cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1509283 - in /cxf/branches/2.6.x-fixes: api/src/main/java/org/apache/cxf/common/util/ASMHelper.java rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java
Date Thu, 01 Aug 2013 15:20:05 GMT
Author: dkulp
Date: Thu Aug  1 15:20:05 2013
New Revision: 1509283

URL: http://svn.apache.org/r1509283
Log:
Merged revisions 1508975 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

........
  r1508975 | dkulp | 2013-07-31 14:13:56 -0400 (Wed, 31 Jul 2013) | 10 lines

  Merged revisions 1508965 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1508965 | dkulp | 2013-07-31 13:34:32 -0400 (Wed, 31 Jul 2013) | 2 lines

    [CXF-5147] Don't NPE if using a primitive for a holder. If null, don't call the setter
so whatever is the default in the wrapper object would end up being used. (basically, same
behavior as when a BARE method is used)

  ........

........

Modified:
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/util/ASMHelper.java
    cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/util/ASMHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/util/ASMHelper.java?rev=1509283&r1=1509282&r2=1509283&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/util/ASMHelper.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/util/ASMHelper.java Thu
Aug  1 15:20:05 2013
@@ -38,6 +38,7 @@ import org.apache.cxf.common.util.Reflec
 public class ASMHelper {
     protected static final Map<Class<?>, String> PRIMITIVE_MAP = new HashMap<Class<?>,
String>();
     protected static final Map<Class<?>, String> NONPRIMITIVE_MAP = new HashMap<Class<?>,
String>();
+    protected static final Map<Class<?>, Integer> PRIMITIVE_ZERO_MAP = new HashMap<Class<?>,
Integer>();
     
     protected static final Map<Class<?>, WeakReference<TypeHelperClassLoader>>
LOADER_MAP 
         = new WeakIdentityHashMap<Class<?>, WeakReference<TypeHelperClassLoader>>();
@@ -127,6 +128,11 @@ public class ASMHelper {
         public static int IFNONNULL = 0;
         public static int SIPUSH = 0;
         public static int INVOKESTATIC = 0;
+        public static int ICONST_0;
+        public static int LCONST_0;
+        public static int FCONST_0;
+        public static int DCONST_0;
+        
         //CHECKSTYLE:ON
         static {
             try {
@@ -139,6 +145,15 @@ public class ASMHelper {
             } catch (Throwable e) {
                 //ignore
             }
+            
+            PRIMITIVE_ZERO_MAP.put(Byte.TYPE, Opcodes.ICONST_0);
+            PRIMITIVE_ZERO_MAP.put(Boolean.TYPE, Opcodes.ICONST_0);
+            PRIMITIVE_ZERO_MAP.put(Long.TYPE, Opcodes.LCONST_0);
+            PRIMITIVE_ZERO_MAP.put(Integer.TYPE, Opcodes.ICONST_0);
+            PRIMITIVE_ZERO_MAP.put(Short.TYPE, Opcodes.ICONST_0);
+            PRIMITIVE_ZERO_MAP.put(Character.TYPE, Opcodes.ICONST_0);
+            PRIMITIVE_ZERO_MAP.put(Float.TYPE, Opcodes.FCONST_0);
+            PRIMITIVE_ZERO_MAP.put(Double.TYPE, Opcodes.DCONST_0);
         }
     }
     

Modified: cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java?rev=1509283&r1=1509282&r2=1509283&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java
Thu Aug  1 15:20:05 2013
@@ -38,7 +38,6 @@ final class WrapperHelperCompiler extend
     final Object objectFactory;
     final ClassWriter cw;
 
-    
     private WrapperHelperCompiler(Class<?> wrapperType,
                                   Method setMethods[],
                                   Method getMethods[],
@@ -263,22 +262,39 @@ final class WrapperHelperCompiler extend
                 
                 if (tp.isPrimitive()) {
                     mv.visitTypeInsn(Opcodes.CHECKCAST, NONPRIMITIVE_MAP.get(tp));
+                    Label l45 = createLabel();
+                    Label l46 = createLabel();
+                    mv.visitInsn(Opcodes.DUP);
+                    mv.visitJumpInsn(Opcodes.IFNULL, l45);
                     mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, NONPRIMITIVE_MAP.get(tp), 
                                        tp.getName() + "Value", "()" + PRIMITIVE_MAP.get(tp));
+                    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
+                                       periodToSlashes(wrapperType.getName()),
+                                       setMethods[x].getName(), "(" + getClassCode(tp) +
")V");
+                    mv.visitJumpInsn(Opcodes.GOTO, l46);
+                    mv.visitLabel(l45);
+                    mv.visitInsn(Opcodes.POP);
+                    mv.visitLabel(l46);
                 } else if (JAXBElement.class.isAssignableFrom(tp)) {
                     mv.visitTypeInsn(Opcodes.CHECKCAST,
                                      periodToSlashes(jaxbMethods[x].getParameterTypes()[0].getName()));
                     mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, periodToSlashes(objectFactoryClass.getName()),
                                        jaxbMethods[x].getName(),
                                        getMethodSignature(jaxbMethods[x]));
+                    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
+                                       periodToSlashes(wrapperType.getName()),
+                                       setMethods[x].getName(), "(" + getClassCode(tp) +
")V");
                 } else if (tp.isArray()) { 
                     mv.visitTypeInsn(Opcodes.CHECKCAST, getClassCode(tp));
+                    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
+                                       periodToSlashes(wrapperType.getName()),
+                                       setMethods[x].getName(), "(" + getClassCode(tp) +
")V");
                 } else {
                     mv.visitTypeInsn(Opcodes.CHECKCAST, periodToSlashes(tp.getName()));
+                    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
+                                       periodToSlashes(wrapperType.getName()),
+                                       setMethods[x].getName(), "(" + getClassCode(tp) +
")V");
                 }
-                mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
-                                   periodToSlashes(wrapperType.getName()),
-                                   setMethods[x].getName(), "(" + getClassCode(tp) + ")V");
             }
         }
         



Mime
View raw message