Example code in JDK8 requiring change for modular function

David Holmes david.holmes at oracle.com
Sun May 6 20:36:04 PDT 2012


On 7/05/2012 12:17 AM, Alan Bateman wrote:
> On 06/05/2012 13:36, David Holmes wrote:
>> :
>>>
>>> When running in "modular mode" the system class loader is the class
>>> loader of the entry module, where as what we really want to use is
>>> the class loader of the callee (the class loader used to load Files).
>>
>>
>> The system class loader needed not be the classloader of the callee.
>> So if we expect this to use the loader of the callee then the code is
>> broken regardless of module-mode.
> This code works as specified, if you have a custom file type detector
> then you put it on the system class path and it will be located.

Okay - then the expectation is _not_ to use the loader of the callee at 
all. That's fine.

> To work with modules it requires changes, including specification

Sure.

David
-----

> changes. This goes for many other areas of the JDK, I assume Paul just
> picked this one out to start a discussion on the changes that will need
> to happen across the board. In this case the specification will need to
> make it clear how it works when running with modules.
> Implementation-wise it will require the base module to have "requires
> optional service java.nio.file.spi.FileTypeDetector" in its module
> declaration and the ServiceLoader usage changed as the legacy system
> class loader notion doesn't make sense when running with modules. For
> this case then loadInstalled is fine. It would also be fine to use
> Files.class.getClassLoader, assuming that it returns a ModuleClassLoader
> (that's a TBD for the base module in Mandy's slides).
>
> -Alan.



More information about the jigsaw-dev mailing list