Bug 26618 - Graphics(2D) type hierarchy broken?
Summary: Graphics(2D) type hierarchy broken?
Status: RESOLVED DUPLICATE of bug 26486
Alias: None
Product: classpath
Classification: Unclassified
Component: awt (show other bugs)
Version: 0.90
: P3 critical
Target Milestone: 0.91
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-09 10:30 UTC by Norman Hendrich
Modified: 2006-04-27 11:58 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
testcase (277 bytes, text/plain)
2006-03-09 10:31 UTC, Norman Hendrich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Norman Hendrich 2006-03-09 10:30:40 UTC
Sorry. I think I have a blackout here...

I am accustomed to get ClassCastExceptions from several of my test apps, 
but I always assumed these were due to Graphics2D not being properly 
implemented.

However, some testing reveals that GtkComponent.paintComponent() actually
casts to GdkGraphics, with GdkGraphics2D not a subclass of GdkGraphics.
Please tell me I am doing something stupid! I just won't believe that 
classpath could have run my apps for ages, if not for this particular way
of designing the type hierarchy. It seems that my custom component returns
a valid Graphics2D, but GtkComponent refuses to use that...

See attached testcase.

- Norman
Comment 1 Norman Hendrich 2006-03-09 10:31:52 UTC
Created attachment 11007 [details]
testcase
Comment 2 Norman Hendrich 2006-03-10 15:51:25 UTC
I've played some more with this. The typecasts to GdkGraphics in

gnu.java.awt.peer.gtk.GtkComponentPeer.paintComponent() 
gnu.java.awt.peer.gtk.GtkComponentPeer.updateComponent()

are definitely broken when running in Java2D-mode, because the GdkGraphics2D
object returned from getGraphics() cannot be cast to a GdkGraphics. I changed
those lines to cast to a (Graphics) instead. (I still have no idea why those
typecasts were required at all.)

The next problem is a NullPointerException in RepaintManager.commitBuffer()
because GdkGraphics2D.getClipBounds() sometimes returns null. For testing,
I added a simple extra null-check to RepaintManager, but we probably want
to change Graphics2D.getClipBounds() to never return null instead.

Afterwards, my test application starts up, but it paints garbage only,
probably because the Graphics2D draw/fill operations are rather broken.







Comment 3 Thomas Fitzsimmons 2006-03-15 18:48:04 UTC
I introduced these methods in my not-yet-committed AWT performance patch.  I'll fix these issues before committing.  Thanks for pointing them out.


*** This bug has been marked as a duplicate of 26486 ***
Comment 4 Norman Hendrich 2006-03-15 19:54:11 UTC
> I introduced these methods in my not-yet-committed AWT performance patch.  I'll
> fix these issues before committing.  Thanks for pointing them out.

Oops. It just didn't occur to me that your PR26486 patch could be related 
to this, because I got similar ClassCastExceptions when I last tested
Graphics2D (about three months ago, I don't remember the details). I guess 
I should start reading patches more thoroughly...