[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Exception Handling
|
Tim,
Is your primary concern empty catch
blocks that people write solely to satisfy the compiler? Unfortunately
you cannot target these directly i.e. identify exception handlers that
contain no logic. Also, as Ron points out, because you can only use before()
advice with the handler join point (because of a well documented byte-code
restriction https://bugs.eclipse.org/bugs/show_bug.cgi?id=33636) you will
always override any existing logic if you throw a new RuntimeException.
However you _can_ target catch blocks for Exception, rather than a specific
subclass e.g. IOException, which is considered bad programming practice:
public aspect Aspect {
before
() : handler(Exception) {
System.err.println("Aspect.before1()
" + thisJoinPoint);
}
}
Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester, SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/
Please respond to aspectj-users@xxxxxxxxxxx
Sent by:
aspectj-users-bounces@xxxxxxxxxxx
To:
aspectj-users@xxxxxxxxxxx
cc:
Subject:
[aspectj-users]
Exception Handling
Is it possible to advice methods that "eat"
exceptions so that they always throw a runtime exception. For example:
public void someMethod() {
try {
someMethodThrowsCheckedException();
}
catch(Exception e) { /* do absolutely nothing */ }
I would like to advise this method, without modifying the siganture, to
throw an unchecked exception when "Exception" is thrown
Thanks in advance
Tim McNamara
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users