codeStream.initializeMaxLocals(binding);
if (isGetter) {
if (onTypeBinding.isInterface()) {
+ TypeX declaringTX = sig.getDeclaringType();
+ ResolvedTypeX declaringRTX = world.getWorld().resolve(declaringTX,munger.getSourceLocation());
MethodBinding readMethod = world.makeMethodBinding(
AjcMemberMaker.interFieldInterfaceGetter(
- sig, world.getWorld().resolve(sig.getDeclaringType()), aspectType));
+ sig, declaringRTX, aspectType));
generateInterfaceReadBody(binding, readMethod, codeStream);
} else {
generateClassReadBody(binding, classField, codeStream);
if (onTypeBinding.isInterface()) {
MethodBinding writeMethod = world.makeMethodBinding(
AjcMemberMaker.interFieldInterfaceSetter(
- sig, world.getWorld().resolve(sig.getDeclaringType()), aspectType));
+ sig, world.getWorld().resolve(sig.getDeclaringType(),munger.getSourceLocation()), aspectType));
generateInterfaceWriteBody(binding, writeMethod, codeStream);
} else {
generateClassWriteBody(binding, classField, codeStream);
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";
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;
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);
}
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;
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;
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);
}
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) {
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())) {
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())) {
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 {
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)