RFR: 6521141: DebugGraphics NPE @ setFont(); [v5]
Tejesh R
tr at openjdk.org
Mon Aug 1 06:16:46 UTC 2022
On Fri, 29 Jul 2022 16:50:08 GMT, Phil Race <prr at openjdk.org> wrote:
>> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Fix: Java doc modified and Graphics contexts created in null case
>
> src/java.desktop/share/classes/javax/swing/DebugGraphics.java line 87:
>
>> 85: // directly.
>> 86: StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
>> 87: if ((graphics == null) && (walker.getCallerClass() != this.getClass())) {
>
> I don't know if creating a StackWalker is expensive but I think it should be done only if graphics == null
>
> Also the version of getInstance() being called here might throw SecurityException
> https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/StackWalker.html#getInstance(java.lang.StackWalker.Option)
>
> So you'll need to wrap it in a doPrivileged.
Checking only if `graphics == null `will also handle the case when user sets the `graphics` to null by passing null in the constructor, so removing StackWalker and checking only for `graphics == null` will handle both the cases whether its internal class or called from other class.
-------------
PR: https://git.openjdk.org/jdk/pull/9673
More information about the client-libs-dev
mailing list