You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/07/21 13:00:51 UTC

(commons-io) 02/03: When testing on Java 21 and up, enable -XX:+EnableDynamicAgentLoading

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 7038644f0473e735ddb072b71e6e0f93367d86b6
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Mon Jul 21 08:59:15 2025 -0400

    When testing on Java 21 and up, enable -XX:+EnableDynamicAgentLoading
    
    This will eliminate console output like:
    
    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/runner/.m2/repository/net/bytebuddy/byte-buddy-agent/1.17.6/byte-buddy-agent-1.17.6.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
    WARNING: A terminally deprecated method in sun.misc.Unsafe has been
    called
    WARNING: sun.misc.Unsafe::objectFieldOffset has been called by
    net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$CreationAction
    (file:/Users/runner/.m2/repository/net/bytebuddy/byte-buddy/1.17.6/byte-buddy-1.17.6.jar)
    WARNING: Please consider reporting this to the maintainers of class
    net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$CreationAction
    WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future
    release
---
 pom.xml                 | 13 ++++++++++++-
 src/changes/changes.xml |  1 +
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 822ccb681..0c9af608f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -158,6 +158,8 @@ file comparators, endian transformation classes, and much more.
     <commons.jacoco.branchRatio>0.85</commons.jacoco.branchRatio>
     <commons.jacoco.lineRatio>0.90</commons.jacoco.lineRatio>
     <commons.jacoco.complexityRatio>0.85</commons.jacoco.complexityRatio>
+    <!-- Java 21 and up -->
+    <EnableDynamicAgentLoading></EnableDynamicAgentLoading>
   </properties>
   <build>
     <!-- japicmp:cmp needs package to work from a jar -->
@@ -217,7 +219,7 @@ file comparators, endian transformation classes, and much more.
           <reuseForks>false</reuseForks>
           <!-- Limit memory size see IO-161 -->
           <!-- Mockito inline may need -XX:+EnableDynamicAgentLoading -->
-          <argLine>${argLine} -Xmx25M</argLine>
+          <argLine>${argLine} -Xmx25M ${EnableDynamicAgentLoading}</argLine>
           <includes>
             <!-- Only include test classes, not test data -->
             <include>**/*Test*.class</include>
@@ -345,6 +347,15 @@ file comparators, endian transformation classes, and much more.
         <maven.compiler.release>8</maven.compiler.release>
       </properties>
     </profile>
+    <profile>
+      <id>java21-up</id>
+      <activation>
+        <jdk>[21,)</jdk>
+      </activation>
+      <properties>
+        <EnableDynamicAgentLoading>-XX:+EnableDynamicAgentLoading</EnableDynamicAgentLoading>  
+      </properties>
+    </profile>
     <profile>
       <!-- Profile to build and run the benchmarks. Use 'mvn test -Pbenchmark', and add '-Dbenchmark=foo' to run only the foo benchmark -->
       <id>benchmark</id>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ee304861d..74efcfe44 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -47,6 +47,7 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
     <release version="2.20.1" date="YYYY-MM-DD" description="Version 2.20.1: Java 8 or later is required.">
       <!-- FIX -->
+      <action dev="ggregory" type="fix"                due-to="Gary Gregory">When testing on Java 21 and up, enable -XX:+EnableDynamicAgentLoading.</action>
       <!-- ADD -->
       <!-- UPDATE -->
   </release>