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 61ba735 Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63781 reported issue 61ba735 is described below commit 61ba735c385e0afd1625e1a8373f0599b47b57af 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/Util.java | 13 +++++++------ java/org/apache/el/util/ReflectionUtil.java | 13 +++++++------ 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/java/javax/el/BeanELResolver.java b/java/javax/el/BeanELResolver.java index cd1a111..15d2c88 100644 --- a/java/javax/el/BeanELResolver.java +++ b/java/javax/el/BeanELResolver.java @@ -92,7 +92,7 @@ public class BeanELResolver extends ELResolver { } context.setPropertyResolved(true); - 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) { @@ -122,7 +122,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) { @@ -154,7 +154,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(), @@ -187,7 +187,7 @@ public class BeanELResolver extends ELResolver { } context.setPropertyResolved(true); - return this.readOnly || this.property(context, base, property).isReadOnly(); + return this.readOnly || this.property(context, base, property).isReadOnly(base); } @Override @@ -300,14 +300,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[] { @@ -317,9 +317,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/Util.java b/java/javax/el/Util.java index 6053fea..1c7073a 100644 --- a/java/javax/el/Util.java +++ b/java/javax/el/Util.java @@ -199,7 +199,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) { @@ -218,7 +218,7 @@ class Util { Wrapper<Method> result = findWrapper(clazz, wrappers, methodName, paramTypes, paramValues); - return getMethod(clazz, result.unWrap()); + return getMethod(clazz, base, result.unWrap()); } /* @@ -541,8 +541,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(); @@ -550,7 +551,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; } @@ -562,7 +563,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 e2560c1..5b88de3 100644 --- a/java/org/apache/el/util/ReflectionUtil.java +++ b/java/org/apache/el/util/ReflectionUtil.java @@ -217,7 +217,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( @@ -264,7 +264,7 @@ public class ReflectionUtil { paramString(paramTypes))); } - return getMethod(base.getClass(), match); + return getMethod(base.getClass(), base, match); } /* @@ -393,8 +393,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(); @@ -402,7 +403,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; } @@ -414,7 +415,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