Compact profiles broken?

Uwe Schindler uschindler at apache.org
Sat May 21 10:15:31 UTC 2016


Hi,

> > $ javac -source 8 -target 8 Test.java
> > warning: [options] bootstrap class path not set in conjunction with -source
> 1.8
> > 1 warning
> >
> So the question is how should javac behave with -source/-target when
> -bootclasspath is not specified. This has always been a problematic
> usage because it means javac compiling for the older edition of the Java
> Language but with the APIs for the runtime that javac is running on. The
> warning was added in JDK 7 to try to bring attention to the problematic
> usage. I'm not sure if anything should change now to align it with the
> policy for root modules. This may be something that Jon can comment on.
> The right thing is of course to add -bootclasspath or just replace the
> usage with `javac -release 8`.

I agree, that's already done in Lucene since yesterday:
https://issues.apache.org/jira/browse/LUCENE-7292

With that -release option, it of course does not fail, because it uses older ct.sym. The problem is now that you get no "warning" that the compilation may not work with Java 9. I would have expected to get a warning by javac where it says: "java.xml.bind" won't work by default in Java 9. Of course that's another discussion about pros and cons.

Here is one problem, I figured out about "-release":

Lot's of tools like Maven or Gradle make it really hard to pass "-release 8", because those tools have automatisms to automatically pass "source/target" to the javac compiler and you cannot do anything against that. Lucene/Solr is fine, because it uses Ant - but Elasticsearch has a hard time with Gradle: Gradle detects the Java version and passes the targeted release version as "1.8" automatically. If you add "-release 8", it fails because of incompatible command line arguments.

In addition, most tools still use "1.8" for everything before 9. So if you make it pass "-release" using the build systems's variables, it would pass "1.8". Unfortunately, it only accepts "-release 8", not "-release 1.8". I'd suggest to add support for old version numbers in the same way like source/target accepts both "1.8" and "8".

My proposal would be: If you start javac with "-source 1.8 -target 1.8" and don't pass a bootclasspath, it should switch to "-release 8" for convenience. What do you think? Alternatively allow source and target when passing release if it's not incompatible.

Uwe



More information about the jigsaw-dev mailing list