aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1241602 - in /aries/trunk/proxy/proxy-impl/src: main/java/org/apache/aries/proxy/impl/common/ main/java/org/apache/aries/proxy/impl/interfaces/ main/java/org/apache/aries/proxy/impl/weaving/ test/java/org/apache/aries/blueprint/proxy/
Date Tue, 07 Feb 2012 20:34:08 GMT
Author: djencks
Date: Tue Feb  7 20:34:08 2012
New Revision: 1241602

URL: http://svn.apache.org/viewvc?rev=1241602&view=rev
Log:
ARIES-819 simplify OSGIFriendlyClassWriter based on feedback from Eric Bruneton

Modified:
    aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/common/OSGiFriendlyClassWriter.java
    aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java
    aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/ProxyWeavingHook.java
    aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/WovenProxyGenerator.java
    aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java

Modified: aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/common/OSGiFriendlyClassWriter.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/common/OSGiFriendlyClassWriter.java?rev=1241602&r1=1241601&r2=1241602&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/common/OSGiFriendlyClassWriter.java
(original)
+++ aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/common/OSGiFriendlyClassWriter.java
Tue Feb  7 20:34:08 2012
@@ -36,24 +36,18 @@ public final class OSGiFriendlyClassWrit
 
   private static final String OBJECT_INTERNAL_NAME = "java/lang/Object";
   private final ClassLoader loader;
-  private String currentClassInternalName;
-  private String currentSuperClassInternalName;
- 
+
   
-  public OSGiFriendlyClassWriter(ClassReader arg0, int arg1, ClassLoader loader, String currentClassInternalName,
String currentSuperClassInternalName) {
+  public OSGiFriendlyClassWriter(ClassReader arg0, int arg1, ClassLoader loader) {
     super(arg0, arg1);
     
     this.loader = loader;
-    this.currentClassInternalName = currentClassInternalName;
-    this.currentSuperClassInternalName = currentSuperClassInternalName;
   }
   
-  public OSGiFriendlyClassWriter(int arg0, ClassLoader loader, String currentClassInternalName,
String currentSuperClassInternalName) {
+  public OSGiFriendlyClassWriter(int arg0, ClassLoader loader) {
     super(arg0);
     
     this.loader = loader;
-    this.currentClassInternalName = currentClassInternalName;
-    this.currentSuperClassInternalName = currentSuperClassInternalName;
   }
 
   /**
@@ -61,25 +55,15 @@ public final class OSGiFriendlyClassWrit
    * 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) {
-    //---------------  see asm ow2 316320 which proposes putting the generic common cases
in ClassWriter.internalGetCommonSuperClass
-    //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))
+    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))
-      return getCommonSuperClass(currentSuperClassInternalName, arg1);
-    else if (arg1.equals(currentClassInternalName))
-      return getCommonSuperClass(arg0, currentSuperClassInternalName);
-    //---------------- end asm 316320 proposal
+    }
     Set<String> names = new HashSet<String>();
     names.add(arg0);
     names.add(arg1);

Modified: aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java?rev=1241602&r1=1241601&r2=1241602&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java
(original)
+++ aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java
Tue Feb  7 20:34:08 2012
@@ -61,7 +61,7 @@ final class InterfaceCombiningClassAdapt
   InterfaceCombiningClassAdapter(String className,
       ClassLoader loader, Class<?> superclass, Collection<Class<?>> interfaces)
{
     super(Opcodes.ASM4);
-    writer = new OSGiFriendlyClassWriter(ClassWriter.COMPUTE_FRAMES, loader, className, (superclass!=null)?
superclass.getName(): null);
+    writer = new OSGiFriendlyClassWriter(ClassWriter.COMPUTE_FRAMES, loader);
     ClassVisitor cv = new OSGiFriendlyClassVisitor(writer, ClassWriter.COMPUTE_FRAMES);
     adapter = new InterfaceUsingWovenProxyAdapter(cv, className, loader);
 

Modified: aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/ProxyWeavingHook.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/ProxyWeavingHook.java?rev=1241602&r1=1241601&r2=1241602&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/ProxyWeavingHook.java
(original)
+++ aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/ProxyWeavingHook.java
Tue Feb  7 20:34:08 2012
@@ -77,7 +77,7 @@ public final class ProxyWeavingHook impl
     
     try {
       bytes = WovenProxyGenerator.getWovenProxy(wovenClass.getBytes(),
-          wovenClass.getClassName(), wovenClass.getBundleWiring().getClassLoader());
+              wovenClass.getBundleWiring().getClassLoader());
       
     } catch (Exception e) {
       if(e instanceof RuntimeException && 

Modified: aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/WovenProxyGenerator.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/WovenProxyGenerator.java?rev=1241602&r1=1241601&r2=1241602&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/WovenProxyGenerator.java
(original)
+++ aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/WovenProxyGenerator.java
Tue Feb  7 20:34:08 2012
@@ -34,7 +34,7 @@ import org.objectweb.asm.ClassWriter;
  */
 public final class WovenProxyGenerator
 {
-  public static final byte[] getWovenProxy(byte[] original, String className, ClassLoader
loader){
+  public static final byte[] getWovenProxy(byte[] original, ClassLoader loader){
     ClassReader cReader = new ClassReader(original);
     //Don't weave interfaces, enums or annotations
     if((cReader.getAccess() & (ACC_INTERFACE | ACC_ANNOTATION | ACC_ENUM)) != 0)
@@ -44,11 +44,11 @@ public final class WovenProxyGenerator
     //maxs are fine (and faster)
     int computeVal = AbstractWovenProxyAdapter.IS_AT_LEAST_JAVA_6 ? 
         ClassWriter.COMPUTE_FRAMES : ClassWriter.COMPUTE_MAXS;
-    ClassWriter cWriter = new OSGiFriendlyClassWriter(cReader, computeVal, loader, cReader.getClassName(),
cReader.getSuperName());
+    ClassWriter cWriter = new OSGiFriendlyClassWriter(cReader, computeVal, loader);
     ClassVisitor cv = new OSGiFriendlyClassVisitor(cWriter, computeVal );
     //Wrap our outer layer to add the original SerialVersionUID if it was previously being
defaulted
     ClassVisitor weavingAdapter = new SyntheticSerialVerUIDAdder(
-                               new WovenProxyAdapter(cv, className, loader));
+                               new WovenProxyAdapter(cv, cReader.getClassName(), loader));
     
     // If we are Java 1.6 + then we need to skip frames as they will be recomputed
     cReader.accept(weavingAdapter, AbstractWovenProxyAdapter.IS_AT_LEAST_JAVA_6 ? ClassReader.SKIP_FRAMES
: 0);

Modified: aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java?rev=1241602&r1=1241601&r2=1241602&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java
(original)
+++ aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java
Tue Feb  7 20:34:08 2012
@@ -122,7 +122,7 @@ public class WovenProxyGeneratorTest ext
         }
       }
       if(weave)
-        bytes = WovenProxyGenerator.getWovenProxy(bytes, className, this);
+        bytes = WovenProxyGenerator.getWovenProxy(bytes, this);
       
       return defineClass(className, bytes, 0, bytes.length);
     }



Mime
View raw message