Summary: | before():execution(new(..)) does not throw NoAspectBoundException | ||
---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Rafael Chaves <chaves> |
Component: | Compiler | Assignee: | Jim Hugunin <jim-aj> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | wes |
Version: | unspecified | ||
Target Milestone: | 1.2 | ||
Hardware: | PC | ||
OS: | Linux | ||
Whiteboard: |
Description
Rafael Chaves
2003-03-08 14:23:07 EST
The modified aspect: aspect Watchcall { pointcut myConstructor(): execution(new(..)); before(): myConstructor() { System.err.println("Entering Constructor"); } after(): myConstructor() { System.err.println("Leaving Constructor"); } } The Java class (unchanged): public class Client { public static void main(String[] args) { Client c = new Client(); } } The error stack trace: Exception in thread "main" java.lang.NoClassDefFoundError at Client.<init>(Client.java:1) at Client.main(Client.java:4) This behavior was easily verified. Thanks for the simple test case. I'm unsure what the correct resolution is. The problem is a standard one with after advice. Because after advice will run even in the presence of exceptions, it can lead to confusing behavior in the same way that try/finally can. See the FAQ entry on "When I run, I get a StackOverflowError (or a long stack trace or no output whatsoever)" for more information on a different manifestation of this same issue. My recommendation in the short-term is to use after returning advice instead of after advice whenever possible to avoid these confusions. For the longer term this might merit discusion on the aspectj-dev list. *** Bug 37256 has been marked as a duplicate of this bug. *** Finally fixed! All exceptions that occur during the static intialization of a persingleton aspect will be swallowed. When using that aspect (via aspectOf()) a NoAspectBoundException will be thrown with the original exception from the staitc initializer as the cause. |