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

Unify version of Java targeted by the tools #921

Closed
ahelwer opened this issue Apr 28, 2024 · 13 comments · Fixed by #925
Closed

Unify version of Java targeted by the tools #921

ahelwer opened this issue Apr 28, 2024 · 13 comments · Fixed by #925
Labels
DevEnvironment Everything related to the Toolbox development environment Tools The command line tools - TLC, SANY, ...

Comments

@ahelwer
Copy link
Contributor

ahelwer commented Apr 28, 2024

Currently our Java version story is a bit out of focus:

So is it just Java 11 then? We should switch to specifying the release="11" parameter to the ant javac task instead of the source and target parameters? Because currently we are declaring that the tools are compatible with Java 8 which is not true and produces the "bootstrap class path not set in conjunction with -source 8" warning during compilation.

@lemmy
Copy link
Member

lemmy commented Apr 28, 2024

Parts a tla2tools.jar should still work with Java 1.8.

@ahelwer
Copy link
Contributor Author

ahelwer commented Apr 28, 2024

If an execution does not use the TLAFlightRecorder class then yes it will work with Java 8. However I don't think it's a good idea to ship a library that says it's Java 8 compatible while parts of it are not Java 8 compatible and will fail at runtime for that reason.

@lemmy
Copy link
Member

lemmy commented Apr 28, 2024

Users can put their own version of TLAFlightRecorder on the classpath and continue with 1.8. IIRC there are still users with 1.8 out there.

@ahelwer
Copy link
Contributor Author

ahelwer commented Apr 28, 2024

All right well an issue is we won't be able to add -Werror to the javac args to treat warnings as errors (thus keeping more from being added) because javac detects that the code it's compiling isn't v8-compatible and issues the bootstrap path warning. Also it won't compile on Windows which is more strict about this kind of thing I guess.

@lemmy
Copy link
Member

lemmy commented Apr 28, 2024

Can you explain why Java is more strict on Windows? This sounds strange given that Java's main feature is platform independence.

@ahelwer
Copy link
Contributor Author

ahelwer commented Apr 28, 2024

Well it's a compile-once-run-anywhere thing so any artifacts we compile will run on windows just fine, but the actual act of compilation is I guess different enough that actually trying to run the ant build on windows will fail with "unable to find jdk.jfr package" errors. Maybe there's a workaround but I wasn't able to find it other than specifying release="11" in the customBuild.xml file.

@lemmy
Copy link
Member

lemmy commented Apr 28, 2024

This must be a local issue because compilation on Windows used to work when the CI (including UI tests) still ran on Azure Pipelines. At any rate, let's make a conscious/explicit decision to break (partial) 1.8 compatibly, instead of as a side-effect of turning warnings into errors. A message to the TLA+ Google group could, perhaps, answer if some users are still on 1.8.

@ahelwer
Copy link
Contributor Author

ahelwer commented Apr 28, 2024

I posted here: https://groups.google.com/g/tlaplus/c/BReLjG8ako4

If we go through with this change I suggest bumping the minor version so nightly releases are uploaded to a separate release from where they're uploaded now.

@Calvin-L
Copy link
Collaborator

Calvin-L commented Apr 28, 2024

I don't think it's a good idea to ship a library that says it's Java 8 compatible while parts of it are not Java 8 compatible and will fail at runtime for that reason.

Welcome to the Java Ecosystem! 😅 What you've described is not a best practice, but it is a practice, and a remarkably common one. It works well for features that can be enabled/disabled at run-time.

Since AFAIK there's no flag or environment variable to disable TLAFlightRecorder, here's what I think we should do ---

IIRC there are still users with 1.8 out there.

The right (?) way to support those users is to ship a multi-release jar:

  • Most of the tools' source code (including a no-op implementation of TLAFlightRecorder) should be compiled with -release 8 as @ahelwer suggested.
  • The real implementation of TLAFlightRecorder should be compiled with -release 9 and the class file should be placed in the META-INF/versions/9 subdirectory of the final jar.
  • The final jar manifest should include Multi-Release: true.

@lemmy
Copy link
Member

lemmy commented Apr 28, 2024

It should be confirmed that OSGi (the Toolbox) correctly handles such a multi-release.jar. That said, https://metabase.tlapl.us/dashboard/1 does not indicate Java 8 users.

@Calvin-L
Copy link
Collaborator

Calvin-L commented May 7, 2024

Recent versions of OSGi do support multi-release jars c. 2018, but the toolbox might be using an older version that doesn't. (I don't know enough about OSGi to tell.)

If dropping Java 8 support is an option, it seems like the best one. I won't miss it. :)

@ahelwer
Copy link
Contributor Author

ahelwer commented May 7, 2024

No replies to the google group posting after a week. I don't know how long we ought to wait. Should we make the switch now? If it breaks for somebody then we can look at doing a multi-release jar.

@lemmy
Copy link
Member

lemmy commented May 7, 2024

Mention it one more time at next week's community meeting?

@lemmy lemmy added Tools The command line tools - TLC, SANY, ... DevEnvironment Everything related to the Toolbox development environment labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DevEnvironment Everything related to the Toolbox development environment Tools The command line tools - TLC, SANY, ...
Development

Successfully merging a pull request may close this issue.

3 participants