[OpenJDK 2D-Dev] Review Reqeust for Bug 100068 - SunGraphics2D exposes a reference to itself while non fully initialised

Mario Torre mario.torre at aicas.com
Sat Jun 13 00:57:44 UTC 2009


Il giorno ven, 12/06/2009 alle 10.13 -0700, Phil Race ha scritto:
> > If I don't set the loop in the
>  > constructor, and don't check for null in the getter, I get NPE in
>  > various places,
> 
> Isn't that just a bug in (I guess) your SurfaceData subclass ?
> 
> -phil.

Hi Phil!

No, because this is with the "plain" OpenJDK and not with my
SurfaceData. This is because all the users of this field expect a valid
non null value, but if we don't set it in the constructor, only the
calls that happens after validate() will see a non null value. Having
this null check in checkFontInfo also makes the NPE disappear in the
Java2D demo, thus obtaining the same effect as initialising in the
constructor, but without exposing "this". It has to be checked if there
are other possible location where this variable is used non initialised,
but I doubt. It's not really robust though if we depend on this
initialisation in the constructor the way it is in my opinion. Not that
is a serious bug, and in fact we could even say it's not a bug because
the code works, but it's not correct in my point of view and looks easy
to fix, so... Just want to be sure that the proposed solution doesn't
add new bugs in some corner cases or doesn't add overhead, so who knows
the code better has the last word on that, of course.

Cheers,
Mario
-- 
Mario Torre, Software Developer, http://www.jroller.com/neugens/
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-44
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF

USt-Id: DE216375633, Handelsregister HRB 109481, AG Mannheim
Geschäftsführer: Dr. James J. Hunt

Please, support open standards:
http://endsoftpatents.org/




More information about the 2d-dev mailing list