Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Java 21 #4161

Merged
merged 1 commit into from
Apr 1, 2024
Merged

Support Java 21 #4161

merged 1 commit into from
Apr 1, 2024

Conversation

holgerfriedrich
Copy link
Member

@holgerfriedrich holgerfriedrich commented Mar 25, 2024

openhab-core can now be compiled an run both on Java 17 and Java 21.

  • Upgrade SAT to 0.16.0
  • Add profiles j17 and j21, automatically activated based on JDK version unless specified.
  • Pin Java version for xtend to 17. As xtend does not yet support Java 21, compile model with Java 17.
  • Includes Compare reference using equals #4125.

Refs: openhab/openhab-distro#1590

@calle2010
Copy link

Have you considered to use maven.compiler.release instead of source/target?
This prevents accidental usage of Java 21 API when compiling for Java 17 on a JDK 21. See also https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#release and https://openjdk.org/jeps/247.

@holgerfriedrich
Copy link
Member Author

Have you considered to use maven.compiler.release instead of source/target? This prevents accidental usage of Java 21 API when compiling for Java 17 on a JDK 21. See also https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#release and https://openjdk.org/jeps/247.

@calle2010 Thanks. This seems reasonable. For core it allows to drop the definition of oh.java.version as well, as it is not used anywhere else.

pom.xml Show resolved Hide resolved
bundles/org.openhab.core.model.item.ide/pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated Show resolved Hide resolved
* Support Java 17 and 21, default compilation to Java 17 class files,
  use maven.compiler.release instead of source and target
* Add profile "j21" to compile to Java 21 class files
* Upgrade SAT to 0.16.0, adapt code which breaks build with new SAT
  checks
* Use model-specific-profile to pin xtend to Java 17

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
@holgerfriedrich
Copy link
Member Author

@wborn Changes are now implemented as proposed. Now the PR is down to a few files. Thanks for directing me towards model-specific-profile.

Copy link
Member

@wborn wborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 👍

@wborn wborn merged commit 9f5a60d into openhab:main Apr 1, 2024
3 checks passed
@wborn wborn added this to the 4.2 milestone Apr 1, 2024
@holgerfriedrich holgerfriedrich deleted the pr-java21 branch April 1, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants