]> source.dussan.org Git - aspectj.git/commitdiff
Adjust from nasty exception to messages
authorAndy Clement <aclement@pivotal.io>
Thu, 8 Dec 2016 16:43:16 +0000 (08:43 -0800)
committerAndy Clement <aclement@pivotal.io>
Thu, 8 Dec 2016 16:43:16 +0000 (08:43 -0800)
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java

index e3e97517a758bfb4dbf9ad7532a0557112a17dc5..d534405daccc9b72f00c348a5b4be79078e28a18 100644 (file)
@@ -215,12 +215,15 @@ public class BcelWeaver {
                        }
                        return type;
                } else {
-                       // FIXME AV - better warning upon no such aspect from aop.xml
-                       RuntimeException ex = new RuntimeException("Cannot register non aspect: " + type.getName() + " , " + aspectName);
-                       if (trace.isTraceEnabled()) {
-                               trace.exit("addLibraryAspect", ex);
-                       }
-                       throw ex;
+                       if (type.isMissing()) {
+                               // May not be found if not visible to the classloader that can see the aop.xml during LTW
+                               IMessage message = new Message("The specified aspect '"+aspectName+"' cannot be found", null, true);
+                               world.getMessageHandler().handleMessage(message);
+                       } else {
+                               IMessage message = new Message("Cannot register '"+aspectName+"' because the type found with that name is not an aspect", null, true);
+                               world.getMessageHandler().handleMessage(message);
+                       }                               
+                       return null;
                }
        }