summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2004-08-06 14:09:24 +0000
committeraclement <aclement>2004-08-06 14:09:24 +0000
commit30df47dcff68326f5d90ff66023b375b90f5a5d1 (patch)
treec61925bfafaa8e22b84125998adbb68af9de8707
parent85e825b8b6287a7e4c058c664a2a8d685780527e (diff)
downloadaspectj-30df47dcff68326f5d90ff66023b375b90f5a5d1.tar.gz
aspectj-30df47dcff68326f5d90ff66023b375b90f5a5d1.zip
Starting the quest to rid the world of unhelpful 'cant find type' messages... around 15down...
-rw-r--r--weaver/src/org/aspectj/weaver/WeaverMessages.java1
-rw-r--r--weaver/src/org/aspectj/weaver/World.java9
-rw-r--r--weaver/src/org/aspectj/weaver/weaver-messages.properties1
-rw-r--r--weaver/testsrc/org/aspectj/weaver/AbstractWorldTestCase.java16
-rw-r--r--weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java1
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java5
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java9
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java9
8 files changed, 39 insertions, 12 deletions
diff --git a/weaver/src/org/aspectj/weaver/WeaverMessages.java b/weaver/src/org/aspectj/weaver/WeaverMessages.java
index f04e6a818..e45c96a67 100644
--- a/weaver/src/org/aspectj/weaver/WeaverMessages.java
+++ b/weaver/src/org/aspectj/weaver/WeaverMessages.java
@@ -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";
diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java
index 90fde5320..479a40c92 100644
--- a/weaver/src/org/aspectj/weaver/World.java
+++ b/weaver/src/org/aspectj/weaver/World.java
@@ -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());
diff --git a/weaver/src/org/aspectj/weaver/weaver-messages.properties b/weaver/src/org/aspectj/weaver/weaver-messages.properties
index d89b3d2e2..a4879342e 100644
--- a/weaver/src/org/aspectj/weaver/weaver-messages.properties
+++ b/weaver/src/org/aspectj/weaver/weaver-messages.properties
@@ -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)
diff --git a/weaver/testsrc/org/aspectj/weaver/AbstractWorldTestCase.java b/weaver/testsrc/org/aspectj/weaver/AbstractWorldTestCase.java
index cd1cbf479..5a5121f25 100644
--- a/weaver/testsrc/org/aspectj/weaver/AbstractWorldTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/AbstractWorldTestCase.java
@@ -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);
diff --git a/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java b/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java
index 19b364792..3219b2f15 100644
--- a/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java
@@ -121,4 +121,5 @@ public class TypeXTestCase extends TestCase {
}
}
+
}
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java
index 6bfb2a3b5..ee45c1045 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java
@@ -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);
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java
index 620f79e08..5ed38ae8b 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java
@@ -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}));
}
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java
index 7fe8f84c9..d48c7cac4 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java
@@ -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);