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

Peter Levart peter.levart at gmail.com
Fri Dec 4 19:58:49 UTC 2015



On 12/04/2015 03:37 PM, Jonathan Gibbons wrote:
> On 12/04/2015 06:33 AM, Stephane Epardaud wrote:
>>
>> On 04/12/2015 15:21, David M. Lloyd wrote:
>>>
>>> IIRC there is *already* within Java 9 an option to compile against 
>>> previous JDK ABIs (which are bundled with JDK 9), isn't there?
>>>
>> Ah that's interesting, I got hit by calls to byteBuffer(int) which 
>> compiled in JDK9 to ByteBuffer.position(int) which did not run in 
>> JDK8 which only had Buffer.position(int).
>>
>> I'd love for that flag to exist ;)
>>
>>
>
> This is the new javac "-release N" option, which functions like a 
> combination of "-source N -target N -bootclasspath rtN.jar", where 
> "rtN.jar" is the public API of the specified release.
>
> -- Jon

Hi Jonathan,

I know about those options. What I was wanting to know is whether the 
class file format will change and for what features.

Currently, modular javac mode is only possible in -release 9. But if 
there are no changes to class file format needed for normal classes, 
then I suspect that the following combination:

     javac -source 9 -target 8

...could be possible - javac would compile Java 9 language in modular 
mode and emit class files with older version. If the new class file 
format is only required for producing module-info.class files, then only 
this file would be emitted in new version of class file. I'm thinking of 
an easier way of producing modular jars that also run with JDK8 on the 
classpath.

A useful combination would also be:

     javac -release 8 -source 9, which would function like: -source 9 
-target 8 -bootclasspath rt8.jar

(when combining -release with -source or -target, I would like the later 
two to override the particular aspects of -release)

In short, as I understand, -source N+1 requires -target N+1 if there are 
features in language N+1 that require new features of class file version 
N+1, otherwise javac could theoretically emit class file version N even 
for language N+1. Now if jigsaw is the only feature in JDK9 that drives 
the increment of class file version, and if that is only required for 
module-info.class files, the above combinations, if possible to support, 
could be useful as they would provide modules at compile-time with 
deployment on JDK8 classpath or as modules on JDK9.


Regards, Peter



More information about the jigsaw-dev mailing list