This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new 2162c11 More prep for https://bz.apache.org/bugzilla/show_bug.cgi?id=63781 2162c11 is described below commit 2162c11d51ce440ce76008ddbff1e54be5830c1f 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 acccess 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 e1b75a7..2718713 100644 --- a/java/javax/el/Jre9Compat.java +++ b/java/javax/el/Jre9Compat.java @@ -19,6 +19,13 @@ package javax.el; 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 org.apache.el.util + * When making changes keep the two in sync. + */ class Jre9Compat extends JreCompat { private static final Method canAccessMethod; @@ -41,7 +48,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 (ReflectiveOperationException | 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 82% copy from java/javax/el/Jre9Compat.java copy to java/org/apache/el/util/Jre9Compat.java index e1b75a7..b4d10d7 100644 --- a/java/javax/el/Jre9Compat.java +++ b/java/org/apache/el/util/Jre9Compat.java @@ -14,11 +14,18 @@ * 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.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; @@ -41,7 +48,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 (ReflectiveOperationException | 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 b20c2b5..98adc3d 100644 --- a/java/org/apache/tomcat/util/compat/Jre9Compat.java +++ b/java/org/apache/tomcat/util/compat/Jre9Compat.java @@ -246,7 +246,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 (ReflectiveOperationException | IllegalArgumentException e) { diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java b/java/org/apache/tomcat/util/compat/JreCompat.java index 003a725..9576fbd 100644 --- a/java/org/apache/tomcat/util/compat/JreCompat.java +++ b/java/org/apache/tomcat/util/compat/JreCompat.java @@ -19,7 +19,6 @@ package org.apache.tomcat.util.compat; import java.io.File; import java.io.IOException; import java.lang.reflect.AccessibleObject; -import java.lang.reflect.Modifier; import java.net.URL; import java.net.URLConnection; import java.util.Deque; @@ -199,19 +198,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