United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6232446 Font.equals in 1.4.2 needs tightening to include the native font pointer.
JDK-6232446 : Font.equals in 1.4.2 needs tightening to include the native font pointer.

Details
Type:
Bug
Submit Date:
2005-02-24
Status:
Resolved
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2005-07-26
Component:
client-libs
OS:
generic
Sub-Component:
2d
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:
1.4.2_10 (b01)

Related Reports
Relates:

Sub Tasks

Description
Running in plugin if the locale specific fonts are preferred sometimes
labels in Swing UIs are clipped.
###@###.### 2005-2-24 00:21:47 GMT

                                    

Comments
EVALUATION

Font.equals doesn't take into account that the composite font may be different
in this case so the font metrics cache on SunGraphics2D may return a metrics
object from an inappropiate font.

This bug is 1.4.2_X only. It is not present in 1.5 or later.
###@###.### 2005-2-24 00:21:47 GMT
                                     
2005-02-24
SUGGESTED FIX

There's a very simple fix for this. Make Font.equals additionally
compare the Java "long"s which hold the pointer addresses for the "peers".
They'll be different for each of these cases.
% sccs diffs -C Font.java

------- Font.java -------
*** /tmp/sccs.FjaO5w    Wed Feb 23 10:56:44 2005
--- Font.java    Wed Feb 23 10:55:10 2005
***************
*** 1100,1105 ****
--- 1100,1106 ----
          return  (size == font.size)
            && (pointSize == font.pointSize)
            && (style == font.style)
+           && (pNativeFont == font.pNativeFont)
            && name.equals(font.name)
            && thismat[0] == thatmat[0]
            && thismat[1] == thatmat[1]

###@###.### 2005-2-24 00:21:47 GMT
                                     
2005-02-24



Hardware and Software, Engineered to Work Together