Skip to content
Advertisement

Xtend force java 7 language level

I am using Xtend in intellij from the Xtend-plugin. My project language level is set to Java 8 and Xtend compiles fine to Java 8 (e.g. using lambda expressions).

For specific reasons, I need Xtend to generate Java 7 code, without changing the language level of my remaining project (Java 8).

In the Xtend project settings I can set the language level, however this option is ignored. I believe it is ignored because the remaining project still uses JDK 8 and the Java 8 language level.

Is there an option to force Xtend to use a different (lower) language level than the source?

Advertisement

Answer

There is at least one bug in the Xtend-Compiler which prevents crosscompiling to a lower version of the JDK than the one in the classpath of the project.

Example:

#[ 42, 43 ].forEach[ println(it) ]

If the project if configured to have Java-8 classes in the classpath, the generated Java-Code will automatically use the Java-8 API (the forEach default method of Iterable, Consumer, …)

This is idependent of any source/target level settings.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement