Title: [738] trunk/qdox/src/test/com/thoughtworks/qdox/model: additional fix for QDOX-214: returns is null for Constructors, which makes several methods fail.?\226?\128?\143
Revision
738
Author
rfscholte
Date
2010-08-02 11:33:28 -0500 (Mon, 02 Aug 2010)

Log Message

additional fix for QDOX-214: returns is null for Constructors, which makes several methods fail.?\226?\128?\143

Modified Paths

Diff

Modified: trunk/qdox/src/java/com/thoughtworks/qdox/model/JavaMethod.java (737 => 738)

--- trunk/qdox/src/java/com/thoughtworks/qdox/model/JavaMethod.java	2010-07-30 16:40:18 UTC (rev 737)
+++ trunk/qdox/src/java/com/thoughtworks/qdox/model/JavaMethod.java	2010-08-02 16:33:28 UTC (rev 738)
@@ -468,12 +468,15 @@
      * @since 1.12
      */
     protected Type getReturnType ( boolean resolve, JavaClass callingClass) {
-        Type result =  getReturns().resolve( this.getParentClass(), callingClass );
-        
-        //According to java-specs, if it could be resolved the upper boundary, so Object, should be returned  
-        if ( !resolve && !returns.getFullyQualifiedName().equals( result.getFullyQualifiedName() ) )
-        {
-            result = new Type( "java.lang.Object" );
+        Type result = null;
+        if (getReturns() != null) {
+            result =  getReturns().resolve( this.getParentClass(), callingClass );
+            
+            //According to java-specs, if it could be resolved the upper boundary, so Object, should be returned  
+            if ( !resolve && !returns.getFullyQualifiedName().equals( result.getFullyQualifiedName() ) )
+            {
+                result = new Type( "java.lang.Object" );
+            }
         }
         return result;
     }
@@ -506,7 +509,7 @@
         {
             Type curType = getParameters()[paramIndex].getType().resolve( this.getParentClass(), callingClass );
             //According to java-specs, if it could be resolved the upper boundary, so Object, should be returned  
-            if ( !resolve && !returns.getFullyQualifiedName().equals( curType.getFullyQualifiedName() ) )
+            if ( !resolve && returns != null && !returns.getFullyQualifiedName().equals( curType.getFullyQualifiedName() ) )
             {
                 result[paramIndex] = new Type( "java.lang.Object" );
             }

Modified: trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java (737 => 738)

--- trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java	2010-07-30 16:40:18 UTC (rev 737)
+++ trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java	2010-08-02 16:33:28 UTC (rev 738)
@@ -366,7 +366,21 @@
         assertEquals("a.b.Executor()", constructor.toString());
     }
 
-    
+    public void testConstructorReturnType() throws Exception {
+        JavaMethod constructor = new JavaMethod(null,"Executor");
+        constructor.setConstructor( true );
+        assertEquals(null, constructor.getReturnType());
+    }
+
+    public void testConstructorParameterTypes() throws Exception {
+        JavaClass cls = new JavaClass("a.b.Executor");
+        JavaMethod constructor = new JavaMethod(null,"Executor");
+        constructor.addParameter( new JavaParameter( new Type("a.b.C"), "param" ) );
+        constructor.setConstructor( true );
+        cls.addMethod(constructor);
+        assertEquals("a.b.C", constructor.getParameterTypes()[0].toString());
+    }
+
     private void assertNotEquals(Object o1, Object o2) {
         assertTrue(o1.toString() + " should not equals " + o2.toString(), !o1.equals(o2));
     }


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to