Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] exceptions in around advice

Title: exceptions in around advice
Mark,
 
In some cases, you can convert the exceptions to unchecked ones (ones that extend RuntimeException), which don't have to be declared.
 
Otherwise, I posed this very same question to the list, and ultimately resolved it myself (http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg00599.html, http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg00619.html). In future (when J2SE 1.5 comes and there are generics), you'll be able to write code like this (see http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg00737.html):
static <T extends Throwable> void dynamicThrow(T t) throws T {
    throw t;
}
 
Today, you can use a special bytecode compiled method, dynamicThrow, that can throw potentially undeclared checked exceptions. If you want a binary version that I've already assembled, email me and I'll give it to you.
 
Cheers,
Ron
 
Ron Bodkin
Chief Technology Officer
New Aspects of Security
m: (415) 509-2895
 
 
------------Original Message-------------
From: "Volkmann, Mark" <Mark.Volkmann@xxxxxxxxxxxxx>
To: "'aspectj-users@xxxxxxxxxxx'" <aspectj-users@xxxxxxxxxxx>
Date: Tue, Aug-19-2003 6:08 AM
Subject: [aspectj-users] exceptions in around advice

I've got an around advice that I want to apply to methods that throw different types of exceptions.  If an exception is thrown in the actual method when I call proceed() then I want that exception to propagate back to the caller.  I can't say that advice throws java.lang.Exception because then callers would have to catch that instead of the specific kinds of exceptions that can really be thrown.  How can I get this to work?



---------------------------------------------------------------------------------------------------------
A.G. Edwards & Sons' outgoing and incoming e-mails are electronically
archived and subject to review and/or disclosure to someone other
than the recipient.

---------------------------------------------------------------------------------------------------------

Back to the top