RFR: 6521141: DebugGraphics NPE @ setFont();

Prasanta Sadhukhan psadhukhan at openjdk.org
Thu Jul 28 12:53:07 UTC 2022


On Thu, 28 Jul 2022 11:47:03 GMT, Tejesh R <tr at openjdk.org> wrote:

> `DebugGraphics` class has a Graphics instance which is been used in slowed down drawing. The `graphics` object is not initialized anywhere inside the class, where it is expected to set explicitly by the user. When the user doesn't set it and try to use the any mehtods like `drawing/setFont`, NPE is raised which is expected. The scenario is taken care by checking if the `graphics` object is null before using it inside the class, thus eliminating the NPE case.

I guess exposing no-args public constructor was wrong and it should have been protected from beginning.
Also, please add a testcase.

src/java.desktop/share/classes/javax/swing/DebugGraphics.java line 349:

> 347:             info().log(toShortString() +
> 348:                     " Setting clipRect: " + (new Rectangle(x, y, width, height)) +
> 349:                     " New clipRect: " + graphics.getClip());

Why this line change is needed? Probably you have added some tabs..Remove this change and similarly from other logs down below.

-------------

PR: https://git.openjdk.org/jdk/pull/9673



More information about the client-libs-dev mailing list