The width and height of a GraphicsConfig is essentially irrelevant
information. If you get the GraphicsConfig of a component, it doesn't
tell you how big that component was, so why should the GC of a BufImg
bear any relation to the dimensions of the image?
If anything, I'd fix it by having it report some fixed bogus (positive,
large) dimensions rather than the dimensions of the first image that it
was created from...
...jim
Dmitri Trembovetski wrote:
Note that this fix may have some performance
implications for cases when there are caches based on the
graphics configuration of the Graphics object used for
rendering - these caches may grow uncontrollably.
I don't know of any other solution for this bug, but I'm
not sure fixing it would do more harm than good.
The bug has only 3 votes after 8 years (all of them
in 2001-2002)..
Thanks,
Dmitri
Torsten Landschoff wrote:
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