Commits

Anonymous committed 2b4bda3

Added new getRootExpressionClass() to compiler interface so that other compiler impls can handle special corner cases (like operating on previously javassist'ed classes)

Comments (0)

Files changed (2)

src/java/ognl/enhance/ExpressionCompiler.java

         return clazz;
     }
 
+    public Class getRootExpressionClass(Node rootNode, OgnlContext context)
+    {
+        if (context.getRoot() == null)
+            return null;
+
+        Class ret = context.getRoot().getClass();
+
+        if (context.getFirstAccessor() != null && context.getFirstAccessor().isInstance(context.getRoot()))
+            ret = context.getFirstAccessor();
+
+        return ret;
+    }
+
     /**
      * Returns the appropriate casting expression (minus parens) for the specified class type.
      * <p/>
              && !ASTStaticMethod.class.isInstance(expression)
              && root != null) || (root != null && ASTRootVarRef.class.isInstance(expression))) {
 
-            Class castClass = root.getClass();
+            Class castClass = OgnlRuntime.getCompiler().getRootExpressionClass(expression, context);
 
-            if (context.getFirstAccessor() != null && context.getFirstAccessor().isInstance(context.getRoot()))
-                castClass = context.getFirstAccessor();
-            
             if (castClass.isArray() || ASTRootVarRef.class.isInstance(expression)
                 || ASTThisVarRef.class.isInstance(expression)) {
 

src/java/ognl/enhance/OgnlExpressionCompiler.java

     Class getInterfaceClass(Class clazz);
 
     Class getSuperOrInterfaceClass(Method m, Class clazz);
-    
+
+    Class getRootExpressionClass(Node rootNode, OgnlContext context);
+
     String castExpression(OgnlContext context, Node expression, String body);
 
     String createLocalReference(OgnlContext context, String expression, Class type);