SunGraphics2D instead of Graphics2D

Mario Torre neugens at
Fri Nov 18 15:17:44 PST 2011

Hello all,

While developing our Swing/JavaFX integration [1] I've found that with the aqua look and feel it doesn't paint correctly, unless I set the awt.nativeDoubleBuffering to false.

The reason for this is that internally, Graphics2D objects are casted to SunGraphics2D, probably this is a left over for some specific optimizations in the Apple JDK, but from the current OpenJDK code I can't see any reason for that cast to exist.

The problem surfaces because we use a special component to proxy heavyweight behavior to the Java FX view and to provide graphics and all the usual goodies that the swing hierarchy wants.

In particular, the graphics object for the heavyweight component is a proxy graphics that wraps a BufferedImage.

Since those cast gets in the way only when native double buffering is enabled on the Mac, I can workaround for older JDK releases, but I would really like to see if this fix can be pushed in for OpenJDK 7.

The webrev for the patch is here:

Any comments?


[1]  Some links:
pgp key: PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF

Proud GNU Classpath developer:
Read About us at:

Please, support open standards:

More information about the macosx-port-dev mailing list