Commits

Anonymous committed 8f30805

XW-534 (Updgrate Ognl dependency to 2.7 for XWork 1.2.3 release)
- fix bug introduced (grab the wrong class) while implementing new methods introduced by PropertyAccessor introduced in OGNL 2.7.x

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/xwork_1-2/src@1679e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits 7977f6f

Comments (0)

Files changed (2)

File java/com/opensymphony/xwork/util/CompoundRootAccessor.java

                                 if (Map.class.isAssignableFrom(pd.getClass())) {
                                     return Map.class;
                                 }
-                                return pd.getClass();
+                                return pd.getPropertyType();
                             }
                         }
                     }
         CompoundRoot root = (CompoundRoot) target;
 
         if (name instanceof Integer) {
-            return ".cutStack("+name+")";    
+            return ".cutStack("+name+")";
         }
         else if (name instanceof String) {
             String beanName = ((String)name).replaceAll("\"", "");
                     if (tmp != null) {
                         PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor(tmp.getClass(), beanName);
                         if (pd != null) {
-                            if (Map.class.isAssignableFrom(pd.getClass())) {
+                            if (Map.class.isAssignableFrom(tmp.getClass())) {
 
                                 ExpressionCompiler.addCastString(ognlcontext, "(("+Map.class.getName()+")");
 
                                 return ".get("+a+")).get(\""+beanName+"\")";
                             }
 
-                            Class type = OgnlRuntime.getCompiler().getInterfaceClass(pd.getClass());
-
+                            Class type = OgnlRuntime.getCompiler().getSuperOrInterfaceClass(pd.getReadMethod(), tmp.getClass());
                             ExpressionCompiler.addCastString(ognlcontext, "((" + type.getName() + ")");
 
                             ognlcontext.setCurrentType(type);
     }
 
     public String getSourceSetter(OgnlContext ognlcontext, Object target, Object name) {
-
         CompoundRoot root = (CompoundRoot) target;
         if (name instanceof String) {
             String beanName = ((String)name).replaceAll("\"", "");
                     if (tmp != null) {
                         PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor(tmp.getClass(), beanName);
                         if (pd != null) {
-                            if (Map.class.isAssignableFrom(pd.getClass())) {
+                            if (Map.class.isAssignableFrom(tmp.getClass())) {
 
                                 ExpressionCompiler.addCastString(ognlcontext, "(("+Map.class.getName()+")");
 
                             if (param.isPrimitive()) {
                                 Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(param);
                                 conversion = OgnlRuntime.getCompiler().createLocalReference(ognlcontext,
-                                                                            "((" + wrapClass.getName() + ")ognl.OgnlOps#convertValue($3," + wrapClass.getName()
-                                                                            + ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass),
+                                                                            "((" + wrapClass.getName() + ")ognl.OgnlOps#convertValue($3,"
+                                                                            + wrapClass.getName()+ ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass),
                                                                             param);
 
                             } else if (param.isArray()) {
                                                                             param);
                             }
 
-                            Class type = OgnlRuntime.getCompiler().getInterfaceClass(pd.getWriteMethod().getClass());
+                            Class type = OgnlRuntime.getCompiler().getSuperOrInterfaceClass(pd.getWriteMethod(), tmp.getClass());
 
                             ExpressionCompiler.addCastString(ognlcontext, "((" + type.getName() + ")");
 

File java/com/opensymphony/xwork/util/ObjectProxyPropertyAccessor.java

         if (tmp != null) {
             Method m = OgnlRuntime.getReadMethod(tmp.getClass(), beanName);
 
-            Class type = OgnlRuntime.getCompiler().getInterfaceClass(proxy.getValue().getClass());
+            Class type = OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, proxy.getValue().getClass());
 
             ExpressionCompiler.addCastString(ognlcontext, "((" + type.getName() + ")");
 
         if (tmp != null) {
             Method m = OgnlRuntime.getWriteMethod(tmp.getClass(), beanName);
 
-            Class type = OgnlRuntime.getCompiler().getInterfaceClass(proxy.getValue().getClass());
+            Class type = OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, proxy.getValue().getClass());
 
-            if (m.getParameterTypes().length > 1) {
+            if (m.getParameterTypes().length != 1) {
                 throw new UnsupportedCompilationException("Object property accessors can only support single parameter setters.");
             }