diff options
author | aclement <aclement> | 2004-08-23 10:25:37 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-08-23 10:25:37 +0000 |
commit | d0be7b851b7bcedce43ab31cc307f44ebf0a2f2e (patch) | |
tree | 6d01cc289069d82a6cd81ba76942be31eec9346e /weaver | |
parent | eed1b054c9c27d6d112e9e66de290dd5f6188f47 (diff) | |
download | aspectj-d0be7b851b7bcedce43ab31cc307f44ebf0a2f2e.tar.gz aspectj-d0be7b851b7bcedce43ab31cc307f44ebf0a2f2e.zip |
More 'cant find types' improved.
Diffstat (limited to 'weaver')
6 files changed, 44 insertions, 6 deletions
diff --git a/weaver/src/org/aspectj/weaver/WeaverMessages.java b/weaver/src/org/aspectj/weaver/WeaverMessages.java index c8351b5f7..df2f90376 100644 --- a/weaver/src/org/aspectj/weaver/WeaverMessages.java +++ b/weaver/src/org/aspectj/weaver/WeaverMessages.java @@ -75,7 +75,8 @@ public class WeaverMessages { public static final String CANT_FIND_TYPE_WITHINPCD = "cantFindTypeWithinpcd"; public static final String CANT_FIND_TYPE_DURING_AROUND_WEAVE = "cftDuringAroundWeave"; public static final String CANT_FIND_TYPE_DURING_AROUND_WEAVE_PREINIT = "cftDuringAroundWeavePreinit"; - + public static final String CANT_FIND_TYPE_EXCEPTION_TYPE = "cftExceptionType"; + public static final String CANT_FIND_TYPE_ARG_TYPE = "cftArgType"; 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 479a40c92..071af0678 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.WeakHashMap; import org.aspectj.asm.IHierarchy; +import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessageHandler; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.Message; @@ -66,6 +67,25 @@ public abstract class World { return ret; } + /** + * Attempt to resolve a type - the source location gives you some context in which + * resolution is taking place. In the case of an error where we can't find the + * type - we can then at least report why (source location) we were trying to resolve it. + */ + public ResolvedTypeX resolve(TypeX ty,ISourceLocation isl) { + ResolvedTypeX ret = resolve(ty,true); + if (ty == ResolvedTypeX.MISSING) { + IMessage msg = null; + if (isl!=null) { + msg = MessageUtil.error(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE,ty.getName()),isl); + } else { + msg = MessageUtil.error(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE,ty.getName())); + } + messageHandler.handleMessage(msg); + } + return ret; + } + public ResolvedTypeX resolve(TypeX ty) { return resolve(ty, false); } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java index 7de867168..76589720f 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java @@ -20,6 +20,8 @@ import java.util.Collections; import org.aspectj.apache.bcel.generic.InstructionFactory; import org.aspectj.apache.bcel.generic.InstructionHandle; import org.aspectj.apache.bcel.generic.InstructionList; +import org.aspectj.bridge.IMessage; +import org.aspectj.bridge.Message; import org.aspectj.weaver.Advice; import org.aspectj.weaver.AdviceKind; import org.aspectj.weaver.AjAttribute; @@ -30,6 +32,7 @@ import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.World; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -173,7 +176,13 @@ public class BcelAdvice extends Advice { ResolvedTypeX error = world.getCoreType(TypeX.ERROR); for (int i=0, len=excs.length; i < len; i++) { - ResolvedTypeX t = world.resolve(excs[i]); + ResolvedTypeX t = world.resolve(excs[i],true); + if (t == ResolvedTypeX.MISSING) { + IMessage msg = new Message( + WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_EXCEPTION_TYPE,excs[i].getName()), + "",IMessage.ERROR,getSourceLocation(),null,null); + world.getMessageHandler().handleMessage(msg); + } if (!(runtimeException.isAssignableFrom(t) || error.isAssignableFrom(t))) { ret.add(t); } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index 83b179643..a824e84d2 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -154,7 +154,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { LazyClassGen gen = weaver.getLazyClassGen(); ResolvedMember member = munger.getMember(); - ResolvedTypeX onType = weaver.getWorld().resolve(member.getDeclaringType()); + ResolvedTypeX onType = weaver.getWorld().resolve(member.getDeclaringType(),munger.getSourceLocation()); //System.out.println("munging: " + gen + " with " + member); if (onType.equals(gen.getType())) { if (member.getKind() == Member.FIELD) { @@ -376,7 +376,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { LazyClassGen gen = weaver.getLazyClassGen(); - ResolvedTypeX onType = weaver.getWorld().resolve(signature.getDeclaringType()); + ResolvedTypeX onType = weaver.getWorld().resolve(signature.getDeclaringType(),munger.getSourceLocation()); boolean onInterface = onType.isInterface(); if (onType.equals(gen.getType())) { @@ -652,7 +652,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { ResolvedMember field = munger.getSignature(); - ResolvedTypeX onType = weaver.getWorld().resolve(field.getDeclaringType()); + ResolvedTypeX onType = weaver.getWorld().resolve(field.getDeclaringType(),munger.getSourceLocation()); boolean onInterface = onType.isInterface(); if (onType.equals(gen.getType())) { diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java index 6b6541758..179684bc3 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java @@ -163,7 +163,13 @@ public class ArgsPointcut extends NameBindingPointcut { TypeX argType = shadow.getArgType(i); TypePattern type = patterns[i]; if (!(type instanceof BindingTypePattern)) { - if (type.matchesInstanceof(shadow.getIWorld().resolve(argType)).alwaysTrue()) { + ResolvedTypeX argRTX = shadow.getIWorld().resolve(argType,true); + if (argRTX == ResolvedTypeX.MISSING) { + IMessage msg = new Message( + WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_ARG_TYPE,argType.getName()), + "",IMessage.ERROR,shadow.getSourceLocation(),null,new ISourceLocation[]{getSourceLocation()}); + } + if (type.matchesInstanceof(argRTX).alwaysTrue()) { continue; } } else { diff --git a/weaver/src/org/aspectj/weaver/weaver-messages.properties b/weaver/src/org/aspectj/weaver/weaver-messages.properties index 128016fb2..97a7e754d 100644 --- a/weaver/src/org/aspectj/weaver/weaver-messages.properties +++ b/weaver/src/org/aspectj/weaver/weaver-messages.properties @@ -78,6 +78,8 @@ cantFindCoreType=can''t find critical required type {0} cantFindTypeWithinpcd=Unable to find type {0} whilst processing within() pointcut at this source location cftDuringAroundWeave=Can't find type {0} whilst applying around advice cftDuringAroundWeavePreinit=Can't find type {0} whilst applying around advice to preinitialization join point +cftExceptionType=Can't find exception type {0} whilst processing advice +cftArgType=Can't find type {0} whilst processing args() pcd # Implementation limitations... decpBinaryLimitation=can''t use declare parents to change superclass of binary form ''{0}'' (implementation limitation) |