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 #1640

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

holgerfriedrich
Copy link
Member

@holgerfriedrich holgerfriedrich commented Mar 26, 2024

Allow for compiling with Java 21

  • Support Java 17 and 21, default compilation to Java 17 class files
  • Add profile "j21" to compile to Java 21 class files
  • Upgrade SAT to 0.16.0
  • Adapt Karaf scpipts to allow both Java 17 and 21

Refs:
#1590
openhab/openhab-core#4161
openhab/openhab-addons#16594

@holgerfriedrich holgerfriedrich requested a review from a team as a code owner March 26, 2024 00:03
@holgerfriedrich holgerfriedrich force-pushed the pr-java21 branch 3 times, most recently from f661b01 to 6c57b39 Compare March 31, 2024 16:53
@holgerfriedrich holgerfriedrich changed the title [WIP] Support Java 21 Support Java 21 Mar 31, 2024
* Support Java 17 and 21, default compilation to Java 17 class files
* Add profile "j21" to compile to Java 21 class files
* Upgrade SAT to 0.16.0
* Adapt Karaf scpipts to allow both Java 17 and 21

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
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.

LGTM! Do you know of any other known issues besides openhab/openhab-addons#16591?

@holgerfriedrich
Copy link
Member Author

LGTM! Do you know of any other known issues besides openhab/openhab-addons#16591?

I am not aware of other issues.
Though, I have not tested installing add-ons yet.

Need to migrate my test server to Java 21...

@holgerfriedrich
Copy link
Member Author

holgerfriedrich commented Apr 2, 2024

Proceeding....

Modified snapshot running on RPI5, openhabian bookworm, 64bit with Zulu Java 21:
image
image
Java classes are compiled for java17, as this is the official snapshot.

Adding the KNX binding compiled with -Pj21 works fine.

@holgerfriedrich
Copy link
Member Author

@wborn did you intentionally delay the merge of this one? You already added it to the 4.2 milestone...

Avoid ZipException with ejc >3.30.0.

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

holgerfriedrich commented Apr 3, 2024

Included upgrade for maven-compiler-plugin, refs openhab/openhab-core#4167

@wborn
Copy link
Member

wborn commented Apr 4, 2024

I wanted to give it another test with Java 21 myself too before the check is removed and users start creating issues that they have issues when using Java 21. 😉

@holgerfriedrich
Copy link
Member Author

holgerfriedrich commented Apr 4, 2024

@wborn Highly appreciated. Don't miss the -Pj21 to switch to J21 code generation.
Should I pin persistence.jpa to J17 to make it work for now? I don't think that openhab/openhab-addons#16591 gets merged soon unless we find someone to test it....

It would be good if this PR is part of M2, as it contains the modification of the karaf start scripts that need to go into the deb packages.

I am doing full builds with verify of the current main branches as well, core and webui are fine. Addons still running.

@holgerfriedrich
Copy link
Member Author

There seems to be an issue in the Java21 core build, when output is set to 17. The native J21 build works.
see my CI builds here:
https://github.com/holgerfriedrich/openhab-core/actions
https://github.com/holgerfriedrich/openhab-addons/actions

@holgerfriedrich
Copy link
Member Author

holgerfriedrich commented Apr 5, 2024

With the PRs mentioned above (openhab/openhab-addons#16612, openhab/openhab-addons#16615, openhab/openhab-core#4171) , everything should be fine:

see my CI builds here: 🥳
https://github.com/holgerfriedrich/openhab-core/actions
https://github.com/holgerfriedrich/openhab-addons/action
The builds include Java 17, Java 21 compiler to generate Java 17 classes, and Java 21 compiler generating Java 21 classes.

@holgerfriedrich
Copy link
Member Author

@kaikreuzer will you trigger a new milestone build this weekend? Would be nice if this one makes it into M2....

@wborn
Copy link
Member

wborn commented Apr 6, 2024

I just gave running openHAB on Java 21 another test but there seems to be some issue with date formats when deserializing timestamps on Java 21.

These errors show up when restarting openHAB:

2024-04-06 09:05:10.272 [ERROR] [re.storage.json.internal.JsonStorage] - Couldn't deserialize value 'org.openhab.core.storage.json.internal.StorageEntry@4a2246a9'. Root cause is: Failed parsing 'Apr 6, 2024, 8:53:04 AM' as Date; at path $.sessions[0].createdTime
09:01:06.164 [ERROR] [rnal.common.AbstractInvocationHandler] - An error occurred while calling method 'QueryablePersistenceService.query()' on 'org.openhab.persistence.mapdb.internal.MapDbPersistenceService@39aca3e6': Failed parsing 'Apr 6, 2024, 8:58:09 AM' as Date; at path $.timestamp
com.google.gson.JsonSyntaxException: Failed parsing 'Apr 6, 2024, 8:58:09 AM' as Date; at path $.timestamp
	at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:90) ~[bundleFile:?]
	at com.google.gson.internal.bind.DateTypeAdapter.read(DateTypeAdapter.java:75) ~[bundleFile:?]
	at com.google.gson.internal.bind.DateTypeAdapter.read(DateTypeAdapter.java:46) ~[bundleFile:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.readIntoField(ReflectiveTypeAdapterFactory.java:212) ~[bundleFile:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.readField(ReflectiveTypeAdapterFactory.java:433) ~[bundleFile:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:393) ~[bundleFile:?]
	at com.google.gson.Gson.fromJson(Gson.java:1227) ~[bundleFile:?]
	at com.google.gson.Gson.fromJson(Gson.java:1137) ~[bundleFile:?]
	at com.google.gson.Gson.fromJson(Gson.java:1047) ~[bundleFile:?]
	at com.google.gson.Gson.fromJson(Gson.java:982) ~[bundleFile:?]
	at org.openhab.persistence.mapdb.internal.MapDbPersistenceService.deserialize(MapDbPersistenceService.java:212) ~[?:?]
	at org.openhab.persistence.mapdb.internal.MapDbPersistenceService.query(MapDbPersistenceService.java:202) ~[?:?]
	at jdk.internal.reflect.GeneratedMethodAccessor64.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:147) [bundleFile:?]
	at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
	at java.lang.Thread.run(Thread.java:840) [?:?]
Caused by: java.text.ParseException: Failed to parse date ["Apr 6, 2024, 8:58:09 AM"]: Invalid number: Apr 
	at com.google.gson.internal.bind.util.ISO8601Utils.parse(ISO8601Utils.java:279) ~[bundleFile:?]
	at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:88) ~[bundleFile:?]
	... 20 more
Caused by: java.lang.NumberFormatException: Invalid number: Apr 
	at com.google.gson.internal.bind.util.ISO8601Utils.parseInt(ISO8601Utils.java:316) ~[bundleFile:?]
	at com.google.gson.internal.bind.util.ISO8601Utils.parse(ISO8601Utils.java:133) ~[bundleFile:?]
	at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:88) ~[bundleFile:?]
	... 20 more

@holgerfriedrich
Copy link
Member Author

Thanks, @wborn. I will be busy the next days, so this has to wait - unless you are willing to step in here.

@kaikreuzer
Copy link
Member

@kaikreuzer will you trigger a new milestone build this weekend?

Yes, planned for tomorrow. With @wborn's observations, I think there is no rush to merge this and declare Java 21 support just yet. Better do this on snapshots and make them "round" before M3.

@holgerfriedrich
Copy link
Member Author

Yes, if there are differences in deserialization, we will likely need some time to get this final.

@holgerfriedrich
Copy link
Member Author

@wborn As openhab/openhab-core#4174 is now closed, it could be worth a next try. MapDB should not behave as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants