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


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 2f438d2b7b Further preparatory work
2f438d2b7b is described below

commit 2f438d2b7b5c77fba46bbafa1d7c5fa7160d0736
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Oct 28 12:36:11 2026 +0000

    Further preparatory work
---
 java/javax/el/JreCompat.java             |  2 +-
 java/org/apache/el/util/Jre11Compat.java | 52 ++++++++++++++++++++++++++++++++
 java/org/apache/el/util/JreCompat.java   | 19 ++++++++++--
 3 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/java/javax/el/JreCompat.java b/java/javax/el/JreCompat.java
index eabed0b78a..5b307dbe1f 100644
--- a/java/javax/el/JreCompat.java
+++ b/java/javax/el/JreCompat.java
@@ -23,7 +23,7 @@ import java.lang.reflect.AccessibleObject;
  * only the methods required by the EL implementation.
  *
  * This class is duplicated in org.apache.el.util
- * When making changes keep the two in sync if required.
+ * When making changes keep the two in sync.
  */
 class JreCompat {
 
diff --git a/java/org/apache/el/util/Jre11Compat.java 
b/java/org/apache/el/util/Jre11Compat.java
new file mode 100644
index 0000000000..ee29b5aa41
--- /dev/null
+++ b/java/org/apache/el/util/Jre11Compat.java
@@ -0,0 +1,52 @@
+/*
+ *  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.el.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+class Jre11Compat extends Jre9Compat {
+
+    private static final Method stripMethod;
+
+    static {
+        Method m1 = null;
+
+        try {
+            m1 = String.class.getMethod("strip");
+        } catch (NoSuchMethodException e) {
+            // Must be pre-Java 11
+        }
+
+        stripMethod = m1;
+    }
+
+
+    public static boolean isSupported() {
+        return stripMethod != null;
+    }
+
+
+    @Override
+    public String strip(String input) {
+        try {
+            return (String) stripMethod.invoke(input);
+        } catch (IllegalAccessException | InvocationTargetException e) {
+            throw new UnsupportedOperationException(e);
+        }
+    }
+}
diff --git a/java/org/apache/el/util/JreCompat.java 
b/java/org/apache/el/util/JreCompat.java
index 42531d5edb..1c78a0ca74 100644
--- a/java/org/apache/el/util/JreCompat.java
+++ b/java/org/apache/el/util/JreCompat.java
@@ -23,14 +23,16 @@ import java.lang.reflect.AccessibleObject;
  * only the methods required by the EL implementation.
  *
  * This class is duplicated in javax.el
- * When making changes keep the two in sync if required.
+ * When making changes keep the two in sync.
  */
 public class JreCompat {
 
     private static final JreCompat instance;
 
     static {
-        if (Jre9Compat.isSupported()) {
+        if (Jre11Compat.isSupported()) {
+            instance = new Jre11Compat();
+        } else if (Jre9Compat.isSupported()) {
             instance = new Jre9Compat();
         } else {
             instance = new JreCompat();
@@ -55,4 +57,17 @@ public class JreCompat {
         // Java 8 doesn't support modules so default to true
         return true;
     }
+
+
+    public String strip(String input) {
+        int start = 0;
+        int end = input.length();
+        while (start < end && Character.isWhitespace(input.charAt(start))) {
+            start++;
+        }
+        while (end > start && Character.isWhitespace(input.charAt(end - 1))) {
+            end--;
+        }
+        return input.substring(start, end);
+    }
 }


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

Reply via email to