Fixed FELIX-3539

If the class version is 1.6. or 1.7, launch the class manipulator with the EXPAND_FRAMES flag.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1346929 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ClassChecker.java b/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ClassChecker.java
index 8e23bf1..2072c23 100644
--- a/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ClassChecker.java
+++ b/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ClassChecker.java
@@ -80,6 +80,12 @@
     private boolean m_supportAnnotation = false;

 

     /**

+     * Class Version.

+     * Used to determine the frame format.

+     */

+    private int m_classVersion;

+

+    /**

      * Check if the _cm field already exists.

      * Update the field list.

      * @param access : access of the field

@@ -155,6 +161,14 @@
     }

 

     /**

+     * Gets the extracted class version

+     * @return the class version.

+     */

+    public int getClassVersion() {

+        return m_classVersion;

+    }

+

+    /**

      * Visit the class.

      * Update the implemented interface list.

      * @param version : version of the class

@@ -168,6 +182,7 @@
     public void visit(int version, int access, String name, String signature,

             String superName, String[] interfaces) {

 

+        m_classVersion = version;

         m_supportAnnotation = version > V1_4 && version < V1_1;

 

         if (! superName.equals("java/lang/Object")) {

diff --git a/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java b/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
index 3739b6a..e10fa47 100644
--- a/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
+++ b/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
@@ -29,6 +29,7 @@
 import org.apache.felix.ipojo.metadata.Element;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Opcodes;
 
 /**
  * iPOJO Byte code Manipulator.
@@ -97,7 +98,11 @@
             ClassWriter cw0 = new ClassWriter(ClassWriter.COMPUTE_MAXS);
             //CheckClassAdapter ch = new CheckClassAdapter(cw0);
             MethodCreator preprocess = new MethodCreator(cw0, m_fields, m_methods);
-            cr0.accept(preprocess, 0);
+            if (ck.getClassVersion() >= Opcodes.V1_6) {
+                cr0.accept(preprocess, ClassReader.EXPAND_FRAMES);
+            } else {
+                cr0.accept(preprocess, 0);
+            }
             is2.close();
             finalWriter = cw0;
         }