is ClassLoader.loadClass() supposed to work on module-info classes?

Alan Bateman Alan.Bateman at oracle.com
Wed Dec 2 13:56:00 UTC 2015


On 02/12/2015 11:01, Stephane Epardaud wrote:
> Just tried it and got:
>
> Exception in thread "main" java.lang.ClassFormatError: Illegal class
> name "com.ceylon.java9.Test" in class file module-info
>      at java.lang.ClassLoader.defineClass1(java.base at 9.0/Native Method)
>      at java.lang.ClassLoader.defineClass(java.base at 9.0/ClassLoader.java:854)
>      at
> java.security.SecureClassLoader.defineClass(java.base at 9.0/SecureClassLoader.java:152)
>      at
> java.net.URLClassLoader.defineClass(java.base at 9.0/URLClassLoader.java:462)
>      at
> java.net.URLClassLoader.access$100(java.base at 9.0/URLClassLoader.java:75)
>      at java.net.URLClassLoader$1.run(java.base at 9.0/URLClassLoader.java:370)
>      at java.net.URLClassLoader$1.run(java.base at 9.0/URLClassLoader.java:364)
>      at java.security.AccessController.doPrivileged(java.base at 9.0/Native
> Method)
>      at
> java.net.URLClassLoader.findClass(java.base at 9.0/URLClassLoader.java:363)
>      at java.lang.ClassLoader.loadClass(java.base at 9.0/ClassLoader.java:440)
>      at java.lang.ClassLoader.loadClass(java.base at 9.0/ClassLoader.java:373)
>
> I know it works for package-info.class files, but is it supposed to work
> with module-info.class files too? Or is it just not implemented yet?
>
The this_class should be <internal-name>/module-info but in any case, 
this isn't the way to "define" a module to the run-time. Instead modules 
are defined in layers, with Layer.create the method to create a Layer.

-Alan.


More information about the jigsaw-dev mailing list