aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1357640 - in /aries/trunk/spi-fly: spi-fly-dynamic-bundle/ spi-fly-dynamic-bundle/src/main/java/org/apache/aries/spifly/dynamic/ spi-fly-static-tool/ spi-fly-weaver/ spi-fly-weaver/src/main/java/org/apache/aries/spifly/weaver/
Date Thu, 05 Jul 2012 14:42:55 GMT
Author: davidb
Date: Thu Jul  5 14:42:55 2012
New Revision: 1357640

URL: http://svn.apache.org/viewvc?rev=1357640&view=rev
Log:
[SPI-Fly] Upgrade asm dependency from 3.2 to 4.0

Modified:
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/pom.xml
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/main/java/org/apache/aries/spifly/dynamic/OSGiFriendlyClassWriter.java
    aries/trunk/spi-fly/spi-fly-static-tool/pom.xml
    aries/trunk/spi-fly/spi-fly-weaver/pom.xml
    aries/trunk/spi-fly/spi-fly-weaver/src/main/java/org/apache/aries/spifly/weaver/TCCLSetterVisitor.java

Modified: aries/trunk/spi-fly/spi-fly-dynamic-bundle/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/pom.xml?rev=1357640&r1=1357639&r2=1357640&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/pom.xml (original)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/pom.xml Thu Jul  5 14:42:55 2012
@@ -39,9 +39,9 @@ JRE through META-INF/services resources)
 
     <dependencies>
         <dependency>
-            <groupId>asm</groupId>
+            <groupId>org.ow2.asm</groupId>
             <artifactId>asm-all</artifactId>
-            <version>3.2</version>
+            <version>4.0</version>
         </dependency>
 
         <dependency>

Modified: aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/main/java/org/apache/aries/spifly/dynamic/OSGiFriendlyClassWriter.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/main/java/org/apache/aries/spifly/dynamic/OSGiFriendlyClassWriter.java?rev=1357640&r1=1357639&r2=1357640&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/main/java/org/apache/aries/spifly/dynamic/OSGiFriendlyClassWriter.java
(original)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/main/java/org/apache/aries/spifly/dynamic/OSGiFriendlyClassWriter.java
Thu Jul  5 14:42:55 2012
@@ -25,127 +25,96 @@ import java.util.Set;
 
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.commons.JSRInlinerAdapter;
-
-
 /**
- * We need to override ASM's default behaviour in
- * {@link #getCommonSuperClass(String, String)} so that it doesn't load classes
- * (which it was doing on the wrong {@link ClassLoader} anyway...)
+ * We need to override ASM's default behaviour in {@link #getCommonSuperClass(String, String)}
+ * so that it doesn't load classes (which it was doing on the wrong {@link ClassLoader}
+ * anyway...)
  *
  * Taken from the org.apache.aries.proxy.impl module.
  */
 public final class OSGiFriendlyClassWriter extends ClassWriter {
 
-    private static final String OBJECT_INTERNAL_NAME = "java/lang/Object";
-    private final ClassLoader loader;
-    private String currentClassInternalName;
-    private String currentSuperClassInternalName;
-    private final boolean inlineJSR;
-
-    public OSGiFriendlyClassWriter(ClassReader arg0, int arg1, ClassLoader loader) {
-        super(arg0, arg1);
-        inlineJSR = arg1 == COMPUTE_FRAMES;
-        this.loader = loader;
-    }
+  private static final String OBJECT_INTERNAL_NAME = "java/lang/Object";
+  private final ClassLoader loader;
 
-    public OSGiFriendlyClassWriter(int arg0, ClassLoader loader) {
-        super(arg0);
-        inlineJSR = arg0 == COMPUTE_FRAMES;
-        this.loader = loader;
-    }
 
-    /**
-     * We provide an implementation that doesn't cause class loads to occur. It
-     * may not be sufficient because it expects to find the common parent using
-     * a single classloader, though in fact the common parent may only be
-     * loadable by another bundle from which an intermediate class is loaded
-     */
-    @Override
-    protected final String getCommonSuperClass(String arg0, String arg1) {
-        // If the two are equal then return either
-        if (arg0.equals(arg1))
-            return arg0;
-
-        // If either is Object, then Object must be the answer
-        if (arg0.equals(OBJECT_INTERNAL_NAME) || arg1.equals(OBJECT_INTERNAL_NAME))
-            return OBJECT_INTERNAL_NAME;
-
-        // If either of these class names are the current class then we can
-        // short
-        // circuit to the superclass (which we already know)
-        if (arg0.equals(currentClassInternalName))
-            getCommonSuperClass(currentSuperClassInternalName, arg1);
-        else if (arg1.equals(currentClassInternalName))
-            getCommonSuperClass(arg0, currentSuperClassInternalName);
-
-        Set<String> names = new HashSet<String>();
-        names.add(arg0);
-        names.add(arg1);
-        // Try loading the class (in ASM not for real)
-        try {
-            boolean bRunning = true;
-            boolean aRunning = true;
-            InputStream is;
-            String arg00 = arg0;
-            String arg11 = arg1;
-            String unable = null;
-            while (aRunning || bRunning) {
-                if (aRunning) {
-                    is = loader.getResourceAsStream(arg00 + ".class");
-                    if (is != null) {
-                        ClassReader cr = new ClassReader(is);
-                        arg00 = cr.getSuperName();
-                        if (arg00 == null)
-                            aRunning = false;
-                        else if (!!!names.add(arg00))
-                            return arg00;
-                    } else {
-                        // The class file isn't visible on this ClassLoader
-                        unable = arg0;
-                        aRunning = false;
-                    }
-                }
-                if (bRunning) {
-                    is = loader.getResourceAsStream(arg11 + ".class");
-                    if (is != null) {
-                        ClassReader cr = new ClassReader(is);
-                        arg11 = cr.getSuperName();
-                        if (arg11 == null)
-                            bRunning = false;
-                        else if (!!!names.add(arg11))
-                            return arg11;
-                    } else {
-                        unable = arg1;
-                        bRunning = false;
-                    }
-                }
-            }
-
-            throw new RuntimeException("No Common Supperclass:" + arg0 + " " + arg1);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
+  public OSGiFriendlyClassWriter(ClassReader arg0, int arg1, ClassLoader loader) {
+    super(arg0, arg1);
 
-    /**
-     * We need access to the super's name and our class name
-     */
-    @Override
-    public final void visit(int arg0, int arg1, String arg2, String arg3, String arg4, String[]
arg5) {
-        currentClassInternalName = arg2;
-        currentSuperClassInternalName = arg4;
-        super.visit(arg0, arg1, arg2, arg3, arg4, arg5);
+    this.loader = loader;
+  }
+
+  public OSGiFriendlyClassWriter(int arg0, ClassLoader loader) {
+    super(arg0);
+
+    this.loader = loader;
+  }
+
+  /**
+   * We provide an implementation that doesn't cause class loads to occur. It may
+   * not be sufficient because it expects to find the common parent using a single
+   * classloader, though in fact the common parent may only be loadable by another
+   * bundle from which an intermediate class is loaded
+   *
+   * precondition: arg0 and arg1 are not equal. (checked before this method is called)
+   */
+  @Override
+  protected final String getCommonSuperClass(String arg0, String arg1) {
+    //If either is Object, then Object must be the answer
+    if(arg0.equals(OBJECT_INTERNAL_NAME) || arg1.equals(OBJECT_INTERNAL_NAME)) {
+      return OBJECT_INTERNAL_NAME;
     }
+    Set<String> names = new HashSet<String>();
+    names.add(arg0);
+    names.add(arg1);
+    //Try loading the class (in ASM not for real)
+    try {
+      boolean bRunning = true;
+      boolean aRunning = true;
+      InputStream is;
+      String arg00 = arg0;
+      String arg11 = arg1;
+      while(aRunning || bRunning ) {
+        if(aRunning) {
+          is = loader.getResourceAsStream(arg00 + ".class");
+          if(is != null) {
+            ClassReader cr = new ClassReader(is);
+            arg00 = cr.getSuperName();
+            if(arg00 == null) {
+              if (names.size() == 2) {
+                return OBJECT_INTERNAL_NAME; //arg0 is an interface
+              }
+              aRunning = false; //old arg00 was java.lang.Object
+            } else if(!!!names.add(arg00)) {
+              return arg00;
+            }
+          } else {
+            //The class file isn't visible on this ClassLoader
+            aRunning = false;
+          }
+        }
+        if(bRunning) {
+          is = loader.getResourceAsStream(arg11 + ".class");
+          if(is != null) {
+            ClassReader cr = new ClassReader(is);
+            arg11 = cr.getSuperName();
+            if(arg11 == null) {
+              if (names.size() == 3) {
+                return OBJECT_INTERNAL_NAME;  //arg1 is an interface
+              }
+              bRunning = false; //old arg11 was java.lang.Object
+            } else if(!!!names.add(arg11)) {
+              return arg11;
+            }
+          } else {
+            bRunning = false;
+          }
+        }
+      }
 
-    @Override
-    public MethodVisitor visitMethod(int arg0, String arg1, String arg2, String arg3, String[]
arg4) {
-        MethodVisitor mv = super.visitMethod(arg0, arg1, arg2, arg3, arg4);
-
-        if (inlineJSR)
-            mv = new JSRInlinerAdapter(mv, arg0, arg1, arg2, arg3, arg4);
-
-        return mv;
+      throw new RuntimeException("No Common Superclass:" + arg0 + " " + arg1);
+    } catch (IOException e) {
+      throw new RuntimeException(e);
     }
+  }
 }

Modified: aries/trunk/spi-fly/spi-fly-static-tool/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-static-tool/pom.xml?rev=1357640&r1=1357639&r2=1357640&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-static-tool/pom.xml (original)
+++ aries/trunk/spi-fly/spi-fly-static-tool/pom.xml Thu Jul  5 14:42:55 2012
@@ -37,9 +37,9 @@
 
     <dependencies>
         <dependency>
-            <groupId>asm</groupId>
+            <groupId>org.ow2.asm</groupId>
             <artifactId>asm-all</artifactId>
-            <version>3.2</version>
+            <version>4.0</version>
         </dependency>
 
         <dependency>

Modified: aries/trunk/spi-fly/spi-fly-weaver/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-weaver/pom.xml?rev=1357640&r1=1357639&r2=1357640&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-weaver/pom.xml (original)
+++ aries/trunk/spi-fly/spi-fly-weaver/pom.xml Thu Jul  5 14:42:55 2012
@@ -34,9 +34,9 @@
 
     <dependencies>
         <dependency>
-            <groupId>asm</groupId>
+            <groupId>org.ow2.asm</groupId>
             <artifactId>asm-all</artifactId>
-            <version>3.2</version>
+            <version>4.0</version>
             <scope>provided</scope>
         </dependency>
 

Modified: aries/trunk/spi-fly/spi-fly-weaver/src/main/java/org/apache/aries/spifly/weaver/TCCLSetterVisitor.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-weaver/src/main/java/org/apache/aries/spifly/weaver/TCCLSetterVisitor.java?rev=1357640&r1=1357639&r2=1357640&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-weaver/src/main/java/org/apache/aries/spifly/weaver/TCCLSetterVisitor.java
(original)
+++ aries/trunk/spi-fly/spi-fly-weaver/src/main/java/org/apache/aries/spifly/weaver/TCCLSetterVisitor.java
Thu Jul  5 14:42:55 2012
@@ -25,7 +25,6 @@ import java.util.Set;
 
 import org.apache.aries.spifly.Util;
 import org.apache.aries.spifly.WeavingData;
-import org.objectweb.asm.ClassAdapter;
 import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.Label;
 import org.objectweb.asm.MethodVisitor;
@@ -38,7 +37,7 @@ import org.objectweb.asm.commons.Method;
  * This class implements an ASM ClassVisitor which puts the appropriate ThreadContextClassloader
  * calls around applicable method invocations. It does the actual bytecode weaving.
  */
-public class TCCLSetterVisitor extends ClassAdapter implements ClassVisitor, Opcodes {
+public class TCCLSetterVisitor extends ClassVisitor implements Opcodes {
     private static final Type CLASSLOADER_TYPE = Type.getType(ClassLoader.class);
 
     private static final String GENERATED_METHOD_NAME = "$$FCCL$$";
@@ -60,7 +59,7 @@ public class TCCLSetterVisitor extends C
     private boolean woven = false;
 
     public TCCLSetterVisitor(ClassVisitor cv, String className, Set<WeavingData> weavingData)
{
-        super(cv);
+        super(Opcodes.ASM4, cv);
         this.targetClass = Type.getType("L" + className.replace('.', '/') + ";");
         this.weavingData = weavingData;
     }
@@ -135,12 +134,11 @@ public class TCCLSetterVisitor extends C
         return name.toString();
     }
 
-    private class TCCLSetterMethodVisitor extends GeneratorAdapter implements MethodVisitor
-    {
+    private class TCCLSetterMethodVisitor extends GeneratorAdapter {
         Type lastLDCType;
 
         public TCCLSetterMethodVisitor(MethodVisitor mv, int access, String name, String
descriptor) {
-            super(mv, access, name, descriptor);
+            super(Opcodes.ASM4, mv, access, name, descriptor);
         }
 
         /**



Mime
View raw message