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 45a65b9 Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63781 reported issue 45a65b9 is described below commit 45a65b9467371ffd9327d5d9485dcc55781f2296 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Oct 3 20:57:16 2019 +0100 Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63781 reported issue This fixes the issue reported in BZ 63781 but there are additional, similar issue to be resolved. --- java/javax/el/BeanELResolver.java | 20 ++++++++++---------- java/javax/el/StaticFieldELResolver.java | 2 +- java/javax/el/Util.java | 13 +++++++------ java/org/apache/el/util/ReflectionUtil.java | 13 +++++++------ 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/java/javax/el/BeanELResolver.java b/java/javax/el/BeanELResolver.java index c69798f..5e93032 100644 --- a/java/javax/el/BeanELResolver.java +++ b/java/javax/el/BeanELResolver.java @@ -89,7 +89,7 @@ public class BeanELResolver extends ELResolver { } context.setPropertyResolved(base, property); - Method m = this.property(context, base, property).read(context); + Method m = this.property(context, base, property).read(context, base); try { return m.invoke(base, (Object[]) null); } catch (InvocationTargetException e) { @@ -117,7 +117,7 @@ public class BeanELResolver extends ELResolver { "resolverNotWriteable", base.getClass().getName())); } - Method m = this.property(context, base, property).write(context); + Method m = this.property(context, base, property).write(context, base); try { m.invoke(base, value); } catch (InvocationTargetException e) { @@ -147,7 +147,7 @@ public class BeanELResolver extends ELResolver { // Find the matching method Method matchingMethod = - Util.findMethod(base.getClass(), methodName, paramTypes, params); + Util.findMethod(base.getClass(), base, methodName, paramTypes, params); Object[] parameters = Util.buildParameters( matchingMethod.getParameterTypes(), matchingMethod.isVarArgs(), @@ -176,7 +176,7 @@ public class BeanELResolver extends ELResolver { } context.setPropertyResolved(base, property); - return this.readOnly || this.property(context, base, property).isReadOnly(); + return this.readOnly || this.property(context, base, property).isReadOnly(base); } @Override @@ -289,14 +289,14 @@ public class BeanELResolver extends ELResolver { return this.type; } - public boolean isReadOnly() { + public boolean isReadOnly(Object base) { return this.write == null && - (null == (this.write = Util.getMethod(this.owner, descriptor.getWriteMethod()))); + (null == (this.write = Util.getMethod(this.owner, base, descriptor.getWriteMethod()))); } - private Method write(ELContext ctx) { + private Method write(ELContext ctx, Object base) { if (this.write == null) { - this.write = Util.getMethod(this.owner, descriptor.getWriteMethod()); + this.write = Util.getMethod(this.owner, base, descriptor.getWriteMethod()); if (this.write == null) { throw new PropertyNotWritableException(Util.message(ctx, "propertyNotWritable", new Object[] { @@ -306,9 +306,9 @@ public class BeanELResolver extends ELResolver { return this.write; } - private Method read(ELContext ctx) { + private Method read(ELContext ctx, Object base) { if (this.read == null) { - this.read = Util.getMethod(this.owner, descriptor.getReadMethod()); + this.read = Util.getMethod(this.owner, base, descriptor.getReadMethod()); if (this.read == null) { throw new PropertyNotFoundException(Util.message(ctx, "propertyNotReadable", new Object[] { diff --git a/java/javax/el/StaticFieldELResolver.java b/java/javax/el/StaticFieldELResolver.java index de34cd0..e3cc72a 100644 --- a/java/javax/el/StaticFieldELResolver.java +++ b/java/javax/el/StaticFieldELResolver.java @@ -112,7 +112,7 @@ public class StaticFieldELResolver extends ELResolver { } else { Method match = - Util.findMethod(clazz, methodName, paramTypes, params); + Util.findMethod(clazz, base, methodName, paramTypes, params); int modifiers = match.getModifiers(); if (!Modifier.isStatic(modifiers)) { diff --git a/java/javax/el/Util.java b/java/javax/el/Util.java index 0bbf0c2..db921a8 100644 --- a/java/javax/el/Util.java +++ b/java/javax/el/Util.java @@ -197,7 +197,7 @@ class Util { * This method duplicates code in org.apache.el.util.ReflectionUtil. When * making changes keep the code in sync. */ - static Method findMethod(Class<?> clazz, String methodName, + static Method findMethod(Class<?> clazz, Object base, String methodName, Class<?>[] paramTypes, Object[] paramValues) { if (clazz == null || methodName == null) { @@ -216,7 +216,7 @@ class Util { Wrapper<Method> result = findWrapper(clazz, wrappers, methodName, paramTypes, paramValues); - return getMethod(clazz, result.unWrap()); + return getMethod(clazz, base, result.unWrap()); } /* @@ -539,8 +539,9 @@ class Util { * This method duplicates code in org.apache.el.util.ReflectionUtil. When * making changes keep the code in sync. */ - static Method getMethod(Class<?> type, Method m) { - if (m == null || Modifier.isPublic(type.getModifiers())) { + static Method getMethod(Class<?> type, Object base, Method m) { + JreCompat jreCompat = JreCompat.getInstance(); + if (m == null || jreCompat.canAcccess(base, m)) { return m; } Class<?>[] inf = type.getInterfaces(); @@ -548,7 +549,7 @@ class Util { for (int i = 0; i < inf.length; i++) { try { mp = inf[i].getMethod(m.getName(), m.getParameterTypes()); - mp = getMethod(mp.getDeclaringClass(), mp); + mp = getMethod(mp.getDeclaringClass(), base, mp); if (mp != null) { return mp; } @@ -560,7 +561,7 @@ class Util { if (sup != null) { try { mp = sup.getMethod(m.getName(), m.getParameterTypes()); - mp = getMethod(mp.getDeclaringClass(), mp); + mp = getMethod(mp.getDeclaringClass(), base, mp); if (mp != null) { return mp; } diff --git a/java/org/apache/el/util/ReflectionUtil.java b/java/org/apache/el/util/ReflectionUtil.java index a760fd9..4856cbb 100644 --- a/java/org/apache/el/util/ReflectionUtil.java +++ b/java/org/apache/el/util/ReflectionUtil.java @@ -246,7 +246,7 @@ public class ReflectionUtil { // If a method is found where every parameter matches exactly, // return it if (exactMatch == paramCount) { - return getMethod(base.getClass(), m); + return getMethod(base.getClass(), base, m); } candidates.put(m, new MatchResult( @@ -293,7 +293,7 @@ public class ReflectionUtil { paramString(paramTypes))); } - return getMethod(base.getClass(), match); + return getMethod(base.getClass(), base, match); } /* @@ -422,8 +422,9 @@ public class ReflectionUtil { * This class duplicates code in javax.el.Util. When making changes keep * the code in sync. */ - private static Method getMethod(Class<?> type, Method m) { - if (m == null || Modifier.isPublic(type.getModifiers())) { + private static Method getMethod(Class<?> type, Object base, Method m) { + JreCompat jreCompat = JreCompat.getInstance(); + if (m == null || (Modifier.isPublic(type.getModifiers()) && jreCompat.canAcccess(base, m))) { return m; } Class<?>[] inf = type.getInterfaces(); @@ -431,7 +432,7 @@ public class ReflectionUtil { for (int i = 0; i < inf.length; i++) { try { mp = inf[i].getMethod(m.getName(), m.getParameterTypes()); - mp = getMethod(mp.getDeclaringClass(), mp); + mp = getMethod(mp.getDeclaringClass(), base, mp); if (mp != null) { return mp; } @@ -443,7 +444,7 @@ public class ReflectionUtil { if (sup != null) { try { mp = sup.getMethod(m.getName(), m.getParameterTypes()); - mp = getMethod(mp.getDeclaringClass(), mp); + mp = getMethod(mp.getDeclaringClass(), base, mp); if (mp != null) { return mp; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org