]> source.dussan.org Git - aspectj.git/commitdiff
More 'cant find types' improved.
authoraclement <aclement>
Mon, 23 Aug 2004 10:25:37 +0000 (10:25 +0000)
committeraclement <aclement>
Mon, 23 Aug 2004 10:25:37 +0000 (10:25 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java
weaver/src/org/aspectj/weaver/WeaverMessages.java
weaver/src/org/aspectj/weaver/World.java
weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
weaver/src/org/aspectj/weaver/weaver-messages.properties

index cbfbc0c0421d4c2a27c103956e46d8252338f422..954a20f0a8b48bb37de46c78c09f5f3ec1597473 100644 (file)
@@ -233,9 +233,11 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration {
                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);
@@ -244,7 +246,7 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration {
                        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);
index c8351b5f71e14afd5f02e9bc417d6ecb9989bb56..df2f90376eb5649ad2ae7864e64591eb6de32030 100644 (file)
@@ -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";
index 479a40c920ae57951f0a45fd93d449202c1bcc3b..071af0678d662bb0b071787b56c156b64174a588 100644 (file)
@@ -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);
     }
index 7de8671687e37f165ddd42a40b5d656ffdb6ff88..76589720f63b86bbfe19ac9d0e69695fe54971d0 100644 (file)
@@ -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);
                        }
index 83b179643eef54a5ad36f11a49c35857b331b30b..a824e84d2a6b3e30031a2ee6b9a3c0a8189d7ef2 100644 (file)
@@ -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())) {
index 6b65417580027879ca685a5f6cdce2d940bbe8fa..179684bc33762a9fc8e0e71a675768a794b9ef58 100644 (file)
@@ -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 {
index 128016fb2efbaaf36a4d2f132af8ead9a2716b6c..97a7e754d5f9c1a8bcadcad5831de09e315a74a0 100644 (file)
@@ -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)