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

Compilation fails using JDK 21 #87

Open
cmoulliard opened this issue Nov 18, 2024 · 0 comments
Open

Compilation fails using JDK 21 #87

cmoulliard opened this issue Nov 18, 2024 · 0 comments

Comments

@cmoulliard
Copy link
Member

Issue

The compilation fails using JDK 21. Two issues should be fixed:

Lombok

mvn install fails en raise this issue

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project buildpack-client: Fatal error compiling: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.javac.tree.JCTree qualid' -> [Help 1]

To fix it, bump the lombok version supporting JDK21

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
            <version>1.18.30</version>
            <optional>true</optional>
        </dependency>

Mockito

Mockito cannot mock this class

Java               : 21
JVM vendor name    : Eclipse Adoptium
JVM vendor version : 21.0.1+12-LTS
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 21.0.1+12-LTS
JVM info           : mixed mode
OS name            : Mac OS X
OS version         : 14.7.1


You are seeing this disclaimer because Mockito is configured to create inlined mocks.
You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.

Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, class dev.snowdrop.buildpack.lifecycle.LifecyclePhaseFactory]
[ERROR]   RestorerTest.testPre10(LifecyclePhaseFactory, BuilderImage, BuilderImage, LogConfig, DockerConfig, DockerClient, StartContainerCmd, LogContainerCmd, WaitContainerCmd, WaitContainerResultCallback, Logger) » ParameterResolution Failed to resolve parameter [dev.snowdrop.buildpack.lifecycle.LifecyclePhaseFactory arg0] in method [void dev.snowdrop.buildpack.lifecycle.phases.RestorerTest.testPre10(dev.snowdrop.buildpack.lifecycle.LifecyclePhaseFactory,dev.snowdrop.buildpack.BuilderImage,dev.snowdrop.buildpack.BuilderImage,dev.snowdrop.buildpack.config.LogConfig,dev.snowdrop.buildpack.config.DockerConfig,com.github.dockerjava.api.DockerClient,com.github.dockerjava.api.command.StartContainerCmd,com.github.dockerjava.api.command.LogContainerCmd,com.github.dockerjava.api.command.WaitContainerCmd,com.github.dockerjava.api.command.WaitContainerResultCallback,dev.snowdrop.buildpack.Logger)]:
Mockito cannot mock this class: class dev.snowdrop.buildpack.lifecycle.LifecyclePhaseFactory.

If you're not sure why you're getting this error, please report to the mailing list.

As documented here, to fix it, bump the version of byte-buddy

        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy</artifactId>
            <version>1.15.4</version>
            <scope>test</scope>
        </dependency>

@BarDweller

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

1 participant