javac: "legacy" mode
mandy.chung at oracle.com
Fri Jan 27 17:28:56 PST 2012
On 1/27/2012 1:37 PM, Jonathan Gibbons wrote:
> 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.
This seems a major compatibility concern but it might worth taking the
migration story into account. What if javac -source 7 -target 7 uses
the entire "jdk" as the default and keep "java.base" as the default for
-source 8 -target 8 (possibly provide a switch to say using the entire
"jdk" rather than just the base)? I'm in two minds and I think it
deserves some more thought.
> 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.
I did some work to support legacy mode in runtime some time ago . I
have re-based it with the latest jigsaw forest. It's just a good
timing and discuss how legacy mode should work in runtime/compile-time.
I should restart this work soon.
More information about the jigsaw-dev