Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51544
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 25 Jul 2011 16:23:39 +0000 (16:23 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 25 Jul 2011 16:23:39 +0000 (16:23 +0000)
Correctly resolve bean methods in EL so accessible methods that are overridden by inaccessible methods do not cause an IllegalAccessException.
Modify test case to catch this problem on Oracle and OpenJDK JREs.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1150767 13f79535-47bb-0310-9956-ffa450edef68

java/javax/el/BeanELResolver.java
test/org/apache/el/TestValueExpressionImpl.java
webapps/docs/changelog.xml

index 7ba9ce0..ddaa8e2 100644 (file)
@@ -402,7 +402,8 @@ public class BeanELResolver extends ELResolver {
         Class<?> clazz = base.getClass();
         if (paramTypes != null) {
             try {
-                matchingMethod = clazz.getMethod(methodName, paramTypes);
+                matchingMethod =
+                    getMethod(clazz, clazz.getMethod(methodName, paramTypes));
             } catch (NoSuchMethodException e) {
                 throw new MethodNotFoundException(e);
             }
@@ -416,11 +417,11 @@ public class BeanELResolver extends ELResolver {
                 if (methodName.equals(m.getName()) && 
                         m.getParameterTypes().length == paramCount) {
                     // Same number of parameters - use the first match
-                    matchingMethod = m;
+                    matchingMethod = getMethod(clazz, m);
                     break;
                 }
                 if (m.isVarArgs()) {
-                    matchingMethod = m;
+                    matchingMethod = getMethod(clazz, m);
                 }
             }
             if (matchingMethod == null) {
index 904fe57..2572ef1 100644 (file)
@@ -186,10 +186,10 @@ public class TestValueExpressionImpl {
         context.getVariableMapper().setVariable("beanA", var);
 
         ValueExpression ve = factory.createValueExpression(
-                context, "${beanA.valList.isEmpty()}", String.class);
+                context, "${beanA.valList.size()}", Integer.class);
 
-        String result = (String) ve.getValue(context);
-        assertEquals("true", result);
+        Integer result = (Integer) ve.getValue(context);
+        assertEquals(Integer.valueOf(0), result);
     }
 
 
@@ -208,9 +208,9 @@ public class TestValueExpressionImpl {
         context.getVariableMapper().setVariable("list", var);
 
         ValueExpression ve = factory.createValueExpression(
-                context, "${list.isEmpty()}", Boolean.class);
+                context, "${list.size()}", Integer.class);
 
-        Boolean result = (Boolean) ve.getValue(context);
-        assertEquals(Boolean.TRUE, result);
+        Integer result = (Integer) ve.getValue(context);
+        assertEquals(Integer.valueOf(0), result);
     }
 }
index 9caec84..fe21e03 100644 (file)
         <bug>51532</bug>: JSP files with dependencies in JARs were recompiled on
         every access leading to poor performance. (markt)
       </fix>
+      <fix>
+        <bug>51544</bug>: Correctly resolve bean methods in EL so accessible
+        methods that are overridden by inaccessible methods do not cause an
+        IllegalAccessException. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">