]> source.dussan.org Git - aspectj.git/commitdiff
Starting the quest to rid the world of unhelpful 'cant find type' messages... around...
authoraclement <aclement>
Fri, 6 Aug 2004 14:09:24 +0000 (14:09 +0000)
committeraclement <aclement>
Fri, 6 Aug 2004 14:09:24 +0000 (14:09 +0000)
weaver/src/org/aspectj/weaver/WeaverMessages.java
weaver/src/org/aspectj/weaver/World.java
weaver/src/org/aspectj/weaver/weaver-messages.properties
weaver/testsrc/org/aspectj/weaver/AbstractWorldTestCase.java
weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java
weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java
weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java
weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java

index f04e6a818309b7440eee1091c032d4b5bedcff6c..e45c96a673f37bd8c366c8379025714081e77907 100644 (file)
@@ -70,6 +70,7 @@ public class WeaverMessages {
        public static final String ASPECT_NEEDED = "aspectNeeded";
        
        public static final String CANT_FIND_TYPE = "cantFindType";
+       public static final String CANT_FIND_CORE_TYPE = "cantFindCoreType";
        
        public static final String DECP_BINARY_LIMITATION = "decpBinaryLimitation";
        public static final String OVERWRITE_JSR45 = "overwriteJSR45";
index 90fde53206b2fa9ea2ffc2b03dc4b72b41bb5d70..479a40c920ae57951f0a45fd93d449202c1bcc3b 100644 (file)
@@ -69,6 +69,15 @@ public abstract class World {
     public ResolvedTypeX resolve(TypeX ty) {
        return resolve(ty, false);
     }
+    
+    public ResolvedTypeX getCoreType(TypeX tx) {
+       ResolvedTypeX coreTy = resolve(tx,true);
+       if (coreTy == ResolvedTypeX.MISSING) {
+                MessageUtil.error(messageHandler, 
+               WeaverMessages.format(WeaverMessages.CANT_FIND_CORE_TYPE,tx.getName()));
+       }
+       return coreTy;
+    }
 
     public ResolvedTypeX resolve(TypeX ty, boolean allowMissing) {
        //System.out.println("resolve: " + ty + " world " + typeMap.keySet());
index d89b3d2e23b7402addbb725907f7ffdbeaca38b2..a4879342e64edc1775f2c2703bb4776a8a754c07 100644 (file)
@@ -72,6 +72,7 @@ aspectNeeded=aspect {0} is needed when using type {1}
 
 # The infamous and deserving a category all of its own...
 cantFindType=can''t find type {0}
+cantFindCoreType=can''t find critical required type {0}
 
 # Implementation limitations...
 decpBinaryLimitation=can''t use declare parents to change superclass of binary form ''{0}'' (implementation limitation)
index cd1cbf4799f18e4a28ca9517e9519cd85ab4f3d4..5a5121f255dc1bbd8f2a7c38f0fc18dd9c6b50fc 100644 (file)
@@ -76,7 +76,9 @@ public abstract class AbstractWorldTestCase extends TestCase {
     }
     private void primAssignTest(String sig, String[] lowers) {
        ResolvedTypeX[] primitives = getWorld().resolve(primitiveTypeXs);
-        ResolvedTypeX ty = getWorld().resolve(TypeX.forSignature(sig));
+       TypeX tx = TypeX.forSignature(sig);
+        ResolvedTypeX ty = getWorld().resolve(tx,true);
+        assertTrue("Couldnt find type "+tx,ty!=ResolvedTypeX.MISSING);
         ResolvedTypeX[] lowerTyArray = 
             getWorld().resolve(TypeX.forSignatures(lowers));
         List lowerTys = new ArrayList(Arrays.asList(lowerTyArray));
@@ -99,13 +101,15 @@ public abstract class AbstractWorldTestCase extends TestCase {
        ResolvedTypeX[] primitives = getWorld().resolve(primitiveTypeXs);
         for(int i = 0, len = primitives.length; i < len; i++) {
             ResolvedTypeX ty = primitives[i];
-            ResolvedTypeX aty = getWorld().resolve(TypeX.forSignature("[" + ty.getSignature()));
+            TypeX tx = TypeX.forSignature("["+ty.getSignature());
+            ResolvedTypeX aty = getWorld().resolve(tx,true);
+            assertTrue("Couldnt find type "+tx,aty!=ResolvedTypeX.MISSING);
             modifiersTest(aty, Modifier.PUBLIC | Modifier.FINAL);
             fieldsTest(aty, ResolvedMember.NONE);
             methodsTest(aty, ResolvedMember.NONE);
             interfacesTest(aty, new ResolvedTypeX[] {
-                                    getWorld().resolve(TypeX.CLONEABLE),
-                                    getWorld().resolve(TypeX.SERIALIZABLE) });
+                                    getWorld().getCoreType(TypeX.CLONEABLE),
+                                    getWorld().getCoreType(TypeX.SERIALIZABLE) });
             superclassTest(aty, TypeX.OBJECT);
 
             pointcutsTest(aty, ResolvedMember.NONE);
@@ -115,7 +119,9 @@ public abstract class AbstractWorldTestCase extends TestCase {
             for (int j = 0; j < len; j++) {
                 ResolvedTypeX ty1 = primitives[j];
                 isCoerceableFromTest(aty, ty1, false);
-                ResolvedTypeX aty1 = getWorld().resolve(TypeX.forSignature("[" + ty1.getSignature()));  
+                tx = TypeX.forSignature("[" + ty1.getSignature());
+                ResolvedTypeX aty1 = getWorld().resolve(tx,true);
+                assertTrue("Couldnt find type "+tx,aty1!=ResolvedTypeX.MISSING);
                 if (ty.equals(ty1)) {
                     isCoerceableFromTest(aty, aty1, true);
                     isAssignableFromTest(aty, aty1, true);
index 19b3647928d7e7dcfdb1defdcc49176ba304d93b..3219b2f150d05e42891b6904941b17fbf14462ce 100644 (file)
@@ -121,4 +121,5 @@ public class TypeXTestCase extends TestCase {
         }
     }
     
+    
 }
index 6bfb2a3b5dc75808ae60817d4b9ef59e298dfe64..ee45c104529eff807b2c48fafe9c51d463fbcbea 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.bcel.generic.InstructionList;
 import org.apache.bcel.generic.Type;
 import org.aspectj.weaver.AdviceKind;
 import org.aspectj.weaver.Member;
+import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.TypeX;
 
@@ -99,9 +100,11 @@ public class ArgsWeaveTestCase extends WeaveTestCase {
        }
     
     private BcelAdvice makeArgsMunger(final String kindx) {
+       ResolvedTypeX rtx = world.resolve(TypeX.forName("Aspect"),true);
+       assertTrue("Cant find required type Aspect",rtx!=ResolvedTypeX.MISSING);
         return new BcelAdvice(AdviceKind.stringToKind(kindx), makePointcutNoZeroArg(),
                                Member.method(TypeX.forName("Aspect"), 0, "foo", "()V"), 0, -1, -1, null,
-                               world.resolve(TypeX.forName("Aspect"))) {
+                               rtx) {
             public void specializeOn(Shadow shadow) {
                 super.specializeOn(shadow);
                 shadow.getArgVar(0);
index 620f79e08f3e4843abdf66a400ad19b68520743c..5ed38ae8be9a486c4c7f376a8dc1863c6432be21 100644 (file)
@@ -16,9 +16,12 @@ package org.aspectj.weaver.bcel;
 import java.io.IOException;
 import java.util.Arrays;
 
+import javax.print.attribute.ResolutionSyntax;
+
 import org.aspectj.weaver.Advice;
 import org.aspectj.weaver.AdviceKind;
 import org.aspectj.weaver.Member;
+import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.TypeX;
 
 public class TjpWeaveTestCase extends WeaveTestCase {
@@ -74,19 +77,21 @@ public class TjpWeaveTestCase extends WeaveTestCase {
     } 
 
     public void testAround2Tjp() throws IOException {
+       ResolvedTypeX rtx = world.resolve(TypeX.forName("Aspect"),true);
+       assertTrue("Couldnt find type Aspect",rtx!=ResolvedTypeX.MISSING);
        BcelAdvice munger1 = new BcelAdvice(
                AdviceKind.stringToKind("around"),
                makePointcutAll(), 
                Member.methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"),
                Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null, 
-               world.resolve(TypeX.forName("Aspect")));
+               rtx);
        
        BcelAdvice munger2 = new BcelAdvice(
                AdviceKind.stringToKind("around"),
                makePointcutAll(), 
                Member.methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"),
                Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null, 
-               world.resolve(TypeX.forName("Aspect")));
+               rtx);
        
         weaveTest("HelloWorld", "TjpAround2HelloWorld", Arrays.asList(new BcelAdvice[] {munger1, munger2}));
     } 
index 7fe8f84c910c88218f22b81d8b600394d93bf55e..d48c7cac4dee66642eb1ed66224b8b6e86a84331 100644 (file)
@@ -35,8 +35,8 @@ public class WorldTestCase extends AbstractWorldTestCase {
 
        // XXX fix the various XXXs before expecting this test to work
     public void xtestTraceJar() {
-        ResolvedTypeX trace = world.resolve(TypeX.forName("Trace"));
-
+        ResolvedTypeX trace = world.resolve(TypeX.forName("Trace"),true);
+        assertTrue("Couldnt find type Trace",trace!=ResolvedTypeX.MISSING);
         fieldsTest(trace, Member.NONE);
         /*Member constr = */Member.methodFromString("void Trace.<init>()"); 
         //XXX need attribute fix - 
@@ -68,7 +68,8 @@ public class WorldTestCase extends AbstractWorldTestCase {
                                                Advice.ExtraArgument),
             });
         
-        ResolvedTypeX myTrace = world.resolve(TypeX.forName("MyTrace"));
+        ResolvedTypeX myTrace = world.resolve(TypeX.forName("MyTrace"),true);
+        assertTrue("Couldnt find type MyTrace",myTrace!=ResolvedTypeX.MISSING);
 
         interfacesTest(myTrace, ResolvedTypeX.NONE);
         superclassTest(myTrace, trace);
@@ -95,7 +96,7 @@ public class WorldTestCase extends AbstractWorldTestCase {
 
     public void testIterator() {
         int abstractPublic = Modifier.ABSTRACT | Modifier.PUBLIC;
-        ResolvedTypeX iter = world.resolve(TypeX.forName("java.util.Iterator"));
+        ResolvedTypeX iter = world.getCoreType(TypeX.forName("java.util.Iterator"));
       
         modifiersTest(iter, abstractPublic | Modifier.INTERFACE);
         fieldsTest(iter, ResolvedMember.NONE);