ServiceLoader.load(Class, ClassLoader) does not load services exposed in modules and loaded by parent CL

Alan Bateman Alan.Bateman at oracle.com
Tue May 29 20:20:58 UTC 2018


On 29/05/2018 21:00, Jochen Theodorou wrote:
>
>
> Am 24.05.2018 um 19:33 schrieb Robert Scholte:
> [...]
>> I can quote Alan:
>> Rhino used to be the JS engine in older releases and that may have 
>> been in rt.jar and so loaded by the boot loader. When Nashorn 
>> replaced it (in JDK 8) then it was configured to be defined to the 
>> extension class loader so this is why the code snippet doesn't find it.
>
> how is this handles in JDK 9 now?
In the JDK 8, the Nashorn classes were loaded/defined by the extension 
class loader. In JDK 9, the jdk.scripting.nashorn module is mapped to 
the platform (formerly extension) class loader. So no real change and 
the issue that Robert refers to must be an issue with JDK 8 too. I can't 
quite tell if this is the same as what Peter is seeing but if Maven is 
creating class loaders with null as the parent then some of the platform 
classes, and the classes in the service provider modules, will not be 
visible.

-Alan


More information about the jigsaw-dev mailing list