On 24 May 2012 02:06, Straub Oliver wrote:
> Hello,
> there has been long discussions on checked vs. unchecked exceptions.
> I don't want to start this discussion again.
>
> I know, the opposite behaviour can be achieved by "declare soft ..."
>
> In my case i have to convert any exception to a layer-specific checked
> exception.
> This behaviour shall be controllable (on/off) with the presence of a
> method-annotation.
> Here an example:
>
> @DSExceptionTranslator
> private void anyMethod() throws DSException {
> throw new PersistException();
> }
>
> Obvious the above code will normally generate an unhandled-exception-error.
> I expected the following advice to solve that.
>
> after() throwing (Exception ex) throws DSException : mypointcut() {
> throw new DSException(ex);
> }
>
> But the unhandled-exception-error did not disappear!
>
> So i added a "declare soft":
>
> declare soft : Exception : mypointcut();
>
> The unhandled-exception-error disappears, but this did not solve my problem
> because the generated code looks like this:
>
> try {
> try {
> throw new PersistException();
> } catch(Exception exception) {
>
> ThrowDSExceptionAspect.aspectOf().ajc$afterThrowing$com_gid_bip_dataservice_aj_ThrowDSExceptionAspect$1$e66f2abe(exception);
> throw exception;
> }
> } catch(Exception exception1) {
> if(exception1 instanceof RuntimeException)
> throw exception1;
> else
> throw new SoftException(exception1);
> }
>
> As we can see, my new DSException is softened too and is thrown as a
> SoftException.
> It seems that the code for "declare soft" will always be weaved as last
> step.
> I tried "declare precedence" to control the weaving-process, but nothing
> changes!
>
> ==== Is there any other way to avoid the unhandled-exception-error? ====
>
> I found similar Questions in several lists, but the solutions all did not
> work with the current release of AspectJ 1.6.12.M1 (ajdt 2.1.3).
>
> Thank you in advance
>
>
> _______________________________________________