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

Closed
KaiSuchomel opened this issue Nov 15, 2023 · 9 comments
Closed

Support Java 21 #1192

KaiSuchomel opened this issue Nov 15, 2023 · 9 comments

Comments

@KaiSuchomel
Copy link

KaiSuchomel commented Nov 15, 2023

Using ArchUnit 1.2.0 with Java 21 the following warning is produced:

[WARNING] Error during import from jrt:/java.base/java/lang/Integer.class, falling back to simple import java.lang.IllegalArgumentException: Unsupported class file major version 65 at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init> (ClassReader.java:199) at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init> (ClassReader.java:180) at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init> (ClassReader.java:166) at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init> (ClassReader.java:287) at com.tngtech.archunit.core.importer.ClassFileProcessor$UriImporterOfProcessor.tryImport (ClassFileProcessor.java:329) at com.tngtech.archunit.core.importer.resolvers.ClassResolverFromClasspath.tryResolve (ClassResolverFromClasspath.java:51) at com.tngtech.archunit.core.importer.ImportedClasses.resolve (ImportedClasses.java:74) at com.tngtech.archunit.core.importer.ImportedClasses.ensurePresent (ImportedClasses.java:69) at com.tngtech.archunit.core.importer.DependencyResolutionProcess.executeRun (DependencyResolutionProcess.java:146) at com.tngtech.archunit.core.importer.DependencyResolutionProcess.resolve (DependencyResolutionProcess.java:122) at com.tngtech.archunit.core.importer.ClassGraphCreator.complete (ClassGraphCreator.java:99) at com.tngtech.archunit.core.importer.ClassFileProcessor.process (ClassFileProcessor.java:75) at com.tngtech.archunit.core.importer.ClassFileImporter.importLocations (ClassFileImporter.java:325) at com.tngtech.archunit.core.importer.ClassFileImporter.importPaths (ClassFileImporter.java:164) at com.tngtech.archunit.core.importer.ClassFileImporter.importPaths (ClassFileImporter.java:151) at com.tngtech.archunit.core.importer.ClassFileImporter.importPath (ClassFileImporter.java:134)

Whats causing this warning??

I found the Issues #230,#409 that had a similar "WARNING"

@hankem
Copy link
Member

hankem commented Nov 15, 2023

Are you sure that you picked up ArchUnit 1.2.0?

While I can reproduce the problem with ArchUnit ≤1.0.1, I cannot with ArchUnit ≥1.1.0.
#1098, released with ArchUnit 1.1.0, has updated ASM to version 9.5, which had added support for Java 21.

@KaiSuchomel
Copy link
Author

The Rules we have created are using:

<dependency>
     <groupId>com.tngtech.archunit</groupId>
     <artifactId>archunit-junit5</artifactId>
     <version>1.2.0</version>
</dependency>

I have prepared a small quarkus project under: https://github.com/KaiSuchomel/quarkus_openapi/tree/issue/archunitWarningJDK21
When you excute mvn clean package under JDK21 a lot of warnings occure in console:

[WARNING] Error during import from jrt:/java.base/java/lang/Object.class, falling back to simple import
java.lang.IllegalArgumentException: Unsupported class file major version 65
    at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init> (ClassReader.java:199)
    at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init> (ClassReader.java:180)
    at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init> (ClassReader.java:166)
    at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init> (ClassReader.java:287)

Perhaps its a problem in the arch-unit-maven-plugin??

@KaiSuchomel
Copy link
Author

I finally found the Issue. The arch-unit-maven-plugin with arch-unit-build-plugin-core is using an older archunit (1.0.0).
With PR societe-generale/arch-unit-build-plugin-core#73 the Issue is gone.

@hankem
Copy link
Member

hankem commented Nov 15, 2023

Cool; I'm glad that you could solve the problem! 🎉 Then I guess we can also close this issue?

@perlun
Copy link
Contributor

perlun commented Nov 30, 2023

#1098, released with ArchUnit 1.1.0, has updated ASM to version 9.5, which had added support for Java 21.

Thank you for this @hankem, appreciated. 🙏 Perhaps it would make sense to mention #1098 in the ArchUnit 1.1.0 release notes? Since it's such an important change, it deserves a bit more visibility IMO.

@hankem
Copy link
Member

hankem commented Nov 30, 2023

Okay, done.

@codecholeric
Copy link
Collaborator

Gonna close this issue for now, since it seems solved to me 🙂 Feel free to reopen if that's not the case...

@danyel
Copy link

danyel commented Jan 16, 2024

well it is not the case with my setup and I don't use the plugin

00:48:10.193 [main] INFO com.tngtech.archunit.core.PluginLoader -- Detected Java version 21.0.1 00:48:10.490 [main] WARN com.tngtech.archunit.core.importer.ClassFileProcessor -- Couldn't import class from file:///.....class java.lang.IllegalArgumentException: Unsupported class file major version 65 at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init>(ClassReader.java:199) at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init>(ClassReader.java:180) at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init>(ClassReader.java:166) at com.tngtech.archunit.thirdparty.org.objectweb.asm.ClassReader.<init>(ClassReader.java:287) at com.tngtech.archunit.core.importer.ClassFileProcessor.process(ClassFileProcessor.java:69) at com.tngtech.archunit.core.importer.ClassFileImporter.importLocations(ClassFileImporter.java:325) at com.tngtech.archunit.core.importer.ClassFileImporter.importPackages(ClassFileImporter.java:214) at com.tngtech.archunit.core.importer.ClassFileImporter.importPackages(ClassFileImporter.java:225)

image

@patrickuhlmann
Copy link

patrickuhlmann commented Feb 1, 2024

@danyel: I recommend running "mvn dependency:tree" and searching for archunit. In my case I found out that another outdated dependency under dependencyManagement (in my case spring-modulith-bom) was referencing archunit 1.0.1 even tough I wanted to use 1.2.1.

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

No branches or pull requests

6 participants