[OpenJDK 2D-Dev] Review Reqeust for Bug 100068 - SunGraphics2D exposes a reference to itself while non fully initialised
Phil.Race at Sun.COM
Sat Jun 13 01:41:59 UTC 2009
Did you, or can you, share a test case (and any platform specific info
needed) to repro this?
Mario Torre wrote:
> 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 ?
> 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.
More information about the 2d-dev