]> source.dussan.org Git - aspectj.git/commitdiff
fix for 152848: cope with discovering a non-generic type
authoraclement <aclement>
Fri, 25 Aug 2006 12:40:55 +0000 (12:40 +0000)
committeraclement <aclement>
Fri, 25 Aug 2006 12:40:55 +0000 (12:40 +0000)
weaver/src/org/aspectj/weaver/TypeFactory.java
weaver/src/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXConverter.java

index f0d143d8fea43b21c1850c56cbdbb90e26fa69fe..23e5bd41f8235beac08deb2cda7cbd20f8a9df9b 100644 (file)
@@ -39,7 +39,7 @@ public class TypeFactory {
                if (!aBaseType.isGenericType()) {
                        // try and find the generic type...
                        if (someTypeParameters != null && someTypeParameters.length>0) {
-                               if (!aBaseType.isRawType()) throw new IllegalStateException("Expecting raw type");
+                               if (!aBaseType.isRawType()) throw new IllegalStateException("Expecting raw type, not: "+aBaseType);
                                baseType = baseType.getGenericType();
                                if (baseType == null) throw new IllegalStateException("Raw type does not have generic type set");
                        } // else if someTypeParameters is null, then the base type is allowed to be non-generic, it's an inner
index dbe499fd1d8742993d8b2dcb45cba6f0ca563173..082dccfdc2d0b1a68ee65046657110cc7ae97ea0 100644 (file)
@@ -24,6 +24,8 @@ import org.aspectj.weaver.TypeVariable;
 import org.aspectj.weaver.TypeVariableReferenceType;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.World;
+import org.aspectj.weaver.tools.Trace;
+import org.aspectj.weaver.tools.TraceFactory;
 
 /**
  * A utility class that assists in unpacking constituent parts of 
@@ -32,6 +34,8 @@ import org.aspectj.weaver.World;
  */
 public class BcelGenericSignatureToTypeXConverter {
 
+       private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelGenericSignatureToTypeXConverter.class);
+       
        public static ResolvedType classTypeSignature2TypeX(
                        Signature.ClassTypeSignature aClassTypeSignature,
                        Signature.FormalTypeParameter[] typeParams,
@@ -75,6 +79,16 @@ public class BcelGenericSignatureToTypeXConverter {
                        // we have to create a parameterized type
                        // type arguments may be array types, class types, or typevariable types
                        ResolvedType theBaseType = UnresolvedType.forSignature(sig.toString()).resolve(world);
+                       
+                       // Sometimes we may find that when the code is being load-time woven that the types have changed.
+                       // Perhaps an old form of a library jar is being used - this can mean we discover right here
+                       // that a type is not parameterizable (is that a word?).  I think in these cases it is ok to
+                       // just return with what we know (the base type). (see pr152848)
+                       if (!(theBaseType.isGenericType() || theBaseType.isRawType())) {
+                               if (trace.isTraceEnabled()) trace.event("classTypeSignature2TypeX: this type is not a generic type:",null,new Object[]{theBaseType});
+                               return theBaseType;
+                       }
+                       
                        ResolvedType[] typeArgumentTypes = new ResolvedType[innerType.typeArguments.length];
                        for (int i = 0; i < typeArgumentTypes.length; i++) {
                                typeArgumentTypes[i] = typeArgument2TypeX(innerType.typeArguments[i],typeParams,world,inProgressTypeVariableResolutions);
@@ -84,7 +98,6 @@ public class BcelGenericSignatureToTypeXConverter {
                                                                        theBaseType,
                                                                        typeArgumentTypes,
                                                                        world);
-                               
                        
 //                             world.resolve(UnresolvedType.forParameterizedTypes(
 //                                             UnresolvedType.forSignature(sig.toString()).resolve(world),