Skip to content

Add Mockito as an agent #11449

Closed
Closed

Description

@Bukama

New feature, improvement proposal

When running mvnup/ApplicabilityTests tests, there is a warning of Mockito that it should be added as an agent.

Mockito is currently self-attaching to enable the inline-mock-maker. This will no longer work in future releases of the JDK. Please add Mockito as an agent to your build as described in Mockito's documentation: https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3
WARNING: A Java agent has been loaded dynamically (C:\Users\matth.m2\repository\net\bytebuddy\byte-buddy-agent\1.17.7\byte-buddy-agent-1.17.7.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
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

Activity

  1. added
    enhancement
    on Nov 16, 2025
  2. added this to the 4.1.0 milestone on Nov 17, 2025
  3. kri-jha commented on Dec 2, 2025

    @kri-jha

    Hi, I would like to work on this issue.

    I have reviewed the Mockito agent-loading warning and understand that future JDK versions will restrict dynamic attachment. My plan is to reproduce the warning, update the test execution configuration to add the Mockito/ByteBuddy agent via -javaagent, verify the fix, and submit a focused PR.

    Please let me know if there are any additional guidelines before I proceed.

    Thank you!

  4. assokhi commented on Mar 15, 2026

    @assokhi
    Contributor

    @kri-jha Are you still working on this? If not, I'd love to pick this up and submit a PR.

  5. slawekjaranowski commented on Mar 15, 2026

    @slawekjaranowski
    Member

    @Bukama @gnodet where should it be implemented?

    I think that is is surefire responsibility for executing test so should be implemented in surefire
    so issue is rather for surefire not for Maven core ...

  6. Hiteshsai007 commented on Jun 25, 2026

    @Hiteshsai007
    Contributor

    The issue was caused by using ${org.mockito:mockito-core:jar} in the mockito profile. Since ${...} properties are resolved at POM parse time before dependency:properties runs, the path remained empty.

    I resolved this by changing it to use Surefire/Failsafe late-binding interpolation @{org.mockito:mockito-core:jar}, which resolves the path during test execution. I also updated the profile to preserve @{jacocoArgLine} and covered both the Surefire and Failsafe plugins.

  7. added a commit that references this issue on Jul 3, 2026
  8. added a commit that references this issue on Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementmvn4

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions