You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/07/28 11:12:36 UTC

[tomcat] branch main updated: Remove JreCompat from EL implementation as it is no longer required

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 0bfaf55  Remove JreCompat from EL implementation as it is no longer required
0bfaf55 is described below

commit 0bfaf55bbe41242ee152c44ec992f71d58925027
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jul 28 12:12:26 2021 +0100

    Remove JreCompat from EL implementation as it is no longer required
---
 java/org/apache/el/util/Jre9Compat.java     | 58 ----------------------------
 java/org/apache/el/util/JreCompat.java      | 60 -----------------------------
 java/org/apache/el/util/ReflectionUtil.java |  3 +-
 3 files changed, 1 insertion(+), 120 deletions(-)

diff --git a/java/org/apache/el/util/Jre9Compat.java b/java/org/apache/el/util/Jre9Compat.java
deleted file mode 100644
index 3debecc..0000000
--- a/java/org/apache/el/util/Jre9Compat.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *  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.AccessibleObject;
-import java.lang.reflect.Method;
-
-/*
- * This is a cut down version of org.apache.tomcat.util.Jre9Compat that provides
- * only the methods required by the EL implementation.
- *
- * This class is duplicated in jakarta.el
- * When making changes keep the two in sync.
- */
-class Jre9Compat extends JreCompat {
-
-    private static final Method canAccessMethod;
-
-
-    static {
-        Method m1 = null;
-        try {
-            m1 = AccessibleObject.class.getMethod("canAccess", new Class<?>[] { Object.class });
-        } catch (NoSuchMethodException e) {
-            // Expected for Java 8
-        }
-        canAccessMethod = m1;
-    }
-
-
-    public static boolean isSupported() {
-        return canAccessMethod != null;
-    }
-
-
-    @Override
-    public boolean canAccess(Object base, AccessibleObject accessibleObject) {
-        try {
-            return ((Boolean) canAccessMethod.invoke(accessibleObject, base)).booleanValue();
-        } catch (ReflectiveOperationException | IllegalArgumentException e) {
-            return false;
-        }
-    }
-}
diff --git a/java/org/apache/el/util/JreCompat.java b/java/org/apache/el/util/JreCompat.java
deleted file mode 100644
index 5c1fc6a..0000000
--- a/java/org/apache/el/util/JreCompat.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  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.AccessibleObject;
-
-/*
- * This is a cut down version of org.apache.tomcat.util.JreCompat that provides
- * only the methods required by the EL implementation.
- *
- * This class is duplicated in jakarta.el
- * When making changes keep the two in sync.
- */
-public class JreCompat {
-
-    private static final JreCompat instance;
-
-    static {
-        if (Jre9Compat.isSupported()) {
-            instance = new Jre9Compat();
-        } else {
-            instance = new JreCompat();
-        }
-    }
-
-
-    public static JreCompat getInstance() {
-        return instance;
-    }
-
-
-    /**
-     * Is the accessibleObject accessible (as a result of appropriate module
-     * exports) on the provided instance?
-     *
-     * @param base  The specific instance to be tested.
-     * @param accessibleObject  The method/field/constructor to be tested.
-     *
-     * @return {code true} if the AccessibleObject can be accessed otherwise
-     *         {code false}
-     */
-    public boolean canAccess(Object base, AccessibleObject accessibleObject) {
-        // Java 8 doesn't support modules so default to true
-        return true;
-    }
-}
diff --git a/java/org/apache/el/util/ReflectionUtil.java b/java/org/apache/el/util/ReflectionUtil.java
index da32349..70e7e41 100644
--- a/java/org/apache/el/util/ReflectionUtil.java
+++ b/java/org/apache/el/util/ReflectionUtil.java
@@ -429,12 +429,11 @@ public class ReflectionUtil {
      * the code in sync.
      */
     private static Method getMethod(Class<?> type, Object base, Method m) {
-        JreCompat jreCompat = JreCompat.getInstance();
         // If base is null, method MUST be static
         // If base is non-null, method may be static or non-static
         if (m == null ||
                 (Modifier.isPublic(type.getModifiers()) &&
-                        (jreCompat.canAccess(base, m) || base != null && jreCompat.canAccess(null, m)))) {
+                        (m.canAccess(base) || base != null && m.canAccess(null)))) {
             return m;
         }
         Class<?>[] interfaces = type.getInterfaces();

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org