cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1562238 - /cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Date Tue, 28 Jan 2014 21:24:39 GMT
Author: dkulp
Date: Tue Jan 28 21:24:38 2014
New Revision: 1562238

URL: http://svn.apache.org/r1562238
Log:
[CXF-5524] More addType fixes
Patch from Denis Simonov, although hard to apply and may have missed something

Modified:
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=1562238&r1=1562237&r2=1562238&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Tue Jan 28 21:24:38 2014
@@ -233,10 +233,13 @@ class JAXBContextInitializer extends Ser
                 addClass((Class<?>)cls);
             }
         } else if (cls instanceof ParameterizedType) {
-            addType(((ParameterizedType)cls).getRawType());
-            if (!((ParameterizedType)cls).getRawType().equals(Enum.class)) {
-                for (Type t2 : ((ParameterizedType)cls).getActualTypeArguments()) {
-                    addType(t2);
+            final ParameterizedType parameterizedType = (ParameterizedType)cls;
+            addType(parameterizedType.getRawType());
+            if (!parameterizedType.getRawType().equals(Enum.class)) {
+                for (Type t2 : parameterizedType.getActualTypeArguments()) {
+                    if (shouldTypeBeAdded(t2, parameterizedType)) {
+                        addType(t2);
+                    }
                 }
             }
         } else if (cls instanceof GenericArrayType) {
@@ -275,7 +278,20 @@ class JAXBContextInitializer extends Ser
         }
     }
 
-
+    private boolean shouldTypeBeAdded(final Type t2, final ParameterizedType parameterizedType)
{
+        if (!(t2 instanceof TypeVariable)) {
+            return true;
+        }
+        TypeVariable<?> typeVariable = (TypeVariable<?>) t2;
+        final Type[] bounds = typeVariable.getBounds();
+        for (Type bound : bounds) {
+            if (bound instanceof ParameterizedType && bound.equals(parameterizedType))
{
+                return false;
+            }
+        }
+        return true;
+    }
+    
     void addClass(Class<?> claz) {
         if (Throwable.class.isAssignableFrom(claz)) {
             if (!Throwable.class.equals(claz)



Mime
View raw message