8000 JDK 21 - Dynamic Loading of Agent (byte-buddy-agent-1.14.4.jar) · Issue #3037 · mockito/mockito · GitHub
[go: up one dir, main page]

Skip to content
JDK 21 - Dynamic Loading of Agent (byte-buddy-agent-1.14.4.jar) #3037
@khmarbaise

Description

@khmarbaise

Based on trying to run Mockito with a simple example project on JDK 21 (EA build) result into the following WARNING:

[INFO] Running com.soebes.jdk21.AFinalClassTest
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
WARNING: A Java agent has been loaded dynamically (/Users/khm/.m2/repository/net/bytebuddy/byte-buddy-agent/1.14.5/byte-buddy-agent-1.14.5.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.793 s - in com.soebes.jdk21.AFinalClassTest

This is related to https://openjdk.org/jeps/451 of the OpenJDK.

Maven Version:

$ /home/khm/mockito-issue » mvn --version
Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39)
Maven home: /Users/khm/tools/maven
Java version: 21-ea, vendor: Oracle Corporation, runtime: /Users/khm/.sdkman/candidates/java/21.ea.26-open
Default locale: en_DE, platform encoding: UTF-8
OS name: "mac os x", version: "13.4", arch: "aarch64", family: "mac"

JDK Version:

$ /home/khm/mockito-issue » java -version
openjdk version "21-ea" 2023-09-19
OpenJDK Runtime Environment (build 21-ea+26-2328)
OpenJDK 64-Bit Server VM (build 21-ea+26-2328, mixed mode, sharing)

Mockito Version: (via BOM): 5.3.1
I have overwritten the byte-buddy version with 1.14.5 (https://github.com/khmarbaise/mockito-issue/blob/main/pom.xml#L39) because otherwise JDK 21 failed completely with 1.14.4 wich is defined in mockito 5.3.1.

The questions which are coming up here:

  • Is there an option to handle that at mockito level? I'm not sure?
  • Or at byte-buddy level?
  • Or should that being fixed on Configuration level of the maven plugin (surefire/failsafe)?
    • Might the usage of -XX:+EnableDynamicAgentLoading be enough?

I've created a full working reproducer: https://github.com/khmarbaise/mockito-issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0