Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6560738
Votes 0
Synopsis SU2.drawChars() calls Font.getStringBounds() with offset instead of limit in printing path
Category java:classes_2d
Reported Against
Release Fixed 7(b14)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs
Submit Date 22-MAY-2007
Description
Whilst running the test case from bug 6560196 on JDK 7 b12 I obtained the
following exception :
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: range length: -2
        at java.awt.Font.getStringBounds(Font.java:2243)
        at sun.swing.SwingUtilities2.drawChars(SwingUtilities2.java:793)
        at javax.swing.text.Utilities.drawTabbedText(Utilities.java:188)
        at javax.swing.text.GlyphPainter1.paint(GlyphPainter1.java:120)
        at javax.swing.text.GlyphView.paintTextUsingColor(GlyphView.java:490)
        at javax.swing.text.GlyphView.paint(GlyphView.java:481)
        at javax.swing.text.BoxView.paintChild(BoxView.java:162)
        at javax.swing.text.BoxView.paint(BoxView.java:434)
...

I traced this back to the b08 fix for 6488219, and specifically this :
>          getStringBounds(data, offset, length, frc).getWidth(); 

the problem is that the third argument should be "limit" not "length"

So long as offset is zero, this isn't a problem, but in some cases
Swing text will index into an array and expose this bug.
Also the code path in which this shows up is only used when printing.
Posted Date : 2007-05-22 18:53:10.0
Work Around
N/A
Evaluation
Instead of "length", the argument should be "offset+length"
*** (#1 of 1): [ UNSAVED ]   xxxxx@xxxxx  
Posted Date : 2007-05-22 19:05:01.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang