Commits

Anonymous committed ca390f4

Fixes OGNL-92. ASTStaticMethod wasn't evaluating its own body during getSourceString() so subsequent chained expression parts weren't able to properly reflect on their members.

Comments (0)

Files changed (2)

src/java/ognl/ASTStaticMethod.java

                     result += parmString;
                 }
             }
+
             result += ")";
 
-            if (m != null) {
+            try {
+
+                Object contextObj = getValueBody(context, target);
+                context.setCurrentObject(contextObj);
+
+            } catch (Throwable t) {
+                // ignore
+            }
+
+            if (m != null)
+            {
                 _getterClass = m.getReturnType();
 
                 context.setCurrentType(m.getReturnType());

src/test/java/org/ognl/test/StaticsAndConstructorsTest.java

         }
     }
 
+    public enum Animals {
+
+        Dog, Cat, Wallabee, Bear; 
+    }
+
     private static Object[][]       TESTS = {
             { "@java.lang.Class@forName(\"java.lang.Object\")", Object.class },
             { "@java.lang.Integer@MAX_VALUE", new Integer(Integer.MAX_VALUE) },
             { "map.test.getCurrentClass(@org.ognl.test.StaticsAndConstructorsTest@KEY.toString())", "size stop"},
             { "new org.ognl.test.StaticsAndConstructorsTest$IntWrapper(index)", new IntWrapper(ROOT.getIndex()) },
             { "new org.ognl.test.StaticsAndConstructorsTest$IntObjectWrapper(index)", new IntObjectWrapper(ROOT.getIndex()) },
-            { "new org.ognl.test.StaticsAndConstructorsTest$A(#root)", new A(ROOT)}
+            { "new org.ognl.test.StaticsAndConstructorsTest$A(#root)", new A(ROOT)},
+            {"@org.ognl.test.StaticsAndConstructorsTest$Animals@values().length != 2", Boolean.TRUE}
     };
 
     /*===================================================================