RFR: 8335231: [macos] Test java/awt/print/PrinterJob/Cancel/PrinterJobCancel.java failed on macOS because the case didn't get the expected PrintAbortException [v3]

Prasanta Sadhukhan psadhukhan at openjdk.org
Fri Aug 2 04:57:34 UTC 2024


On Thu, 1 Aug 2024 18:26:50 GMT, Phil Race <prr at openjdk.org> wrote:

>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Restore invokeLater and throw PrinterAbortException from native
>
> src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java line 764:
> 
>> 762:                     }
>> 763:                 }}, null);
>> 764:             } catch (NullPointerException ex) {
> 
> I'm confused. I thought you were going to do something about the null ?
> Unless you don't this code won't work.
> Restoring using invokeLater isn't the same thing as restoring the bug.
> 
> Look at the code that you are calling - it won't run the Runnable if there's an NPE.
> "new Component()" instead of null for example.
> FWIW I do not understand why this code uses LWCToolkit.invokeLater()
> Seems unnecessary.
> Why don't it use EventQueue.invokeLater() directly ?
> That'll solve a couple of problems - simpler code, no null check because no Component arg needed.

Yes, actually I wanted to avoid changing the common `LWCToolkit.invokeLater` (as it needs to use Toolkit.getToolkit if component is null as I was not sure if it is ok to pass any adhoc component via `new Component `in CPrinterJob) which is also used in [accessibility](https://github.com/openjdk/jdk/blob/d10afa26e5c59475e49b353ed34e8e85d0615d92/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java#L148) and [InputMethod](https://github.com/openjdk/jdk/blob/d10afa26e5c59475e49b353ed34e8e85d0615d92/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java#L499) which would have affected and require testing in those areas 
but yes, I didn't see having NPE will render invokeLater a no-op

Changed to use EventQueue.invokeLater..

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20027#discussion_r1701258601


More information about the client-libs-dev mailing list