Skip to content

Configure Mockito to avoid self attachment warning#24094

Draft
apupier wants to merge 1 commit into
apache:mainfrom
apupier:configureMockitoToAvoidSelfAttachmentWarning
Draft

Configure Mockito to avoid self attachment warning#24094
apupier wants to merge 1 commit into
apache:mainfrom
apupier:configureMockitoToAvoidSelfAttachmentWarning

Conversation

@apupier

@apupier apupier commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

it is in link with https://openjdk.org/jeps/451

the warnings were:

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
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
(/home/apupier/.m2/repository/net/bytebuddy/byte-buddy-agent/1.18.10/byte-buddy-agent-1.18.10.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

it remains just OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended which has a different root cause

note that I have not found a JEP for planned removal of the Dynamic Loading of Agents. Anyway, it will allow to be ready and it is mentioned as a bit safer.

Description

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

it is in link with https://openjdk.org/jeps/451

the warnings were:
```
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
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
(/home/apupier/.m2/repository/net/bytebuddy/byte-buddy-agent/1.18.10/byte-buddy-agent-1.18.10.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
```

it remains just `OpenJDK 64-Bit Server VM warning: Sharing is only
supported for boot loader classes because bootstrap classpath has been
appended` which has a different root cause

note that I have not found a JEP for planned removal of the Dynamic
Loading of Agents. Anyway, it will allow to be ready and it is mentioned
as a bit safer.

Signed-off-by: Aurélien Pupier <apupier@ibm.com>
@davsclaus

Copy link
Copy Markdown
Contributor

Nice if we can remove this warning

@apupier

apupier commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

hum not the kind of errors that i would have expected with this kind of change...:

Error:  Failed to execute goal org.apache.maven.plugins:maven-remote-resources-plugin:3.3.0:process (default) on project bundles-pom: Error loading supplemental data models: Could not find resource 'target/legal/legal.xml'. -> [Help 1]

EDIT: which of course i do not reproduce locally when building directly the maven module in error
EDIT2: reproducing when building from top-level

@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@davsclaus

Copy link
Copy Markdown
Contributor

⏺ The build fails on bundles-pom with:

Error loading supplemental data models: Could not find resource 'target/legal/legal.xml'

This is a build infrastructure issue in the bundles-pom module — the maven-remote-resources-plugin can't find target/legal/legal.xml. This is unrelated to the PR's Mockito changes. It failed
on Java 25 only (the Java 17 job also failed, likely the same cause).

This is a known pattern in the Camel build — the legal.xml supplemental resource is generated by a prior build step, and if that step is skipped or the build order is off (especially with mvnd
parallelism), bundles-pom can't find it. The PR itself (configuring Mockito self-attachment) doesn't touch anything near bundles-pom or the legal/resource plugin setup, so this looks like a
flaky CI issue rather than a problem introduced by the PR.

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

Successfully merging this pull request may close these issues.

2 participants