[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Important problem with new limit on declare soft.

From the changes page:

" # 'declare soft: TYPE: POINTCUT;' In 1.0 a TYPE_PATTERN was allowed
rather than a TYPE. This limitation makes declare soft much easier to
implement efficiently."

Unfortunately this gives users no way to soften only checked exceptions. 

Examine this line:

declare soft : Exception : somePcd();

Since RuntimeException subclasses Exception it will be softened as well,
leaving no way to throw your own RuntimeException and have it propagate
normally.  (Avoiding SoftException's obfuscation of the original cause).

I tried getting around this limitation by using a marker interface and got:

Exception in thread "main" java.lang.VerifyError: (class: simple/Except,
method: <clinit> signature: ()V) catch_type not a subclass of Throwable

Though I'm sure this bug will be fixed, it suggests that there may be no
way to use marker interfaces either.

Does anyone else think that this is an important limitation? 

Cheers,
nick

Here's my class (I've already submitted the bug).


public class Except {

    public static void a(){
        b();
    }
    /**
     * Method b.
     */
    private static void b() {
        throw new RuntimeException("Orig");
    }
    
    public static void main(String[] args) {
        try {
            a();
        } catch (SoftException e) {
            System.out.println(e.getWrappedThrowable());
        }
    }
    
    public static interface Checked{
    }
    
    static aspect Softner{
        declare parents : Exception+ && !RuntimeException implements
Checked;
        declare soft : Checked : within(Except);
    }
}
__________________________________________________
Video Attachment
Lesiecki Nicholas has sent you a video.
Please go to
http://mediaframe.yahoo.com/mf/spotlife/o?.auth=38RcrNf7pyXQ4uJgyZWR4w--&id=
to view the video.
__________________________________________________


=====


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com