[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-dev] Fature request: User-specifiable exception in "declare soft"

This very cool & neat idea.
As long as the Exception "must" not be a child of the org.aspectj.lang.SoftException it can be very clean !


Ramnivas Laddad <ramnivas@xxxxxxxxx> wrote:

>This is filed in bugzilla for tracking purpose:
>Posting here for discussion purpose...
>Here is a feature request to enhance the "declare soft" construct in
>a fully backward compatible way.
>Currently, the "declare soft" construct is used to soften a checked
>exception by throwing an org.aspectj.lang.SoftException wrapping in
>original exception. I will like the possibility of specifying a
>user-specifiable runtime exception. I intend to use such a feature to
>specify a concern-specific runtime exception while softening. This
>simple change will help in multiple ways. Here are a few: 
>1. The exception call stack will be clearer. I will now have an
>   indication of the concern involved by just looking at name of the
>   exception thrown.
>2. I can catch specific runtime exception at some higher level to
>   process it in the most meaningful way. Currently, I need to trap the
>   generic SoftException and examine the cause (using getCause()) to
>   check if the checked exception needs to be handled.
>As it stands now, I almost never use "declare soft" by
>itself. Typically, I wrap the checked exceptions in question in a
>concern-specific runtime exception and use a "declare soft" to avoid
>exception-related compiler errors. A feature to easily support this
>idiom will make the code easy to understand and explain.
>Possible syntax: declare soft: <Exception to be softened> : <Pointcut>
>                            [: <Runtime Exception>];
>For example:
>declare soft: RemoteException
>            : call(* PaymentService. *(..) throws RemoteException)
>            : RemoteRuntimeException;
>declare soft: SystemException
>            : call(* *.*(..) throws SystemException)
>            : TransactionRuntimeException;
>When the last part ([: <Runtime Exception>]) is omitted, we could
>default to the current behavior, hence maintaining backward
>The runtime exception specified must have a way to set the wrapped
>exception. This is not a problem for JDK1.4+ as initCause() can always
>be used. For the earlier JDKs, we could require that the runtime
>exception specified must have the "initCuase(Throwable)" method.
>Do you Yahoo!?
>The New Yahoo! Shopping - with improved product search
>aspectj-dev mailing list

Thomas SMETS 
rue J. Wytsmanstraat 62
1050 Brussels

McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!

Get AOL Instant Messenger 5.1 free of charge.  Download Now!