RFR: 8269638: Property methods, setters, and getters in printing API should be final [v4]
Phil Race
prr at openjdk.java.net
Fri Jul 16 21:12:55 UTC 2021
On Fri, 16 Jul 2021 13:41:15 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
> > looks good..
> > However I have a different question...I was looking at printerProperty and I saw In l182, we are not checking for getDefaultPrinter() returns null or not but in l120, we do...Is it not required in l182?
>
> It might be a good follow-on bug to skip lines 185-6 if `getDefaultPrinter()` is `null` (else it will NPE), but it's completely unrelated to this fix so wouldn't be done as part of this PR.
I don't think there's a problem here.
Else we'd have had a thousand bug reports by now.
Printer can never be null. Its instaniated by the private PrinterJob constructor.
So perhaps more to the point is are the lines right before that necessary ?
<pre>
if (value == null) {
value = Printer.getDefaultPrinter();
}
</pre>
The public no-args factory method returns null if it can't find a printer and the one
where the app supplies the printer to the factory method that takes one it NPEs out in the internal constuctor
if you pass in the illegal value NULL as the printer.
There's a small issue there as the doc doesn't actually say that but anyone
who has tried it will have found out pretty quickly !
-------------
PR: https://git.openjdk.java.net/jfx/pull/574
More information about the openjfx-dev
mailing list