Author: clement
Date: Fri Jun 18 12:20:24 2010
New Revision: 955965

URL: http://svn.apache.org/viewvc?rev=955965&view=rev
Log:
Fix FELIX-2430
The super() invocation was not correctly computed. It wrongly guess that it is 
the first <init> call, but not necessary. Now, the super call detection check 
for the super class name.

Added:
    
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithNew.java
Modified:
    
felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ConstructorCodeAdapter.java
    
felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java
    felix/trunk/ipojo/tests/core/service-providing/pom.xml
    felix/trunk/ipojo/tests/manipulator/creation/pom.xml
    
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
    
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java
    felix/trunk/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml

Modified: 
felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ConstructorCodeAdapter.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ConstructorCodeAdapter.java?rev=955965&r1=955964&r2=955965&view=diff
==============================================================================
--- 
felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ConstructorCodeAdapter.java
 (original)
+++ 
felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ConstructorCodeAdapter.java
 Fri Jun 18 12:20:24 2010
@@ -48,6 +48,11 @@ public class ConstructorCodeAdapter exte
     private boolean m_superDetected;
     
     /**
+     * The super class. 
+     */
+    private String m_superClass;
+    
+    /**
      * Set of contained fields.
      */
     private Set m_fields;
@@ -63,11 +68,12 @@ public class ConstructorCodeAdapter exte
      * @param desc the constructor descriptor
      * @param name the name
      */
-    public ConstructorCodeAdapter(final MethodVisitor mv, final String owner, 
Set fields, int access, String name, String desc) {
+    public ConstructorCodeAdapter(final MethodVisitor mv, final String owner, 
Set fields, int access, String name, String desc, String superClass) {
         super(mv, access, name, desc);
         m_owner = owner;
         m_superDetected = false;
         m_fields = fields;
+        m_superClass = superClass;
     }
     
     /**
@@ -137,7 +143,8 @@ public class ConstructorCodeAdapter exte
     public void visitMethodInsn(int opcode, String owner, String name, String 
desc) {
         
         // A method call is detected, check if it is the super call :
-        if (!m_superDetected && name.equals("<init>")) {
+        // the first init is not necessary the super call, so check that it is 
really the super class.
+        if (!m_superDetected && name.equals("<init>")  && 
owner.equals(m_superClass)) {
             m_superDetected = true; 
             // The first invocation is the super call
             // 1) Visit the super constructor :

Modified: 
felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java?rev=955965&r1=955964&r2=955965&view=diff
==============================================================================
--- 
felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java
 (original)
+++ 
felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java
 Fri Jun 18 12:20:24 2010
@@ -203,7 +203,7 @@ public class MethodCreator extends Class
 
             // Insert the new constructor
             MethodVisitor mv = super.visitMethod(ACC_PRIVATE, "<init>", 
newDesc, signature, exceptions);
-            return new ConstructorCodeAdapter(mv, m_owner, m_fields, 
ACC_PRIVATE, name, newDesc);
+            return new ConstructorCodeAdapter(mv, m_owner, m_fields, 
ACC_PRIVATE, name, newDesc, m_superclass);
         }
         
         if ((access & ACC_SYNTHETIC) == ACC_SYNTHETIC && 
name.startsWith("access$")) { 

Modified: felix/trunk/ipojo/tests/core/service-providing/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/pom.xml?rev=955965&r1=955964&r2=955965&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/pom.xml (original)
+++ felix/trunk/ipojo/tests/core/service-providing/pom.xml Fri Jun 18 12:20:24 
2010
@@ -93,7 +93,6 @@
             </goals>
             <configuration>
               <ignoreAnnotations>true</ignoreAnnotations>
-              <ignoreEmbeddedSchemas>true</ignoreEmbeddedSchemas>
             </configuration>
           </execution>
         </executions>

Modified: felix/trunk/ipojo/tests/manipulator/creation/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/pom.xml?rev=955965&r1=955964&r2=955965&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/creation/pom.xml (original)
+++ felix/trunk/ipojo/tests/manipulator/creation/pom.xml Fri Jun 18 12:20:24 
2010
@@ -85,6 +85,7 @@
                        <plugin>
                                <groupId>org.apache.felix</groupId>
                                <artifactId>maven-ipojo-plugin</artifactId>
+                <version>1.7.0-SNAPSHOT</version>
                                <executions>
                                        <execution>
                                                <goals>

Added: 
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithNew.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithNew.java?rev=955965&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithNew.java
 (added)
+++ 
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithNew.java
 Fri Jun 18 12:20:24 2010
@@ -0,0 +1,10 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+public class CallSuperConstructorWithNew extends ParentClass {
+    
+    public CallSuperConstructorWithNew() {
+        super(new StringBuffer("test"));
+        System.out.println("plop");
+    } 
+
+}

Modified: 
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java?rev=955965&r1=955964&r2=955965&view=diff
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
 (original)
+++ 
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
 Fri Jun 18 12:20:24 2010
@@ -6,6 +6,10 @@ public class ParentClass {
 
     public ParentClass(final String n) {
         name = n;
+    }
+    
+    public ParentClass(final StringBuffer n) {
+        name = n.toString();
     } 
 
 }

Modified: 
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java?rev=955965&r1=955964&r2=955965&view=diff
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java
 (original)
+++ 
felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java
 Fri Jun 18 12:20:24 2010
@@ -233,6 +233,14 @@ public class POJOCreation extends OSGiTe
         }
     }
     
+    public void testSuperCallWithNew() {
+        try {
+            
helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructorWithNew");
+        } catch (Throwable e) {
+            fail(e.getMessage());
+        }
+    }
+    
     public void testSuperCallWithBC() {
         try {
             
helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructorWithBC");

Modified: 
felix/trunk/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml?rev=955965&r1=955964&r2=955965&view=diff
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml 
(original)
+++ 
felix/trunk/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml 
Fri Jun 18 12:20:24 2010
@@ -57,6 +57,7 @@
        
        <!-- Try calling super constructors -->
         <component 
classname="org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructor"
 immediate="true"/>
+     <component 
classname="org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructorWithNew"
 immediate="true"/>
         <component 
classname="org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructorWithBC"
 immediate="true"/>
         
         <!--  Several constructors -->


Reply via email to