]> source.dussan.org Git - aspectj.git/commitdiff
231396: refactoring AspectJ: simplified Member again, removed string compares for...
authoraclement <aclement>
Fri, 6 Jun 2008 16:35:43 +0000 (16:35 +0000)
committeraclement <aclement>
Fri, 6 Jun 2008 16:35:43 +0000 (16:35 +0000)
weaver/src/org/aspectj/weaver/JoinPointSignature.java
weaver/src/org/aspectj/weaver/Member.java
weaver/src/org/aspectj/weaver/MemberImpl.java
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java

index b6bb83b7e6e8c785884558022123bf3a860315ff..15c6c05e1c00bff4a1536649cf42076e897e8f47 100644 (file)
@@ -244,10 +244,6 @@ public class JoinPointSignature implements ResolvedMember {
                return realMember.compareTo(other);
        }
 
-       public String toLongString() {
-               return realMember.toLongString();
-       }
-
        public MemberKind getKind() {
                return realMember.getKind();
        }
@@ -308,10 +304,6 @@ public class JoinPointSignature implements ResolvedMember {
                return realMember.canBeParameterized();
        }
 
-       public String getExtractableName() {
-               return realMember.getExtractableName();
-       }
-
        public AnnotationX[] getAnnotations() {
                return realMember.getAnnotations();
        }
@@ -320,18 +312,6 @@ public class JoinPointSignature implements ResolvedMember {
                throw new UnsupportedOperationException("Adrian doesn't think you should be calling this...");
        }
 
-       public String getSignatureMakerName() {
-               return realMember.getSignatureMakerName();
-       }
-
-       public String getSignatureType() {
-               return realMember.getSignatureType();
-       }
-
-       public String getSignatureString(World world) {
-               return realMember.getSignatureString(world);
-       }
-
        public Iterator getJoinPointSignatures(World world) {
                return realMember.getJoinPointSignatures(world);
        }
index 36dcfe3a9c3190c163c98411535f8b735844e5ce..00254e54e7efa987df336b33ffa1f9b715f8c50a 100644 (file)
@@ -41,13 +41,12 @@ public interface Member extends Comparable {
 
     public int compareTo(Object other);
 
-       public String toLongString();
-
        public UnresolvedType getDeclaringType();
 
        public UnresolvedType getReturnType();
        
        public UnresolvedType getGenericReturnType();
+       
        public UnresolvedType[] getGenericParameterTypes();
 
        public UnresolvedType getType();
@@ -87,18 +86,9 @@ public interface Member extends Comparable {
         */
        public boolean canBeParameterized();
 
-       public String getExtractableName();
-
     public AnnotationX[] getAnnotations();
-
-       // ---- reflective thisJoinPoint stuff
-       public String getSignatureMakerName();
-
-       public String getSignatureType();
        
     public Collection/* ResolvedType */getDeclaringTypes(World world);
-    
-       public String getSignatureString(World world);
 
        public String[] getParameterNames(World world);
 
index 9acb8a12b29ae5c3800dcb4ddc1a7be1195bd3b0..dd12a7e863f7dd51df81def50e9ea6b6dd25055d 100644 (file)
@@ -22,7 +22,6 @@ import java.util.List;
 public class MemberImpl implements Member {
     
     protected MemberKind kind;
-
     protected int modifiers; 
     protected String name;
     protected UnresolvedType returnType;
@@ -34,12 +33,9 @@ public class MemberImpl implements Member {
     // OPTIMIZE move out of the member!
     private boolean reportedCantFindDeclaringType = false;
     private boolean reportedUnresolvableMember = false;
-
     
     /**
      * All the signatures that a join point with this member as its signature has.
-     * The fact that this has to go on MemberImpl and not ResolvedMemberImpl says a lot about
-     * how broken the Member/ResolvedMember distinction currently is.
      */
     private JoinPointSignatureIterator joinPointSignatures = null;
 
@@ -76,7 +72,6 @@ public class MemberImpl implements Member {
         String name, 
         UnresolvedType[] parameterTypes) 
     {
-        super();
         this.kind = kind;
         this.declaringType = declaringType;
         this.modifiers = modifiers;
@@ -211,6 +206,7 @@ public class MemberImpl implements Member {
     public static Member field(UnresolvedType declaring, int mods, String name, UnresolvedType type) {
         return new MemberImpl(FIELD, declaring, mods, type, name, UnresolvedType.NONE);
     }    
+    // OPTIMIZE do we need to call this? unless necessary the signatureToTypes() call smacks of laziness on the behalf of the caller of this method
     public static MemberImpl method(UnresolvedType declaring, int mods, String name, String signature) {
         Object[] pair = signatureToTypes(signature,false);
         return method(declaring, mods, (UnresolvedType) pair[0], name, (UnresolvedType[]) pair[1]);
@@ -250,6 +246,7 @@ public class MemberImpl implements Member {
             name,
             paramTys);
     }
+    
     private static Member pointcut(UnresolvedType declTy, int mods, UnresolvedType rTy, String name, UnresolvedType[] paramTys) {
         return new MemberImpl(
             POINTCUT,
@@ -269,10 +266,6 @@ public class MemberImpl implements Member {
                        "(" + catchType.getSignature() + ")V");
        }
     
-    // ---- parsing methods
-    
-    // ---- things we know without resolution
-    
     public boolean equals(Object other) {
         if (! (other instanceof Member)) return false;
         Member o = (Member) other;
@@ -303,7 +296,6 @@ public class MemberImpl implements Member {
 
      public int compareTo(Object other) {
         Member o = (Member) other;
-
         int i = getName().compareTo(o.getName());
         if (i != 0) return i;
         return getSignature().compareTo(o.getSignature());
@@ -329,38 +321,13 @@ public class MemberImpl implements Member {
        }
        return buf.toString();
     }
-    
-    /* (non-Javadoc)
-        * @see org.aspectj.weaver.Member#toLongString()
-        */
-    public String toLongString() {
-        StringBuffer buf = new StringBuffer();
-        buf.append(kind);
-        buf.append(' ');
-        if (modifiers != 0) {
-            buf.append(Modifier.toString(modifiers));
-            buf.append(' ');
-        }
-        buf.append(toString());
-        buf.append(" <");
-        buf.append(signature);
-        buf.append(" >");
-        return buf.toString();
-    }        
 
-    /* (non-Javadoc)
-        * @see org.aspectj.weaver.Member#getKind()
-        */
     public MemberKind getKind() {
         return kind;
     }
-    /* (non-Javadoc)
-        * @see org.aspectj.weaver.Member#getDeclaringType()
-        */
+
     public UnresolvedType getDeclaringType() { return declaringType; }
-    /* (non-Javadoc)
-        * @see org.aspectj.weaver.Member#getReturnType()
-        */
+
     public UnresolvedType getReturnType() { return returnType; }
     
     public UnresolvedType getGenericReturnType() { return getReturnType(); }
@@ -412,7 +379,7 @@ public class MemberImpl implements Member {
     }    
 
     public final boolean isInterface() {
-        return Modifier.isInterface(modifiers);  // this is kinda weird
+        return Modifier.isInterface(modifiers);
     }    
     
     public final boolean isPrivate() {
@@ -427,13 +394,6 @@ public class MemberImpl implements Member {
                return modifiers;
        }
 
-    public final String getExtractableName() {
-    // OPTIMIZE remove silly string compares for init - use kind==CTOR/STATIC_INITIALIZATION
-       if (name.equals("<init>")) return "init$";
-       else if (name.equals("<clinit>")) return "clinit$";
-       else return name;
-    }
-
        public AnnotationX[] getAnnotations() {
                throw new UnsupportedOperationException("You should resolve this member '"+this+"' and call getAnnotations() on the result...");
        }
@@ -491,247 +451,6 @@ public class MemberImpl implements Member {
                }
        }
 
-       // ---- reflective thisJoinPoint stuff
-    /* (non-Javadoc)
-        * @see org.aspectj.weaver.Member#getSignatureMakerName()
-        */
-    public String getSignatureMakerName() {
-       if (getName().equals("<clinit>")) return "makeInitializerSig";
-       
-       MemberKind kind = getKind();
-       if (kind == METHOD) {
-               return "makeMethodSig";
-       } else if (kind == CONSTRUCTOR) {
-               return "makeConstructorSig";
-       } else if (kind == FIELD) {
-               return "makeFieldSig";
-       } else if (kind == HANDLER) {
-               return "makeCatchClauseSig";
-       } else if (kind == STATIC_INITIALIZATION) {
-               return "makeInitializerSig";
-       } else if (kind == ADVICE) {
-               return "makeAdviceSig";
-       } else if (kind == MONITORENTER) {
-               return "makeLockSig";
-       } else if (kind == MONITOREXIT) {
-               return "makeUnlockSig";
-       } else {
-               throw new RuntimeException("unimplemented");
-       }
-    }
-       
-    
-       public String getSignatureType() {
-       MemberKind kind = getKind();
-       if (getName().equals("<clinit>")) return "org.aspectj.lang.reflect.InitializerSignature";
-       
-       if (kind == METHOD) {
-               return "org.aspectj.lang.reflect.MethodSignature";
-       } else if (kind == CONSTRUCTOR) {
-               return "org.aspectj.lang.reflect.ConstructorSignature";
-       } else if (kind == FIELD) {
-               return "org.aspectj.lang.reflect.FieldSignature";
-       } else if (kind == HANDLER) {
-               return "org.aspectj.lang.reflect.CatchClauseSignature";
-       } else if (kind == STATIC_INITIALIZATION) {
-               return "org.aspectj.lang.reflect.InitializerSignature";
-       } else if (kind == ADVICE) {
-               return "org.aspectj.lang.reflect.AdviceSignature";
-       } else if (kind == MONITORENTER) {
-               return "org.aspectj.lang.reflect.LockSignature";
-       } else if (kind == MONITOREXIT) {
-               return "org.aspectj.lang.reflect.UnlockSignature";
-       } else {
-               throw new RuntimeException("unimplemented");
-       }
-    }
-
-       /* (non-Javadoc)
-        * @see org.aspectj.weaver.Member#getSignatureString(org.aspectj.weaver.World)
-        */
-       public String getSignatureString(World world) {
-               if (getName().equals("<clinit>")) return getStaticInitializationSignatureString(world);
-               
-       MemberKind kind = getKind();
-       if (kind == METHOD) {
-               return getMethodSignatureString(world);
-       } else if (kind == CONSTRUCTOR) {
-               return getConstructorSignatureString(world);
-       } else if (kind == FIELD) {
-               return getFieldSignatureString(world);
-       } else if (kind == HANDLER) {
-               return getHandlerSignatureString(world);
-       } else if (kind == STATIC_INITIALIZATION) {
-               return getStaticInitializationSignatureString(world);
-       } else if (kind == ADVICE) {
-               return getAdviceSignatureString(world);
-       } else if (kind == MONITORENTER || kind == MONITOREXIT) {
-               return getMonitorSignatureString(world);
-       } else {
-               throw new RuntimeException("unimplemented");
-       }
-    }
-
-       private String getHandlerSignatureString(World world) {
-        StringBuffer buf = new StringBuffer();
-        buf.append(makeString(0));
-        buf.append('-');
-        //buf.append(getName());
-        buf.append('-');
-        buf.append(makeString(getDeclaringType()));
-        buf.append('-');
-        buf.append(makeString(getParameterTypes()[0]));
-        buf.append('-');
-        String pName = "<missing>";
-        String[] names = getParameterNames(world);
-        if (names != null) pName = names[0];
-        buf.append(pName);
-        buf.append('-');
-        return buf.toString();
-       }
-       
-       private String getStaticInitializationSignatureString(World world) {
-        StringBuffer buf = new StringBuffer();
-        buf.append(makeString(getModifiers(world)));
-        buf.append('-');
-        //buf.append(getName());
-        buf.append('-');
-        buf.append(makeString(getDeclaringType()));
-        buf.append('-');
-        return buf.toString();
-       }
-
-
-
-       protected String getAdviceSignatureString(World world) {
-        StringBuffer buf = new StringBuffer();
-        buf.append(makeString(getModifiers(world)));
-        buf.append('-');
-        buf.append(getName());
-        buf.append('-');
-        buf.append(makeString(getDeclaringType()));
-        buf.append('-');
-        buf.append(makeString(getParameterTypes()));
-        buf.append('-');
-        buf.append(makeString(getParameterNames(world)));
-        buf.append('-');
-        buf.append(makeString(getExceptions(world)));
-        buf.append('-');
-        buf.append(makeString(getReturnType()));
-        buf.append('-');
-        return buf.toString();
-       }
-
-
-       protected String getMethodSignatureString(World world) {
-        StringBuffer buf = new StringBuffer();
-        buf.append(makeString(getModifiers(world)));
-        buf.append('-');
-        buf.append(getName());
-        buf.append('-');
-        buf.append(makeString(getDeclaringType()));
-        buf.append('-');
-        buf.append(makeString(getParameterTypes()));
-        buf.append('-');
-        buf.append(makeString(getParameterNames(world)));
-        buf.append('-');
-        buf.append(makeString(getExceptions(world)));
-        buf.append('-');
-        buf.append(makeString(getReturnType()));
-        buf.append('-');
-        return buf.toString();
-       }
-       
-       protected String getMonitorSignatureString(World world) {
-        StringBuffer buf = new StringBuffer();
-        buf.append(makeString(Modifier.STATIC));    // modifiers
-        buf.append('-');
-        buf.append(getName());                      // name
-        buf.append('-');
-        buf.append(makeString(getDeclaringType())); // Declaring Type
-        buf.append('-');
-        buf.append(makeString(getParameterTypes()[0])); // Parameter Types
-        buf.append('-');
-        buf.append("");                                 // Parameter names
-        buf.append('-');
-        return buf.toString();
-       }
-       
-
-
-       protected String getConstructorSignatureString(World world) {
-        StringBuffer buf = new StringBuffer();
-        buf.append(makeString(getModifiers(world)));
-        buf.append('-');
-        buf.append('-');
-        buf.append(makeString(getDeclaringType()));
-        buf.append('-');
-        buf.append(makeString(getParameterTypes()));
-        buf.append('-');
-        buf.append(makeString(getParameterNames(world)));
-        buf.append('-');
-        buf.append(makeString(getExceptions(world)));
-        buf.append('-');
-        return buf.toString();
-    }
-       
-       
-
-
-       protected String getFieldSignatureString(World world) {
-        StringBuffer buf = new StringBuffer();
-        buf.append(makeString(getModifiers(world)));
-        buf.append('-');
-        buf.append(getName());
-        buf.append('-');
-        buf.append(makeString(getDeclaringType()));
-        buf.append('-');
-        buf.append(makeString(getReturnType()));
-        buf.append('-');
-        return buf.toString();
-    }
-
-       protected String makeString(int i) {
-               return Integer.toString(i, 16);
-       }
-
-
-
-
-       protected String makeString(UnresolvedType t) {
-       // this is the inverse of the odd behavior for Class.forName w/ arrays
-       if (t.isArray()) {
-               // this behavior matches the string used by the eclipse compiler for Foo.class literals
-               return t.getSignature().replace('/', '.');
-       } else {
-               return t.getName();
-       }
-    }
-    
-
-
-       protected String makeString(UnresolvedType[] types) {
-       if (types == null) return "";
-        StringBuffer buf = new StringBuffer();
-        for (int i = 0, len=types.length; i < len; i++) {
-            buf.append(makeString(types[i]));
-            buf.append(':');
-        }
-        return buf.toString();
-    }
-    
-
-
-       protected String makeString(String[] names) {
-       if (names == null) return "";
-        StringBuffer buf = new StringBuffer();
-        for (int i = 0, len=names.length; i < len; i++) {
-            buf.append(names[i]);
-            buf.append(':');
-        }
-        return buf.toString();
-    }
-
        public String[] getParameterNames(World world) {
        ResolvedMember resolved = resolve(world);
        if (resolved == null) {
index 5aafc27dcfeaa7a42a8dae260b31969f2fae40a9..4cb961bc20f270e0daccfacacd3c2b451a726f95 100644 (file)
@@ -482,7 +482,7 @@ public class BcelShadow extends Shadow {
                        new BcelShadow(
                                world,
                                ConstructorExecution,
-                               world.makeJoinPointSignature(enclosingMethod),
+                               world.makeJoinPointSignatureFromMethod(enclosingMethod,Member.CONSTRUCTOR),
                                enclosingMethod,
                                null);
                ShadowRange r = new ShadowRange(body);
@@ -525,7 +525,7 @@ public class BcelShadow extends Shadow {
             new BcelShadow(
                 world,
                 StaticInitialization,
-                world.makeJoinPointSignature(enclosingMethod),
+                world.makeJoinPointSignatureFromMethod(enclosingMethod,Member.STATIC_INITIALIZATION),
                 enclosingMethod,
                 null);
         ShadowRange r = new ShadowRange(body);
@@ -676,7 +676,7 @@ public class BcelShadow extends Shadow {
                BcelShadow ret =  new BcelShadow(
                        world,
                        Initialization,
-                       world.makeJoinPointSignature(constructor),
+                       world.makeJoinPointSignatureFromMethod(constructor,Member.CONSTRUCTOR),
                        constructor,
                        null);
                if (constructor.getEffectiveSignature() != null) {
@@ -692,10 +692,9 @@ public class BcelShadow extends Shadow {
                BcelShadow ret =  new BcelShadow(
                        world,
                        PreInitialization,
-                       world.makeJoinPointSignature(constructor),
+                       world.makeJoinPointSignatureFromMethod(constructor,Member.CONSTRUCTOR),
                        constructor,
                        null);
-//             ret.fallsThrough = true;
                if (constructor.getEffectiveSignature() != null) {
                        ret.setMatchingSignature(constructor.getEffectiveSignature().getEffectiveSignature());
                }
@@ -755,7 +754,7 @@ public class BcelShadow extends Shadow {
                 null);
         ShadowRange r = new ShadowRange(body);
         r.associateWithShadow(s);
-        r.associateWithTargets(
+        r.associateWithTargets(// OPTIMIZE this occurs lots of times for all jp kinds...
             Range.genStart(body),
             Range.genEnd(body));                  
         return s;
@@ -1292,14 +1291,13 @@ public class BcelShadow extends Shadow {
     public BcelVar getThisJoinPointStaticPartBcelVar(final boolean isEnclosingJp) {
        if (thisJoinPointStaticPartVar == null) {
                Field field = getEnclosingClass().getTjpField(this, isEnclosingJp);
-               
                        ResolvedType sjpType = null;
                if (world.isTargettingAspectJRuntime12()) { // TAG:SUPPORTING12: We didn't have different jpsp types in 1.2     
-                       sjpType = world.getCoreType(UnresolvedType.forName("org.aspectj.lang.JoinPoint$StaticPart"));
+                       sjpType = world.getCoreType(UnresolvedType.JOINPOINT_STATICPART);
                    } else {
                        sjpType = isEnclosingJp?
-                              world.getCoreType(UnresolvedType.forName("org.aspectj.lang.JoinPoint$EnclosingStaticPart")):
-                              world.getCoreType(UnresolvedType.forName("org.aspectj.lang.JoinPoint$StaticPart"));
+                              world.getCoreType(UnresolvedType.JOINPOINT_ENCLOSINGSTATICPART):
+                              world.getCoreType(UnresolvedType.JOINPOINT_STATICPART);
                    }
                    thisJoinPointStaticPartVar = new BcelFieldRef(
                                sjpType,
@@ -1590,27 +1588,27 @@ public class BcelShadow extends Shadow {
        }
        return foundMember.getAnnotationTypes();
     }
-       
+    
+    /**
+     * By determining what "kind" of shadow we are, we can find out the
+        * annotations on the appropriate element (method, field, constructor, type).
+        * Then create one BcelVar entry in the map for each annotation, keyed by
+        * annotation type.
+        */
     public void initializeKindedAnnotationVars() {
        if (kindedAnnotationVars != null) return;
        kindedAnnotationVars = new HashMap();
-       // by determining what "kind" of shadow we are, we can find out the
-       // annotations on the appropriate element (method, field, constructor, type).
-       // Then create one BcelVar entry in the map for each annotation, keyed by
-       // annotation type.
        
        // FIXME asc Refactor this code, there is duplication
        ResolvedType[] annotations = null;
-//     Member relevantMember = getSignature();
        Member shadowSignature = getSignature();
        Member annotationHolder = getSignature();
        ResolvedType  relevantType   = shadowSignature.getDeclaringType().resolve(world);
        
-       if (relevantType.isRawType() || relevantType.isParameterizedType()) relevantType = relevantType.getGenericType();
+       if (relevantType.isRawType() || relevantType.isParameterizedType()) relevantType = relevantType.getGenericType();
 
-       if (getKind() == Shadow.StaticInitialization) {
+       if (getKind() == Shadow.StaticInitialization) {
                annotations  = relevantType.resolve(world).getAnnotationTypes();
-               
        } else if (getKind() == Shadow.MethodCall  || getKind() == Shadow.ConstructorCall) {
             ResolvedMember foundMember = findMethod2(relevantType.resolve(world).getDeclaredMethods(),getSignature());            
             annotations = getAnnotations(foundMember, shadowSignature, relevantType);
@@ -1651,7 +1649,6 @@ public class BcelShadow extends Shadow {
        } else if (getKind() == Shadow.ExceptionHandler) {
                relevantType = getSignature().getParameterTypes()[0].resolve(world);
                annotations  =  relevantType.getAnnotationTypes();
-               
        } else if (getKind() == Shadow.PreInitialization || getKind() == Shadow.Initialization) {
                ResolvedMember found = findMethod2(relevantType.getDeclaredMethods(),getSignature());
                annotations = found.getAnnotationTypes();
@@ -1659,17 +1656,17 @@ public class BcelShadow extends Shadow {
        
        if (annotations == null) {
                // We can't have recognized the shadow - should blow up now to be on the safe side
-               throw new BCException("Couldn't discover annotations for shadow: "+getKind());
+               throw new BCException("Could not discover annotations for shadow: "+getKind());
        }
        
                for (int i = 0; i < annotations.length; i++) {
-                       ResolvedType aTX = annotations[i];
-                       AnnotationAccessVar kaav =  new AnnotationAccessVar(getKind(),aTX.resolve(world),relevantType,annotationHolder);
-               kindedAnnotationVars.put(aTX,kaav);
+                       ResolvedType annotationType = annotations[i];
+                       AnnotationAccessVar accessVar =  new AnnotationAccessVar(getKind(),annotationType.resolve(world),relevantType,annotationHolder);
+               kindedAnnotationVars.put(annotationType,accessVar);
                }
     }
     
-//FIXME asc whats the real diff between this one and the version in findMethod()?
+    //FIXME asc whats the real diff between this one and the version in findMethod()?
         ResolvedMember findMethod2(ResolvedMember rm[], Member sig) {
                ResolvedMember found = null;
                // String searchString = getSignature().getName()+getSignature().getParameterSignature();
@@ -3577,7 +3574,7 @@ public class BcelShadow extends Shadow {
        }
 
        public boolean isFallsThrough() {
-               return !terminatesWithReturn(); //fallsThrough;
+               return !terminatesWithReturn();
        }
 
        public void setActualTargetType(String className) {
index 30916dbd524107c6155ef9f97b63a1e2a38e9964..bb4cc7b32c6f01ea958b2593461bcbbb0f3229b2 100644 (file)
@@ -381,22 +381,6 @@ public class BcelWorld extends World implements Repository {
                                fi.getName(cpg),
                                fi.getSignature(cpg));
     }
-       
-//    public static Member makeFieldSetSignature(LazyClassGen cg, FieldInstruction fi) {
-//     ConstantPoolGen cpg = cg.getConstantPoolGen();
-//        return 
-//            MemberImpl.field(
-//                fi.getClassName(cpg),
-//                (fi instanceof GETSTATIC || fi instanceof PUTSTATIC)
-//                ? Modifier.STATIC
-//                : 0, 
-//                fi.getName(cpg),
-//                "(" + fi.getSignature(cpg) + ")" +fi.getSignature(cpg));
-//    }
-
-       public Member makeJoinPointSignature(LazyMethodGen mg) {
-               return makeJoinPointSignatureFromMethod(mg, null);
-       }
 
        
        public Member makeJoinPointSignatureFromMethod(LazyMethodGen mg, MemberKind kind) {
@@ -406,16 +390,6 @@ public class BcelWorld extends World implements Repository {
                if (mg.getEnclosingClass().isInterface()) {
                    mods |= Modifier.INTERFACE;
                }
-               if (kind == null) {
-                       //OPTIMIZE surely we can pass the kind in and not resort to string compares?
-                       if (mg.getName().equals("<init>")) {
-                               kind = Member.CONSTRUCTOR;
-                       } else if (mg.getName().equals("<clinit>")) {
-                               kind = Member.STATIC_INITIALIZATION;
-                       } else {
-                               kind = Member.METHOD;
-                       }
-               }
                return new ResolvedMemberImpl(kind,
                        UnresolvedType.forName(mg.getClassName()), 
                        mods,
index 2111a300a66c8b7b34fcdc58bff2f650acf5894c..1565cbfc53401a1efa8bce130628b8a6d8730995 100644 (file)
@@ -59,6 +59,7 @@ import org.aspectj.weaver.NameMangler;
 import org.aspectj.weaver.ResolvedMember;
 import org.aspectj.weaver.ResolvedType;
 import org.aspectj.weaver.Shadow;
+import org.aspectj.weaver.SignatureUtils;
 import org.aspectj.weaver.TypeVariable;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.WeaverMessages;
@@ -283,6 +284,9 @@ public final class LazyClassGen {
                        for (int i = 0; i < methods.length; i++) {
                                ResolvedMember method = methods[i];
                                if (method.getName().equals("<clinit>")) {
+                                       if (method.getKind()!=Member.STATIC_INITIALIZATION) {
+                                               throw new RuntimeException("qui?");
+                                       }
                                        hasClinit = true;                                       
                                }
                        }
@@ -649,15 +653,6 @@ public final class LazyClassGen {
 
        private static boolean hasSourceDebugExtensionAttribute(ClassGen gen) {
                return gen.hasAttribute("SourceDebugExtension");
-//             ConstantPool pool = gen.getConstantPool();
-//             Attribute[] attrs = gen.getAttributes();
-//             for (int i = 0; i < attrs.length; i++) {
-//                     if ("SourceDebugExtension"
-//                             .equals(((ConstantUtf8) pool.getConstant(attrs[i].getNameIndex())).getBytes())) {
-//                             return true;
-//                     }
-//             }
-//             return false;
        }
 
     public JavaClass getJavaClass(BcelWorld world) {
@@ -809,6 +804,7 @@ public final class LazyClassGen {
     }
     
     private boolean isEmptyClinit(LazyMethodGen gen) {
+       
        if (!gen.getName().equals("<clinit>")) return false;
        //System.err.println("checking clinig: " + gen);
        InstructionHandle start = gen.getBody().getStart();
@@ -860,6 +856,7 @@ public final class LazyClassGen {
     public LazyMethodGen getStaticInitializer() {
         for (Iterator i = methodGens.iterator(); i.hasNext();) {
             LazyMethodGen gen = (LazyMethodGen) i.next();
+            // OPTIMIZE persist kind of member into the gen object? for clinit
                        if (gen.getName().equals("<clinit>")) return gen;
         } 
         LazyMethodGen clinit = new LazyMethodGen(
@@ -1053,14 +1050,15 @@ public final class LazyClassGen {
        // create the signature
        list.append(InstructionFactory.createLoad(factoryType, 0));
        
+       String signatureMakerName = SignatureUtils.getSignatureMakerName(sig);
+       ObjectType signatureType = new ObjectType(SignatureUtils.getSignatureType(sig));
+       
+       
        if (world.isTargettingAspectJRuntime12()) { // TAG:SUPPORTING12: We didn't have optimized factory methods in 1.2
-               list.append(InstructionFactory.PUSH(getConstantPool(), sig.getSignatureString(shadow.getWorld())));
+               list.append(InstructionFactory.PUSH(getConstantPool(), SignatureUtils.getSignatureString(sig,shadow.getWorld())));
                list.append(fact.createInvoke(factoryType.getClassName(), 
-                                       sig.getSignatureMakerName(),
-                                       new ObjectType(sig.getSignatureType()),
-                                       new Type[] { Type.STRING },
-                                       Constants.INVOKEVIRTUAL));
-       } else  if (sig.getKind().equals(Member.METHOD)) {
+                                       signatureMakerName,signatureType,Type.STRINGARRAY1, Constants.INVOKEVIRTUAL));
+       } else if (sig.getKind().equals(Member.METHOD)) {       
                BcelWorld w = shadow.getWorld();
                // For methods, push the parts of the signature on.
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getModifiers(w))));
@@ -1072,23 +1070,18 @@ public final class LazyClassGen {
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getReturnType())));
                // And generate a call to the variant of makeMethodSig() that takes 7 strings
                list.append(fact.createInvoke(factoryType.getClassName(), 
-                               sig.getSignatureMakerName(),
-                               new ObjectType(sig.getSignatureType()),
+                                       signatureMakerName,signatureType,
                                new Type[] { Type.STRING,Type.STRING,Type.STRING,Type.STRING,Type.STRING,Type.STRING,Type.STRING },
                                Constants.INVOKEVIRTUAL));
            } else if (sig.getKind().equals(Member.MONITORENTER)) {
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getDeclaringType())));
                list.append(fact.createInvoke(factoryType.getClassName(), 
-                               sig.getSignatureMakerName(),
-                               new ObjectType(sig.getSignatureType()),
-                               new Type[] { Type.STRING},
+                                       signatureMakerName,signatureType,Type.STRINGARRAY1,
                                Constants.INVOKEVIRTUAL));
        } else if (sig.getKind().equals(Member.MONITOREXIT)) {
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getDeclaringType())));
                list.append(fact.createInvoke(factoryType.getClassName(), 
-                               sig.getSignatureMakerName(),
-                               new ObjectType(sig.getSignatureType()),
-                               new Type[] { Type.STRING},
+                                       signatureMakerName,signatureType,Type.STRINGARRAY1,
                                Constants.INVOKEVIRTUAL));
        } else if (sig.getKind().equals(Member.HANDLER)) {
                BcelWorld w = shadow.getWorld();
@@ -1096,9 +1089,7 @@ public final class LazyClassGen {
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getParameterTypes())));
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getParameterNames(w))));
                list.append(fact.createInvoke(factoryType.getClassName(),
-                               sig.getSignatureMakerName(),
-                               new ObjectType(sig.getSignatureType()),
-                               new Type[] { Type.STRING, Type.STRING, Type.STRING },
+                                       signatureMakerName,signatureType,Type.STRINGARRAY3,
                                Constants.INVOKEVIRTUAL));      
        } else if(sig.getKind().equals(Member.CONSTRUCTOR)) {
                BcelWorld w = shadow.getWorld();
@@ -1110,9 +1101,7 @@ public final class LazyClassGen {
                        list.append(InstructionFactory.PUSH(getConstantPool(),""));//makeString("")));//sig.getParameterNames(w))));
                        list.append(InstructionFactory.PUSH(getConstantPool(),""));//makeString("")));//sig.getExceptions(w))));
                        list.append(fact.createInvoke(factoryType.getClassName(),
-                                       sig.getSignatureMakerName(),
-                                       new ObjectType(sig.getSignatureType()),
-                                       new Type[] { Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING },
+                                       signatureMakerName,signatureType,Type.STRINGARRAY5,
                                        Constants.INVOKEVIRTUAL));      
                } else {
                        list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getModifiers(w))));        
@@ -1121,9 +1110,7 @@ public final class LazyClassGen {
                        list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getParameterNames(w))));
                        list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getExceptions(w))));
                        list.append(fact.createInvoke(factoryType.getClassName(),
-                                       sig.getSignatureMakerName(),
-                                       new ObjectType(sig.getSignatureType()),
-                                       new Type[] { Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING },
+                                       signatureMakerName,signatureType,Type.STRINGARRAY5,
                                        Constants.INVOKEVIRTUAL));      
                }
        } else if(sig.getKind().equals(Member.FIELD)) {
@@ -1139,9 +1126,7 @@ public final class LazyClassGen {
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(dType)));              
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getReturnType())));
                list.append(fact.createInvoke(factoryType.getClassName(),
-                               sig.getSignatureMakerName(),
-                               new ObjectType(sig.getSignatureType()),
-                               new Type[] { Type.STRING, Type.STRING, Type.STRING, Type.STRING },
+                                       signatureMakerName,signatureType,Type.STRINGARRAY4,
                                Constants.INVOKEVIRTUAL));      
        } else if(sig.getKind().equals(Member.ADVICE)) {
                BcelWorld w = shadow.getWorld();
@@ -1153,8 +1138,7 @@ public final class LazyClassGen {
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getExceptions(w))));
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString((sig.getReturnType()))));              
                list.append(fact.createInvoke(factoryType.getClassName(),
-                               sig.getSignatureMakerName(),
-                               new ObjectType(sig.getSignatureType()),
+                                       signatureMakerName,signatureType,
                                new Type[] { Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING },
                                Constants.INVOKEVIRTUAL));      
        } else if(sig.getKind().equals(Member.STATIC_INITIALIZATION)) {
@@ -1162,16 +1146,12 @@ public final class LazyClassGen {
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getModifiers(w))));
                list.append(InstructionFactory.PUSH(getConstantPool(),makeString(sig.getDeclaringType())));
                list.append(fact.createInvoke(factoryType.getClassName(),
-                               sig.getSignatureMakerName(),
-                               new ObjectType(sig.getSignatureType()),
-                               new Type[] { Type.STRING, Type.STRING },
+                                       signatureMakerName,signatureType,Type.STRINGARRAY2,
                                Constants.INVOKEVIRTUAL));
        } else {
-         list.append(InstructionFactory.PUSH(getConstantPool(), sig.getSignatureString(shadow.getWorld())));
+         list.append(InstructionFactory.PUSH(getConstantPool(), SignatureUtils.getSignatureString(sig,shadow.getWorld())));
          list.append(fact.createInvoke(factoryType.getClassName(), 
-                                  sig.getSignatureMakerName(),
-                                  new ObjectType(sig.getSignatureType()),
-                                  new Type[] { Type.STRING },
+                                       signatureMakerName,signatureType,Type.STRINGARRAY1,
                                   Constants.INVOKEVIRTUAL));
        }