[OpenJDK 2D-Dev] [PATCH] 4494651: Wrong width and height in BufferedImage GraphicsConfiguration objects

Torsten Landschoff t.landschoff at gmx.de
Mon Feb 2 22:54:43 UTC 2009


Hello List,

A few days before I ran into bug 4494651, after more than 7 years of its 
existence. See 

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4494651

I was curious how hard it would be to build a fixed OpenJDK, so I spent 
half of the saturday to get OpenJDK build and its unit tests running.

Turned out that it wasn't that hard so here are my changes for you to 
consider.

The first diff contains a trivial unit test derived from the example code 
in the bug log. The code should speak for itself.

Tracing the bug to its origin, I found the interesting lookup table in 
BufferedImageGraphicsConfig.java which maps each imageType supported by 
BufferedImage to a BufferedImageGraphicsConfig. I have no idea why that 
would be a good idea (apart from performance), so the second diff just 
removes that feature and creates a new graphics configuration each time 
it is requested.

As the only reason why one would create such a lookup table would be to 
get around performance problems, I wrote a third patch which caches 
the graphics configurations already retrieved in a weak hash map.

Comments welcome. Feel free to apply my code to the OpenJDK code base, 
I'd be glad to sign the Sun Contributor Agreement if needed for such 
a trivial contribution.


Thanks for all your work, I really enjoy working with Java (and even 
more with its virtual machine and great libraries).

Greetings, Torsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4494651-unittest.diff
Type: text/x-diff
Size: 3947 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20090202/81a43e7f/4494651-unittest.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4494651-trivial-fix.diff
Type: text/x-diff
Size: 2647 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20090202/81a43e7f/4494651-trivial-fix.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4494651-cache-configs.diff
Type: text/x-diff
Size: 2449 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20090202/81a43e7f/4494651-cache-configs.diff>


More information about the 2d-dev mailing list