This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 7.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push: new b165765 More prep for https://bz.apache.org/bugzilla/show_bug.cgi?id=63781 b165765 is described below commit b16576575b6f61ab57f436d72175e0baaff0fff6 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Oct 4 10:29:03 2019 +0100 More prep for https://bz.apache.org/bugzilla/show_bug.cgi?id=63781 The EL impl as well as the API needs access to JreCompat.canAccess() Keep the isPublic check separate from the access check --- java/javax/el/Jre9Compat.java | 9 ++++++++- java/javax/el/JreCompat.java | 18 +++++++++--------- .../el => org/apache/el/util}/Jre9Compat.java | 11 +++++++++-- .../el => org/apache/el/util}/JreCompat.java | 22 +++++++++++----------- java/org/apache/tomcat/util/compat/Jre9Compat.java | 2 +- java/org/apache/tomcat/util/compat/JreCompat.java | 15 ++++++--------- 6 files changed, 44 insertions(+), 33 deletions(-) diff --git a/java/javax/el/Jre9Compat.java b/java/javax/el/Jre9Compat.java index 55110cd..9342b05 100644 --- a/java/javax/el/Jre9Compat.java +++ b/java/javax/el/Jre9Compat.java @@ -20,6 +20,13 @@ import java.lang.reflect.AccessibleObject; import java.lang.reflect.InvocationTargetException; 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 org.apache.el.util + * When making changes keep the two in sync. + */ class Jre9Compat extends JreCompat { private static final Method canAccessMethod; @@ -42,7 +49,7 @@ class Jre9Compat extends JreCompat { @Override - public boolean canAcccess(Class<?> type, Object base, AccessibleObject accessibleObject) { + public boolean canAcccess(Object base, AccessibleObject accessibleObject) { try { return ((Boolean) canAccessMethod.invoke(accessibleObject, base)).booleanValue(); } catch (IllegalArgumentException e) { diff --git a/java/javax/el/JreCompat.java b/java/javax/el/JreCompat.java index b01d94e..6d68ed0 100644 --- a/java/javax/el/JreCompat.java +++ b/java/javax/el/JreCompat.java @@ -17,11 +17,13 @@ package javax.el; import java.lang.reflect.AccessibleObject; -import java.lang.reflect.Modifier; /* * This is cut down version of org.apache.tomcat.util.JreCompat that provides * 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. */ class JreCompat { @@ -42,19 +44,17 @@ class JreCompat { /** - * Is the accessibleObject of the given type accessible on the provided - * instance of that type. + * Is the accessibleObject accessible (as a result of appropriate module + * exports) on the provided instance? * - * @param type The type the accessible object belongs to - * @param base The specific instance of the type to be tested. Unused prior - * to Java 9. + * @param base The specific instance to be tested. * @param accessibleObject The method/field/constructor to be tested. - * Unused prior to Java 9. * * @return {code true} if the AccessibleObject can be accessed otherwise * {code false} */ - public boolean canAcccess(Class<?> type, Object base, AccessibleObject accessibleObject) { - return Modifier.isPublic(type.getModifiers()); + public boolean canAcccess(Object base, AccessibleObject accessibleObject) { + // Java 8 doesn't support modules so default to true + return true; } } diff --git a/java/javax/el/Jre9Compat.java b/java/org/apache/el/util/Jre9Compat.java similarity index 83% copy from java/javax/el/Jre9Compat.java copy to java/org/apache/el/util/Jre9Compat.java index 55110cd..e02a82b 100644 --- a/java/javax/el/Jre9Compat.java +++ b/java/org/apache/el/util/Jre9Compat.java @@ -14,12 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package javax.el; +package org.apache.el.util; import java.lang.reflect.AccessibleObject; import java.lang.reflect.InvocationTargetException; 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 javax.el + * When making changes keep the two in sync. + */ class Jre9Compat extends JreCompat { private static final Method canAccessMethod; @@ -42,7 +49,7 @@ class Jre9Compat extends JreCompat { @Override - public boolean canAcccess(Class<?> type, Object base, AccessibleObject accessibleObject) { + public boolean canAcccess(Object base, AccessibleObject accessibleObject) { try { return ((Boolean) canAccessMethod.invoke(accessibleObject, base)).booleanValue(); } catch (IllegalArgumentException e) { diff --git a/java/javax/el/JreCompat.java b/java/org/apache/el/util/JreCompat.java similarity index 69% copy from java/javax/el/JreCompat.java copy to java/org/apache/el/util/JreCompat.java index b01d94e..7ef8b87 100644 --- a/java/javax/el/JreCompat.java +++ b/java/org/apache/el/util/JreCompat.java @@ -14,14 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package javax.el; +package org.apache.el.util; import java.lang.reflect.AccessibleObject; -import java.lang.reflect.Modifier; /* - * This is cut down version of org.apache.tomcat.util.JreCompat that provides + * 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 javax.el + * When making changes keep the two in sync. */ class JreCompat { @@ -42,19 +44,17 @@ class JreCompat { /** - * Is the accessibleObject of the given type accessible on the provided - * instance of that type. + * Is the accessibleObject accessible (as a result of appropriate module + * exports) on the provided instance? * - * @param type The type the accessible object belongs to - * @param base The specific instance of the type to be tested. Unused prior - * to Java 9. + * @param base The specific instance to be tested. * @param accessibleObject The method/field/constructor to be tested. - * Unused prior to Java 9. * * @return {code true} if the AccessibleObject can be accessed otherwise * {code false} */ - public boolean canAcccess(Class<?> type, Object base, AccessibleObject accessibleObject) { - return Modifier.isPublic(type.getModifiers()); + public boolean canAcccess(Object base, AccessibleObject accessibleObject) { + // Java 8 doesn't support modules so default to true + return true; } } diff --git a/java/org/apache/tomcat/util/compat/Jre9Compat.java b/java/org/apache/tomcat/util/compat/Jre9Compat.java index debf9c2..e8c5c3f 100644 --- a/java/org/apache/tomcat/util/compat/Jre9Compat.java +++ b/java/org/apache/tomcat/util/compat/Jre9Compat.java @@ -245,7 +245,7 @@ class Jre9Compat extends Jre8Compat { @Override - public boolean canAcccess(Class<?> type, Object base, AccessibleObject accessibleObject) { + public boolean canAcccess(Object base, AccessibleObject accessibleObject) { try { return ((Boolean) canAccessMethod.invoke(accessibleObject, base)).booleanValue(); } catch (IllegalArgumentException e) { diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java b/java/org/apache/tomcat/util/compat/JreCompat.java index 7e0c92a..9883fc5 100644 --- a/java/org/apache/tomcat/util/compat/JreCompat.java +++ b/java/org/apache/tomcat/util/compat/JreCompat.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.net.URL; import java.net.URLConnection; import java.sql.CallableStatement; @@ -350,19 +349,17 @@ public class JreCompat { /** - * Is the accessibleObject of the given type accessible on the provided - * instance of that type. + * Is the accessibleObject accessible (as a result of appropriate module + * exports) on the provided instance? * - * @param type The type the accessible object belongs to - * @param base The specific instance of the type to be tested. Unused prior - * to Java 9. + * @param base The specific instance to be tested. * @param accessibleObject The method/field/constructor to be tested. - * Unused prior to Java 9. * * @return {code true} if the AccessibleObject can be accessed otherwise * {code false} */ - public boolean canAcccess(Class<?> type, Object base, AccessibleObject accessibleObject) { - return Modifier.isPublic(type.getModifiers()); + public boolean canAcccess(Object base, AccessibleObject accessibleObject) { + // Java 8 doesn't support modules so default to true + return true; } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org