Skip to content

Issue #17954: Suppress JVM warnings seen in tests#17955

Merged
romani merged 1 commit into
checkstyle:masterfrom
mureinik:17954-jvm-warnings-tests
Oct 20, 2025
Merged

Issue #17954: Suppress JVM warnings seen in tests#17955
romani merged 1 commit into
checkstyle:masterfrom
mureinik:17954-jvm-warnings-tests

Conversation

@mureinik

@mureinik mureinik commented Oct 18, 2025

Copy link
Copy Markdown
Contributor

Fix JVM warnings about sharing and about dynamic agent loading seen in the CI (e.g, from https://dev.azure.com/romanivanovjr/romanivanovjr/_build/results?buildId=32993&view=logs&j=c902ebb4-c9f8-5f09-4e17-ff78fbbc842e&t=9ca98c81-ff64-58f0-9d03-a23ac1c4a111&l=104):

[INFO] --- surefire:3.5.4:test (default-test) @ checkstyle ---
[INFO] Surefire report directory: /home/vsts/work/1/s/target/surefire-reports
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Running com.puppycrawl.tools.checkstyle.api.FileContentsTest
[INFO] Tests run: 23, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.192 s -- in com.puppycrawl.tools.checkstyle.api.FileContentsTest
[INFO] Running com.puppycrawl.tools.checkstyle.api.FileTextTest
[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.166 s -- in com.puppycrawl.tools.checkstyle.api.FileTextTest
[INFO] Running com.puppycrawl.tools.checkstyle.api.AbstractViolationReporterTest
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.045 s -- in com.puppycrawl.tools.checkstyle.api.AbstractViolationReporterTest
[INFO] Running com.puppycrawl.tools.checkstyle.api.FileSetCheckTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.313 s -- in com.puppycrawl.tools.checkstyle.api.FileSetCheckTest
[INFO] Running com.puppycrawl.tools.checkstyle.api.LineColumnTest
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/vsts/work/1/.m2/repository/net/bytebuddy/byte-buddy-agent/1.14.11/byte-buddy-agent-1.14.11.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

Fixes #17954

@mureinik mureinik force-pushed the 17954-jvm-warnings-tests branch from 250daf5 to 8b8f158 Compare October 18, 2025 14:25
@mureinik

mureinik commented Oct 18, 2025

Copy link
Copy Markdown
Contributor Author

Side note: I know issue #17954 is not approved yet, and thus the "Check PR Description / Analyze (pull_request)" CI will fail.

The goal of pushing this PR early is to have the rest of the CI run and assess whether this is a viable solution, or whether this change will break some other CI flow (e.g., if alternative JVMs are used, or if some test somehow depends on JVM behavior).

In the worst case, if the project maintainers aren't on board with this approach, both the issue and the PR shold be closed.

@mureinik mureinik force-pushed the 17954-jvm-warnings-tests branch from 8b8f158 to b4f6119 Compare October 18, 2025 15:25
@mureinik

Copy link
Copy Markdown
Contributor Author

There are two CI failures.
Check PR Description / Analyze (pull_request) is expected to fail, as the issue is not approved (yet).
ci/semaphoreci/pr: Checkstyle CI pipeline on Semaphore fails in the job setup phase, and seems like an ephemeral environmental issue - the previous iteration of this PR did not fail that test, so I'm guessing rerunning this job should clear the error.

@romani

romani commented Oct 18, 2025

Copy link
Copy Markdown
Member

Both relaunched.

@romani

romani commented Oct 18, 2025

Copy link
Copy Markdown
Member

Please share knowledge or links to knowledge what such jvm parameters means and why we need two of them to fix issue

Is this different or same issue?
https://ci.appveyor.com/project/Checkstyle/checkstyle/builds/52930182/job/51iwjpcb4vln1oa9?fullLog=true#L118
Screenshot_20251018-111051

@romani

romani commented Oct 18, 2025

Copy link
Copy Markdown
Member

Ok, I got it, we addressed only

[INFO] Running com.puppycrawl.tools.checkstyle.api.LineColumnTest
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/vsts/work/1/.m2/repository/net/bytebuddy/byte-buddy-agent/1.14.11/byte-buddy-agent-1.14.11.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

@romani

romani commented Oct 18, 2025

Copy link
Copy Markdown
Member

Ok, please share links to knowledge and we are merging this PR.

Thanks a lot for help.

@mureinik

Copy link
Copy Markdown
Contributor Author

Ok, please share links to knowledge and we are merging this PR.

WRT --xShrare:off:
Class Data Sharing (CDS) is a feature that can potentially speed up application startup by having a shared archive of system classes, which acts as a sort of a cache.
When using Mockito in test scenarios, some of these classes are loaded by a different classsloader than the one CDS expects, causing this warning message. As the performance gain is negligible anyway in this scenario, it's easier to just shut it off.
Relevant links:

WRT -XX:+EnableDynamicAgentLoading:
Java has been preparing to get rid of dynamic agent loading since Java 21 (see JEP 451), and will issue a warning when you try to use this feature, as Mockito does internally.
At the time of writing (and note that Java 25 is now the latest!) there's no equivalent feature that provides similar functionality, so the common practice is just to allow this feature (or disable the warning) with that JVM flag.
Note that this isn't really an edge case - it's used by mocking libraries (like Mockito), APM tools and even IAST tools, so I don't think it will be going away any time soon.

@romani romani merged commit 5321622 into checkstyle:master Oct 20, 2025
120 of 121 checks passed
@mureinik mureinik deleted the 17954-jvm-warnings-tests branch October 20, 2025 20:40
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.

JVM warnings when running tests

2 participants