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

Adopt Class File API (preview feature Java 22) #165

Open
rfscholte opened this issue Aug 21, 2023 · 3 comments
Open

Adopt Class File API (preview feature Java 22) #165

rfscholte opened this issue Aug 21, 2023 · 3 comments

Comments

@rfscholte
Copy link
Member

See https://bugs.openjdk.org/browse/JDK-8308754 , which means that as of that version this should be the preferred way to parse class files over ASM, i.e. introduce a src/main/java22 with the required code.

@jorsol
Copy link
Contributor

jorsol commented Oct 31, 2023

The issue is that preview features require running with --enable-preview, so it should not be the preferred way until it's GA.

The bad news is that if you introduce src/main/java22, the classes will need to be compiled with --enable-preview (which is perfectly possible), but then every single run on Java 22 would require using --enable-preview at runtime and that might not be desirable (or might not be even possible on some scenarios), also using MRJAR, would mean that Java 23+ will break when you compile code that targets Java 22 (with --enable-preview) code with 22's compiler and try to run it with 23 you get an UnsupportedClassVersionError (preview features are not intended to be in production code).

Yet, there is some good news to actually start adopting the Class File API before its GA, but it requires introducing a dependency: https://github.com/Glavo/classfile, with this dependency is possible to use the Class File API even in Java 17, so one idea should be to actually introduce the dependency in src/main/java17 to use and test the Class File API (using org.glavo.classfile), and when the Class File API is finished introduce something like src/main/java25 and it will be just a swap of org.glavo.classfile to the new java.lang.classfile.

@rfscholte
Copy link
Member Author

I agree that it should not be added as long as it's a preview feature, for the reasons you mention. Currently upgrading ASM is sufficient to support the latest Java version to read the module descriptor, so there's no real rush to implement this.

@jorsol
Copy link
Contributor

jorsol commented Oct 7, 2024

Proposed to be targeted in Java 24: JEP 484: Class-File API, once this is integrated it can be added to plexus-languages.

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

No branches or pull requests

3 participants