Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Re: aspectj-dev Digest, Vol 19, Issue 2

There are two pre-requisites for throwing a checked exception at a join point:

1) the checked exception must be declared in the advice signature, and 
2) the checked exception must be declared in the join point signature

For example, given the advice declaration:

Object around() throws CheckedException : some_pc() {
   throw new CheckedException();
}

This will compile happily as long as all the join points matched by some_pc() declare CheckedException in their signature. As soon as the weaver sees a join point matched by some_pc() that does not have "throws CheckedException" in its signature however you will get a compilation error when compiling the type with the offending join point shadow.

AspectJ is a statically typed language, so there is no way to conditionally throw a checked exception based on a runtime test.

Regards, Adrian.

On 4 Sep 2006, at 13:25, Jonghyun Yoon wrote:

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.
 
//original method
someMethod()
 
//advice
around() throws * : call(* *.someMethod()) {
throw new CheckedException();
}
 
//weven method and also illegal if someMethod() can not throw CheckedException
someMethod()
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
try {
  someMethod()
  throw new CheckedException()...
} catch (Throwable t) {
  if (isPointCutCanThrow(t)) {
    throw t
  } else {
    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
******************************************

_______________________________________________
aspectj-dev mailing list



Back to the top