Your pointcuts can be rephrased in a better way, I guess, but first of all you
need to get JRE weaving done correctly if this is really the way you want to
go. I recommend not to do that because it is not trivial and usually too
massive a weapon to shoot a little sparrow. Ask yourself if it is really
necessary to intercept exceptions which are - hopefully correctly - handed by
your software.
Anyway, JRE weaving is possible but involves weaving rt.jar and creating a new
version of it or at least a JAR of woven class files which you can overlay your
original rt.jar with by means of JVM option
-Xbootclasspath/p:"path/to/my_rt.jar"
Think twice before doing that, is my advice.
--
Alexander Kriegisch
http://scrum-master.de
> Am 10.01.2014 um 10:01 schrieb Krishna Jasty <[email protected]>:
>
> Hi,
> Yes Catch, i did the correction in below code snippet.
> Yes i want to weave the JRE library, i tried to invoke the exception object
> constructor in the several ways as followed, but nothing works as of now.
>
> pointcut customException():call(* *.*(..) throws Exception);
> after() throwing(Exception ex): customException(){
> System.out.println("joinpoint is "+thisJoinPoint);
> System.out.println("exception is "+ ex);
> }
>
>
>
> after() throwing(Exception e): execution(* **Exception(..)){
> System.out.println("jointpoint is "+thisJoinPoint);
> System.out.println(e);
>
>
>
> after(Exception ex) : initialization(*.new(..)) && this(ex){
> System.out.println("inside exception advice");
> System.out.println(ex.toString());
> ex.printStackTrace();
> }
>
> after() :
> within(java.lang.ArrayIndexOutofBoundsException..*)||within(Exception+) {
> System.out.println("Returned normally with " +
> thisJoinPoint);
> }
>
> Thanks,
> Krishna
>
>
> From: Alexander Kriegisch <[email protected]>
> To: "[email protected]" <[email protected]>
> Date: 01/10/2014 01:31 PM
> Subject: Re: [aspectj-users] Catch exception with aspectj
> Sent by: [email protected]
>
>
>
>
> Hi Krishna.
>
> You mean catch, not cache.
>
> What you can do is intercept the method which is actually throwing the
> exception if it is accessible/weavable for you. I.e. if that joinpoint is in
> an external library, you need to weave the library. If it is in the JRE, you
> need to weave the JRE. That way you could also intercept the creation of
> exceptions by targetting their constructors.
> --
> Alexander
>
>
> Am 10.01.2014 um 07:00 schrieb Krishna Jasty <[email protected]>:
>
> Thanks Andy for clarification.
>
> My confusion is on how to handle the cache exception such as follows.
>
> If the catch block throws exception i can use a handler on get the exception.
> catch(Exception e){
> throw e;
> }
>
> Where as if the developer just did like below, handler cannot caught it. How
> to proceed in this case.
> catch(Exception e){
> log.error("Exception occured");
> }
>
> Thanks,
> Krishna
>
> From: Andy Clement <[email protected]>
> To: [email protected]
> Date: 01/09/2014 12:22 AM
> Subject: Re: [aspectj-users] Exception cache with aspectj
> Sent by: [email protected]
>
>
>
>
>
> There is no joinpoint for array access so you cannot catch the exception
> unfortunately.
>
> Some form of support could be added to AspectJ, but is not currently on the
> radar.
>
> cheers,
> Andy
>
>
> On 8 January 2014 05:00, Krishna Jasty <[email protected]> wrote:
> Hi ,
> Can anybody faced a similar situation like this.
>
> How to specify a pointcut and advice for caching this type of exception.
>
> try{
> int array[]={10,20,30};
> System.out.println("The value of array is" +array[5]);
> }
> catch(ArrayIndexOutOfBoundsException aiob){
> aiob.printStackTrace();
> }
>
> Thanks,
> Krishna
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users_______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users