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

resolveMainClassName fails when building with Gradle using Java 22 #40074

Closed
wilkinsona opened this issue Mar 22, 2024 · 5 comments
Closed

resolveMainClassName fails when building with Gradle using Java 22 #40074

wilkinsona opened this issue Mar 22, 2024 · 5 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@wilkinsona
Copy link
Member

It fails like this:

Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 66
        at org.springframework.asm.ClassReader.<init>(ClassReader.java:199)
        at org.springframework.asm.ClassReader.<init>(ClassReader.java:180)
        at org.springframework.asm.ClassReader.<init>(ClassReader.java:166)
        at org.springframework.asm.ClassReader.<init>(ClassReader.java:287)
        at org.springframework.boot.loader.tools.MainClassFinder.createClassDescriptor(MainClassFinder.java:254)
        at org.springframework.boot.loader.tools.MainClassFinder.doWithMainClasses(MainClassFinder.java:136)
        at org.springframework.boot.loader.tools.MainClassFinder.findSingleMainClass(MainClassFinder.java:109)
        at org.springframework.boot.gradle.plugin.ResolveMainClassName.findMainClass(ResolveMainClassName.java:145)
        at org.springframework.boot.gradle.plugin.ResolveMainClassName.resolveMainClassName(ResolveMainClassName.java:139)
        at org.springframework.boot.gradle.plugin.ResolveMainClassName.resolveAndStoreMainClassName(ResolveMainClassName.java:124)

This can be worked around by configuring the application's main class name:

springBoot {
    mainClass = 'com.example.ExampleApplication'
}
@wilkinsona wilkinsona added this to the 3.2.x milestone Mar 22, 2024
@wilkinsona wilkinsona added the type: bug A general bug label Mar 22, 2024
@sergey-morenets
Copy link

Hi @wilkinsona

I encountered the same issue while trying to upgrade to JDK 22. Do you have ETA for the fixes?

@wilkinsona
Copy link
Member Author

Not at this time, I'm afraid. Please use the workaround for now.

@Eng-Fouad
Copy link
Contributor

Eng-Fouad commented Apr 14, 2024

What about resolveTestMainClassName (run with bootTestRun)? Is there a workaround?

@Eng-Fouad
Copy link
Contributor

I found a workaround for resolveTestMainClassName:

tasks.getByName<org.springframework.boot.gradle.plugin.ResolveMainClassName>("resolveTestMainClassName") {
    configuredMainClassName.set("io.fouad.tests.TestAppLauncher")
}

@mhalbritter
Copy link
Contributor

Cause for this is that we downgrade Spring Core in the spring-boot-loader-tools to 6.0.10 to workaround a Gradle limitation with multi-version JAR files.

The ClassReader from Spring Framework 6.1 supports Java 22.

@wilkinsona wilkinsona self-assigned this May 2, 2024
@wilkinsona wilkinsona changed the title resolveMainClassName fails when building with Gradle using a Java 22 toolchain resolveMainClassName fails when building with Gradle using Java 22 May 2, 2024
@wilkinsona wilkinsona modified the milestones: 3.2.x, 3.2.6 May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants