javac: "legacy" mode

Jonathan Gibbons jonathan.gibbons at oracle.com
Fri Jan 27 13:37:12 PST 2012


Until recently, javac implicitly supported "legacy" compilations 
(meaning compilations that were valid in JDK 7 or earlier). This was as 
side-effect by design of "single-module mode", because the default 
requires if none was given was "jdk at 8-ea".

Now, we have changed the default requires to "java.base@>=8".  This 
means that without any other changes, a legacy compilation referencing 
non-base classes will fail to compile.

There are two possible solutions.

1. Have javac support -Xmode:legacy, which would change the default 
requires. It would also require everyone to change the way they use 
javac for legacy compilations.

2. Distinguish between the case of no module compilation units in a 
compilation and module compilation units involved, but not containing 
any requires on the base module.  If no module compilation unit is 
observable, one would be synthesized containing "requires jdk;" or some 
equivalent.   If any observable module compilation unit does not contain 
a requires for the platform base, then a "requires java.base>=N;" will 
be generated, with an appropriate value of N, per the spec.

-- Jon




More information about the jigsaw-dev mailing list