Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtend java source version configuration (maven)
Xtend java source version configuration (maven) [message #1868121] Thu, 11 July 2024 11:26 Go to next message
Eclipse UserFriend
Dear all,

I have Eclipse xtend plugins that have a lower Java compatibility level than the JRE/JDK used for compilation. In particular, I'd like to use OpenJDK21 for compilation, but the plugins are still at Java17.
The maven plugin configures the property javaSourceVersion to be lower which implies for instance that xtend extension need to be used for methods such as list.getLast().

However, if the xtend to Java generation is done with OpenJDK21, the javaSourceVersion configuration seems to be ignored, as for instance the method getLast is used in the generated Java code. Interestingly, setting JAVA_HOME to an older JRE implies that the maven org.eclipse.xtend modules produces the "right" code. But this is not a good solution for compilation on a CI server on which paths may change.

What is the method to configure the source code compatibility?

PS: Is it a bug that the javaSourceVersion attribute in class AbstractXtendCompilerMojo is defined by a property with a different name, see below?

@Parameter(property="maven.compiler.source", defaultValue="11")
private String javaSourceVersion;
Re: Xtend java source version configuration (maven) [message #1868124 is a reply to message #1868121] Thu, 11 July 2024 11:37 Go to previous messageGo to next message
Eclipse UserFriend
this is not a generator problem but a linking problem.
and this happens against runtime jdk.
thus we have introduced new methods to avoid this situation
https://eclipse.dev/Xtext/releasenotes.html#/releasenotes/2024/05/28/version-2-35-0

[Updated on: Thu, 11 July 2024 11:40] by Moderator

Re: Xtend java source version configuration (maven) [message #1868130 is a reply to message #1868124] Thu, 11 July 2024 13:37 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the swift answer, but my problem is a different one (sorry, if that was not clear):
I want to generate Java code that is compatible with Java-17, not with Java-21. But the generation is done with an OpenJDK-21. And it currently seems that the JDK used for generation determines the code compatibility of the generated Java code and not the configuration.
Re: Xtend java source version configuration (maven) [message #1868136 is a reply to message #1868130] Thu, 11 July 2024 14:19 Go to previous messageGo to next message
Eclipse UserFriend
The Xtend code generation has no differences in any Java versions >= 8
The problem is a linking problem
Not a generation problem

If you link against 21 it will emit calls into 21.
So you need to avoid this

This is what the new LastOrNull as replacement for last will do
Re: Xtend java source version configuration (maven) [message #1868139 is a reply to message #1868136] Thu, 11 July 2024 14:34 Go to previous messageGo to next message
Eclipse UserFriend
See also https://github.com/eclipse/xtext/issues/2981
Re: Xtend java source version configuration (maven) [message #1868157 is a reply to message #1868139] Fri, 12 July 2024 05:26 Go to previous message
Eclipse UserFriend
Thanks, I could resolve the compilation problems by replacing all .last calls by .lastOrNull calls.
Previous Topic:Xtext 2.36.0.M1 is out
Next Topic:Formatting conflict
Goto Forum:
  


Current Time: Mon Apr 21 02:10:59 EDT 2025

Powered by FUDForum. Page generated in 0.06573 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top