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

jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new eac816f6bd ARTEMIS-4751 upgrade to Apache parent 32
eac816f6bd is described below

commit eac816f6bd592ea0f06cbf08b410362ff4e48e3e
Author: Justin Bertram <[email protected]>
AuthorDate: Wed May 1 13:33:05 2024 -0500

    ARTEMIS-4751 upgrade to Apache parent 32
    
    Due to https://github.com/apache/maven-apache-parent/pull/188 the
    property `maven.compiler.release` is now being set which precludes
    exporting and using any internal Java classes. Therefore this commit
    removed references to `--add-exports` from the build, switches to
    reflection, and adds `--add-opens` to the runtime JVM parameters.
---
 .../cli/commands/messages/perf/MicrosClock.java    | 43 ++++++++++++++--------
 .../artemis/cli/commands/etc/artemis.profile       |  2 +-
 .../artemis/cli/commands/etc/artemis.profile.cmd   |  2 +-
 pom.xml                                            | 19 +---------
 tests/smoke-tests/pom.xml                          | 10 -----
 .../artemis/tests/smoke/jmx/JmxConnectionTest.java | 10 ++---
 6 files changed, 36 insertions(+), 50 deletions(-)

diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/MicrosClock.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/MicrosClock.java
index 29875b6e40..7d3d14e7a7 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/MicrosClock.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/MicrosClock.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.cli.commands.messages.perf;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.concurrent.TimeUnit;
 
 public class MicrosClock {
@@ -23,6 +25,8 @@ public class MicrosClock {
    // no need for volatile here
    private static long offset = -1;
    private static long NANOS_PER_SECOND = TimeUnit.SECONDS.toNanos(1);
+   private static Class vm;
+   private static Method getNanoTimeAdjustment;
 
    private static final boolean AVAILABLE = checkAvailable();
 
@@ -43,23 +47,32 @@ public class MicrosClock {
    }
 
    public static long now() {
-      long epochSecond = offset;
-      long nanoAdjustment = 
jdk.internal.misc.VM.getNanoTimeAdjustment(epochSecond);
+      try {
+         long epochSecond = offset;
+         if (vm == null) {
+            vm = Class.forName("jdk.internal.misc.VM");
+         }
+         if (getNanoTimeAdjustment == null) {
+            getNanoTimeAdjustment = vm.getMethod("getNanoTimeAdjustment", 
long.class);
+         }
+         long nanoAdjustment = (long) 
getNanoTimeAdjustment.invoke(getNanoTimeAdjustment, epochSecond);
 
-      if (nanoAdjustment == -1) {
-         epochSecond = System.currentTimeMillis() / 1000 - 1024;
-         nanoAdjustment = 
jdk.internal.misc.VM.getNanoTimeAdjustment(epochSecond);
          if (nanoAdjustment == -1) {
-            throw new InternalError("Offset " + epochSecond + " is not in 
range");
-         } else {
-            offset = epochSecond;
+            epochSecond = System.currentTimeMillis() / 1000 - 1024;
+            nanoAdjustment = (long) 
getNanoTimeAdjustment.invoke(getNanoTimeAdjustment, epochSecond);
+            if (nanoAdjustment == -1) {
+               throw new InternalError("Offset " + epochSecond + " is not in 
range");
+            } else {
+               offset = epochSecond;
+            }
          }
+         final long secs = Math.addExact(epochSecond, 
Math.floorDiv(nanoAdjustment, NANOS_PER_SECOND));
+         final long secsInUs = TimeUnit.SECONDS.toMicros(secs);
+         final long nsOffset = (int) Math.floorMod(nanoAdjustment, 
NANOS_PER_SECOND);
+         final long usOffset = TimeUnit.NANOSECONDS.toMicros(nsOffset);
+         return secsInUs + usOffset;
+      } catch (ClassNotFoundException | NoSuchMethodException | 
InvocationTargetException | IllegalAccessException e) {
+         throw new IllegalStateException(e);
       }
-      final long secs = Math.addExact(epochSecond, 
Math.floorDiv(nanoAdjustment, NANOS_PER_SECOND));
-      final long secsInUs = TimeUnit.SECONDS.toMicros(secs);
-      final long nsOffset = (int) Math.floorMod(nanoAdjustment, 
NANOS_PER_SECOND);
-      final long usOffset = TimeUnit.NANOSECONDS.toMicros(nsOffset);
-      return secsInUs + usOffset;
    }
-
-}
+}
\ No newline at end of file
diff --git 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
index ec3532663e..4e1c28dc37 100644
--- 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
+++ 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
@@ -37,7 +37,7 @@ HAWTIO_ROLE='${role}'
 
 # Java Opts
 if [ -z "$JAVA_ARGS" ]; then
-    JAVA_ARGS="-XX:AutoBoxCacheMax=20000 -XX:+PrintClassHistogram -XX:+UseG1GC 
-XX:+UseStringDeduplication -Xms512M -Xmx${java-memory} 
-Dhawtio.disableProxy=true -Dhawtio.realm=activemq -Dhawtio.offline=true 
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
 
-Dhawtio.http.strictTransportSecurity=max-age=31536000;includeSubDomains;preload
 -Djolokia.policyLocation=${ARTEMIS_INSTANCE_ETC_URI}jolokia-access.xml 
-Dlog4j2.disableJmx=true ${java-opts}"
+    JAVA_ARGS="-XX:AutoBoxCacheMax=20000 -XX:+PrintClassHistogram -XX:+UseG1GC 
-XX:+UseStringDeduplication -Xms512M -Xmx${java-memory} 
-Dhawtio.disableProxy=true -Dhawtio.realm=activemq -Dhawtio.offline=true 
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
 
-Dhawtio.http.strictTransportSecurity=max-age=31536000;includeSubDomains;preload
 -Djolokia.policyLocation=${ARTEMIS_INSTANCE_ETC_URI}jolokia-access.xml 
-Dlog4j2.disableJmx=true --add-opens  [...]
 fi
 
 # Uncomment to enable logging for Safepoint JVM pauses
diff --git 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
index ca23d27f09..547666df37 100644
--- 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
+++ 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
@@ -33,7 +33,7 @@ rem Cluster Properties: Used to pass arguments to ActiveMQ 
Artemis which can be
 rem set ARTEMIS_CLUSTER_PROPS=-Dactivemq.remoting.default.port=61617 
-Dactivemq.remoting.amqp.port=5673 -Dactivemq.remoting.stomp.port=61614 
-Dactivemq.remoting.hornetq.port=5446
 
 rem Java Opts
-IF "%JAVA_ARGS%"=="" (set JAVA_ARGS=${java-opts} -XX:AutoBoxCacheMax=20000 
-XX:+PrintClassHistogram  -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M 
-Xmx${java-memory} 
-Djava.security.auth.login.config=%ARTEMIS_ETC_DIR%\login.config 
-Dhawtio.disableProxy=true -Dhawtio.offline=true -Dhawtio.realm=activemq 
-Dhawtio.role=${role} 
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
 -Dhawtio.http.strictTransportSecurity=max-age=31536000;includeSubDo [...]
+IF "%JAVA_ARGS%"=="" (set JAVA_ARGS=${java-opts} -XX:AutoBoxCacheMax=20000 
-XX:+PrintClassHistogram  -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M 
-Xmx${java-memory} 
-Djava.security.auth.login.config=%ARTEMIS_ETC_DIR%\login.config 
-Dhawtio.disableProxy=true -Dhawtio.offline=true -Dhawtio.realm=activemq 
-Dhawtio.role=${role} 
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
 -Dhawtio.http.strictTransportSecurity=max-age=31536000;includeSubDo [...]
 
 rem Logs Safepoints JVM pauses: Uncomment to enable them
 rem In addition to the traditional GC logs you could enable some JVM flags to 
know any meaningful and "hidden" pause that could
diff --git a/pom.xml b/pom.xml
index 39735d120c..86ef43c496 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
    <parent>
       <groupId>org.apache</groupId>
       <artifactId>apache</artifactId>
-      <version>31</version>
+      <version>32</version>
       <relativePath>org.apache:apache</relativePath>
    </parent>
 
@@ -119,9 +119,6 @@
       <zookeeper.version>3.9.1</zookeeper.version>
       <woodstox.version>4.4.0</woodstox.version>
       <pem-keystore.version>2.3.0</pem-keystore.version>
-      <!-- This overrides the Apache parent POM due to 
https://issues.apache.org/jira/browse/MSHADE-462. Once that issue
-           is resolved and a new Apache parent is released then we can get rid 
of this. -->
-      <version.maven-shade-plugin>3.4.1</version.maven-shade-plugin>
 
       <!-- This overrides the Apache parent POM. Once a new Apache parent is 
released with the latest version then we
            can get rid of this. -->
@@ -340,8 +337,6 @@
                   <configuration>
                      <compilerArgs>
                         <arg>-Xdiags:verbose</arg>
-                        
<arg>--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED</arg>
-                        
<arg>--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED</arg>
                         <arg>-XDcompilePolicy=simple</arg>
                         <arg>-Xplugin:ErrorProne -Xep:ThreadLocalUsage:ERROR 
-Xep:MissingOverride:ERROR -Xep:NonAtomicVolatileUpdate:ERROR 
-Xep:SynchronizeOnNonFinalField:ERROR -Xep:StaticQualifiedUsingExpression:ERROR 
-Xep:WaitNotInLoop:ERROR -Xep:BanJNDI:OFF 
-XepExcludedPaths:.*/generated-sources/.*</arg>
                      </compilerArgs>
@@ -376,8 +371,6 @@
                      <fork>true</fork>
                      <compilerArgs>
                         <arg>-Xdiags:verbose</arg>
-                        
<arg>--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED</arg>
-                        
<arg>--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED</arg>
                         <arg>-XDcompilePolicy=simple</arg>
                         <arg>-Xplugin:ErrorProne -Xep:ThreadLocalUsage:ERROR 
-Xep:MissingOverride:WARN -Xep:NonAtomicVolatileUpdate:ERROR 
-Xep:SynchronizeOnNonFinalField:ERROR -Xep:StaticQualifiedUsingExpression:ERROR 
-Xep:WaitNotInLoop:ERROR -Xep:BanJNDI:OFF 
-XepExcludedPaths:.*/generated-sources/.*</arg>
                         
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
@@ -829,16 +822,6 @@
                   </execution>
                </executions>
             </plugin>
-            <plugin>
-               <groupId>org.apache.maven.plugins</groupId>
-               <artifactId>maven-compiler-plugin</artifactId>
-               <configuration>
-                  <showWarnings>true</showWarnings>
-                  <compilerArgs>
-                     
<arg>--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED</arg>
-                  </compilerArgs>
-               </configuration>
-            </plugin>
             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-rar-plugin</artifactId>
diff --git a/tests/smoke-tests/pom.xml b/tests/smoke-tests/pom.xml
index 786d4d7486..e442fd8516 100644
--- a/tests/smoke-tests/pom.xml
+++ b/tests/smoke-tests/pom.xml
@@ -291,16 +291,6 @@
                </execution>
             </executions>
          </plugin>
-         <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-compiler-plugin</artifactId>
-            <configuration>
-               <compilerArgs>
-                  <arg>--add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED</arg>
-                  
<arg>--add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED</arg>
-               </compilerArgs>
-            </configuration>
-         </plugin>
          <plugin>
             <groupId>org.apache.activemq</groupId>
             <artifactId>artemis-maven-plugin</artifactId>
diff --git 
a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmx/JmxConnectionTest.java
 
b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmx/JmxConnectionTest.java
index d7721906f9..1d8fbd5fca 100644
--- 
a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmx/JmxConnectionTest.java
+++ 
b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmx/JmxConnectionTest.java
@@ -24,6 +24,7 @@ import javax.management.remote.rmi.RMIConnection;
 import javax.management.remote.rmi.RMIConnector;
 import java.io.File;
 import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.rmi.server.RemoteObject;
 import java.rmi.server.RemoteRef;
 
@@ -36,8 +37,6 @@ import org.junit.Assume;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import sun.rmi.server.UnicastRef;
-import sun.rmi.transport.LiveRef;
 
 /**
  * This test checks JMX connection to Artemis with both necessary ports set up 
so that it's easier to tunnel through
@@ -142,12 +141,13 @@ public class JmxConnectionTest extends SmokeTestBase {
                remoteRefField = (RemoteRef) 
UnsafeAccess.UNSAFE.getObject(remoteRef, 
UnsafeAccess.UNSAFE.objectFieldOffset(refField));
             }
             Assert.assertNotNull(remoteRefField);
-            Assert.assertTrue(remoteRefField instanceof UnicastRef);
+            Assert.assertEquals("sun.rmi.server.UnicastRef2", 
remoteRefField.getClass().getTypeName());
 
             // 5. UnicastRef::getLiveRef returns LiveRef
-            LiveRef liveRef = ((UnicastRef) remoteRefField).getLiveRef();
+            Method getLiveRef = 
remoteRefField.getClass().getMethod("getLiveRef");
+            Object liveRef = getLiveRef.invoke(remoteRefField);
 
-            Assert.assertEquals(RMI_REGISTRY_PORT, liveRef.getPort());
+            Assert.assertEquals(RMI_REGISTRY_PORT, 
liveRef.getClass().getMethod("getPort").invoke(liveRef));
 
          } finally {
             jmxConnector.close();

Reply via email to