On Wed, 24 Mar 2021 09:25:56 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>> src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java >> line 120: >> >>> 118: // don't get the default. >>> 119: invalidateServices(); >>> 120: printServices = new PrintService[0]; >> >> I am not sure this call to invalidateServices() is needed as we are creating >> a new `printServices` object of 0 length so making the old printServices >> invalid is redundant as it is same global variable. > > That's exactly the problem I am addressing. > > In the regular case, the existing services left in `printServices` are > invalidated before `newServices` is assigned to it. Yet no existing services > are invalidated if all the printers were removed from the system. > > Why is it needed to invalidate deleted services if the list of printers is > updated and if at least one printer is left in the system? Why is it not > needed to invalidate deleted services if all the printers are removed from > the system? Since this is windows specific code, I am not sure if system will not have any printers. I guess by default, Microsoft XPS Document Writer, Microsoft Print-to-PDF, Fax are present in printers list. That is the reason we do not have getPrintService() return 0 printer although there may not be any real printer present in windows system...reason for some failure in jtreg test which caused us to use `@key printer `tag in those tests to make real printers are configured. ------------- PR: https://git.openjdk.java.net/jdk/pull/3151