Commits

jkuh...@d4b077e3-5828-0410-b394-cb2b42183085  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)

  • Participants
  • Parent commits 3cde858

Comments (0)

Files changed (2)

File 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)) {
 

File 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);