Hi Jonghyun,
I’ve hit cases where I’ve
wanted to do this. There are two good solutions:
1) Most often you can use the Exception
Introduction pattern as Ramnivas Laddad describes in AspectJ in
Action: you wrap the exception in an unchecked exception and then unpack it in
some receiving type
2) in odd cases, e.g., for virtual mock object testing frameworks, you
can use other techniques to throw checked exceptions and rely on dynamic tests
to ensure safety. I believe this should be a last resort, rather like using Java
reflections’s setAccessible to access non-public members.
This topic has come up before on the
AspectJ users mailing list, so a more full discussion can be read at
http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg01412.html
http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg01400.html
(you can download a direct bytecode implementation of throwing checked
exceptions from the aTrack open source project too).
HTH,
Ron
From:
aspectj-dev-bounces@xxxxxxxxxxx [mailto:aspectj-dev-bounces@xxxxxxxxxxx] On Behalf Of Jonghyun Yoon
Sent: Monday, September 04, 2006
5:25 AM
To: aspectj-dev@xxxxxxxxxxx
Subject: [aspectj-dev] Re:
aspectj-dev Digest, Vol 19, Issue 2
Thank you about your response
I am not saying about breaking JLS. What I am saying is totally
regal.
Please read my first mail.
For more simple explaination.
around() throws * : call(* *.someMethod()) {
throw new CheckedException();
//weven method and also illegal if someMethod() can not throw
CheckedException
throw new CheckedException()...
//but if aspectj compiler make next code,
//it is totally regal because It will never throw checked exception
which someMethod() can not throw
throw new CheckedException()...
if (isPointCutCanThrow(t)) {
throw new RunTimeException(t);
I hoped there was solution like this. But it seems aspectj
does not implement it yet..
I hope it will be implemented soon.
On 9/4/06, aspectj-dev-request@xxxxxxxxxxx
<aspectj-dev-request@xxxxxxxxxxx
> wrote:
Send aspectj-dev mailing list submissions to
aspectj-dev@xxxxxxxxxxx
To subscribe or unsubscribe via the World Wide Web, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-dev
or, via email, send a message with subject or body 'help' to
aspectj-dev-request@xxxxxxxxxxx
You can reach the person managing the list at
aspectj-dev-owner@xxxxxxxxxxx
When replying, please edit your Subject line so it is more specific
than "Re: Contents of aspectj-dev digest..."
Today's Topics:
1. Re: Can throw arbitrary Checked Exception in around? (Wes)
----------------------------------------------------------------------
Message: 1
Date: Sat, 2 Sep 2006 22:32:43 -0700
From: "Wes" <wes@xxxxxxxxxxxxxx
>
Subject: Re: [aspectj-dev] Can throw arbitrary Checked Exception in
around?
To: "AspectJ developer discussions"
<aspectj-dev@xxxxxxxxxxx>
Message-ID: <20060902223243.1136929287.wes@xxxxxxxxxxxxxx>
Content-Type: text/plain; charset="utf-8"
See the documentation of "declare soft".
http://www.google.com/search?q=site%3Awww.eclipse.org+%22declare+soft
http://www.eclipse.org/aspectj/doc/released/progguide/semantics-declare.html
http://www.eclipse.org/aspectj/doc/next/adk15notebook/declare-soft.html
Exception checking is the responsibility of every Java compiler, including
AspectJ's.
Wes
------------Original Message------------
From: "Jonghyun Yoon" <
ormastes@xxxxxxxxx>
To: aspectj-dev@xxxxxxxxxxx
Date: Sat, Sep-2-2006 6:08 AM
Subject: [aspectj-dev] Can throw arbitrary Checked Exception in around?
Does anyone know how to throw abitrary checked Exception in around?
When I try to write advise which throw arbitrary Exception
It always show me error message can't throw checked Exception 'xxxx'
Only way to throw exception without error is
Object around() throws AnException: call(* *(..) throws
AnException) {
throw new AnException();
}
But problem is that it must be written to every Exceptions and even it is done
it can not be prevent new Exceptions.
Is there any solution for this problem?
If there isn't, I hope aspectj developer make a solution like this.
when aspecj compiler weaving
suround the advice by try catch block
check throwable can be thrown by target point cut
if it can be thrown by the point cut just rethrow it
if not just wrap it with RuntimeException and throw it.
It may reduce performance but does not brake Java Language Specification and
reduce a lot of works.
It will be not a problem if compiler give warning about performance penalty Or
only some special grammar allow to throw checked Exceptions(like: Object
around() throws * : somePointcut()).
I hope there is some solution already exist but i don't know about it.
Thank you.
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://eclipse.org/pipermail/aspectj-dev/attachments/20060902/6f106153/attachment.html
------------------------------
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev
End of aspectj-dev Digest, Vol 19, Issue 2
******************************************