Weird Tycho/JDT Behavior

Contrary to how I understood the documentation (particularly #457413), the Eclipse compiler initially didn’t properly support Java 9.

The problem described here is fixed in recent releases.

Unresolved Java EE Modules

Java EE modules are deprecated for removal and not resolved by default and will be removed in Java 11. The best way to handle this is to use a third-party dependency, but JDT tripped over its own feet when that is done.

This project uses a JAXB class, javax.xml.bind.JAXBContext, which can be found in the Jave EE module java.xml.bind and in the artifact javax.xml.bind:jaxb-api. Adding the artifact as a dependency leads to the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:
	compile (default-compile) on project tycho-jdt:
	Compilation failure
[ERROR] .../java-9-wtf/tycho-jdt/src/main/java/wtf/java9/tycho_jdt/
[ERROR] 	package wtf.java9.tycho_jdt;
[ERROR] 	^
[ERROR] Internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.BinaryModuleBinding.create(
[ERROR] java.lang.NullPointerException
[ERROR] 	at org.eclipse.jdt.internal.compiler.lookup.BinaryModuleBinding.create(
[ERROR] 	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getModuleFromAnswer(
[ERROR] 	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForTypeFromModules(
[ERROR] 	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(
[ERROR] 	at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(
[ERROR] 	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(
[ERROR] 	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveTypesFor(
[ERROR] 	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.getExactMethod(
[ERROR] 	at org.eclipse.jdt.internal.compiler.lookup.Scope.findExactMethod(
[ERROR] 	at org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod(
[ERROR] 	at org.eclipse.jdt.internal.compiler.ast.MessageSend.findMethodBinding(
[ERROR] 	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(
[ERROR] 	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(
[ERROR] 	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(
[ERROR] 	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(
[ERROR] 	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(
[ERROR] 	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(
[ERROR] 	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(
[ERROR] 	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(
[ERROR] 	at org.eclipse.jdt.internal.compiler.Compiler.process(
[ERROR] 	at
[ERROR] 	at java.base/

Research lead to the issues #525522 and #526206, but they are supposedly fixed, so this shouldn’t have happened. Yet it did, so I opened a new issue.

After that was resolved it took some time for the fix to show up in a publicly available artifact. The first artifact I know that contains the fix and works with Java 10 comes with Eclipse Photon I20180531-0700. Execute the following in Eclipse’s plugins folder (you may have to update the version):

mvn install:install-file \
    -Dfile=org.eclipse.jdt.core_3.14.0.v20180528-0519.jar \
    -DgroupId=org.eclipse.tycho \
    -DartifactId=org.eclipse.jdt.core \
    -Dversion=3.14.0.v20180528-0519 \

You can then use that artifact in your build by referencing it as usual - for details, see the POM.

Command Line Flags

Unfortunately, the JDT compiler still seems to be unable to process Java 9’s new command line options, so that removing the dependency and adding --add-modules=java.xml.bind didn’t work either:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:
	compile (default-compile) on project tycho-jdt:
	Fatal error compiling:
	Unrecognized option : --add-modules=java.xml.bind -> [Help 1]

(Last checked: 9.0.4/10.0.1 and org.eclipse.tycho : org.eclipse.jdt.core : 3.14.0.v20180528-0519)