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

markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 9f9e821c420f9fd915703aedcf9691c9771dc628
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Nov 10 12:02:08 2026 +0000

    Add Java 17 detection (currently only for tests)
---
 .../org/apache/tomcat/util/compat/Jre17Compat.java | 47 ++++++++++++++++++++++
 .../org/apache/tomcat/util/compat/Jre19Compat.java |  2 +-
 java/org/apache/tomcat/util/compat/JreCompat.java  | 26 ++++++++++++
 3 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre17Compat.java 
b/java/org/apache/tomcat/util/compat/Jre17Compat.java
new file mode 100644
index 0000000000..0bb0f727d6
--- /dev/null
+++ b/java/org/apache/tomcat/util/compat/Jre17Compat.java
@@ -0,0 +1,47 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.util.compat;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
+public class Jre17Compat extends Jre16Compat {
+
+    private static final Log log = LogFactory.getLog(Jre17Compat.class);
+    private static final StringManager sm = 
StringManager.getManager(Jre17Compat.class);
+
+    private static final Class<?> randomGeneratorFactoryClass;
+
+    static {
+        Class<?> c1 = null;
+
+        try {
+            c1 = Class.forName("java.util.random.RandomGeneratorFactory");
+        } catch (ReflectiveOperationException e) {
+            // Must be pre-Java 17
+            log.debug(sm.getString("jre17Compat.javaPre17"), e);
+        }
+
+        randomGeneratorFactoryClass = c1;
+    }
+
+
+    static boolean isSupported() {
+        return randomGeneratorFactoryClass != null;
+    }
+}
diff --git a/java/org/apache/tomcat/util/compat/Jre19Compat.java 
b/java/org/apache/tomcat/util/compat/Jre19Compat.java
index 587ad39dcb..0815252a90 100644
--- a/java/org/apache/tomcat/util/compat/Jre19Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre19Compat.java
@@ -22,7 +22,7 @@ import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.res.StringManager;
 
-public class Jre19Compat extends Jre16Compat {
+public class Jre19Compat extends Jre17Compat {
 
     private static final Log log = LogFactory.getLog(Jre19Compat.class);
     private static final StringManager sm = 
StringManager.getManager(Jre19Compat.class);
diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java 
b/java/org/apache/tomcat/util/compat/JreCompat.java
index d20a40aed4..ff94a26c0b 100644
--- a/java/org/apache/tomcat/util/compat/JreCompat.java
+++ b/java/org/apache/tomcat/util/compat/JreCompat.java
@@ -67,6 +67,7 @@ public class JreCompat {
     private static final boolean jre11Available;
     private static final boolean jre12Available;
     private static final boolean jre16Available;
+    private static final boolean jre17Available;
     private static final boolean jre19Available;
     private static final boolean jre20Available;
     private static final boolean jre21Available;
@@ -100,6 +101,7 @@ public class JreCompat {
             jre21Available = true;
             jre20Available = true;
             jre19Available = true;
+            jre17Available = true;
             jre16Available = true;
             jre12Available = true;
             jre11Available = true;
@@ -110,6 +112,7 @@ public class JreCompat {
             jre21Available = true;
             jre20Available = true;
             jre19Available = true;
+            jre17Available = true;
             jre16Available = true;
             jre12Available = true;
             jre11Available = true;
@@ -120,6 +123,7 @@ public class JreCompat {
             jre21Available = false;
             jre20Available = true;
             jre19Available = true;
+            jre17Available = true;
             jre16Available = true;
             jre12Available = true;
             jre11Available = true;
@@ -130,6 +134,18 @@ public class JreCompat {
             jre21Available = false;
             jre20Available = false;
             jre19Available = true;
+            jre17Available = true;
+            jre16Available = true;
+            jre12Available = true;
+            jre11Available = true;
+            jre9Available = true;
+        } else if (Jre17Compat.isSupported()) {
+            instance = new Jre17Compat();
+            jre22Available = false;
+            jre21Available = false;
+            jre20Available = false;
+            jre19Available = false;
+            jre17Available = true;
             jre16Available = true;
             jre12Available = true;
             jre11Available = true;
@@ -140,6 +156,7 @@ public class JreCompat {
             jre21Available = false;
             jre20Available = false;
             jre19Available = false;
+            jre17Available = false;
             jre16Available = true;
             jre12Available = true;
             jre11Available = true;
@@ -150,6 +167,7 @@ public class JreCompat {
             jre21Available = false;
             jre20Available = false;
             jre19Available = false;
+            jre17Available = false;
             jre16Available = false;
             jre12Available = true;
             jre11Available = true;
@@ -160,6 +178,7 @@ public class JreCompat {
             jre21Available = false;
             jre20Available = false;
             jre19Available = false;
+            jre17Available = false;
             jre16Available = false;
             jre12Available = false;
             jre11Available = true;
@@ -170,6 +189,7 @@ public class JreCompat {
             jre21Available = false;
             jre20Available = false;
             jre19Available = false;
+            jre17Available = false;
             jre16Available = false;
             jre12Available = false;
             jre11Available = false;
@@ -180,6 +200,7 @@ public class JreCompat {
             jre21Available = false;
             jre20Available = false;
             jre19Available = false;
+            jre17Available = false;
             jre16Available = false;
             jre12Available = false;
             jre11Available = false;
@@ -244,6 +265,11 @@ public class JreCompat {
     }
 
 
+    public static boolean isJre17Available() {
+        return jre17Available;
+    }
+
+
     public static boolean isJre19Available() {
         return jre19Available;
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to