Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] JoinPoint SourceLocation vs. Stack Trace Interigation

> Prior to JoinPoint, I was unaware of any other Java mechanism to  
> obtain file location information beyond the stack trace.   

The stack trace gets the file location information from attributes in
the .class file put there by ... the compiler.  The source location
is generated staticly by the compiler at compile-time so there is *no* 
cost to generate it at run time.

As for generating stack traces, Eric Bodden already stated that it 
was one of the most expensive operations in Java (no less so of late),
as you can imagine if you think about it.

> Sorry if I am over obsessing on this but, asking helps me learn AND  
> move on... :-}

Two (very smart) people replied with the answer to your original question 
within 45 minutes (I love this list...).  But then it seems you didn't try or 
research their answers to validate them for yourself.  Their answers were terse 
because this question is one that one can teach oneself by reading the 
documentation (I hate this list...).

I'm glad to see folks using annotation style.  I realize the docs and the
implementation aren't entirely tailored for that style, so any feedback
you have there can help us make it easier for folks who come after you.

Thanks -
Wes

> ------------Original Message------------
> From: Gregory Kedge <greg@xxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Sun, Sep-3-2006 6:22 AM
> Subject: Re: [aspectj-users] JoinPoint SourceLocation vs. Stack Trace Interigation
>
> >   "Using thisJoinPointStaticPart will avoid the run-time creation  
> > of the
> >    join point object that may be necessary when using thisJoinPoint  
> > directly"
> >
> > Wes
> 
> >>> 	Gregory> It is my understanding that the use of JoinPoint is a
> >>> 	Gregory> reflective operation.  [...]
> >>>
> >>> Have you considered using `thisJoinPointStaticPart'?
> >>>
> >>> Eric.
> 
> Cool.  Got it. Using it. Works great.  Here's the quandary: How is  
> the JoinPoint static data obtained?
> 
> Prior to JoinPoint, I was unaware of any other Java mechanism to  
> obtain file location information beyond the stack trace.  If  
> JoinPoint is using a stack trace to fill out it's data, why not just  
> do it myself?  I am of course assuming that if I leave off the  
> JoinPoint arg, I won't incur the JoinPoint data-gathering hit... IOW:  
> If I do this,:
> 
>      @After("call (net.kedges.Foo+.new(..))")
>      public void fooCreatedHere() {
>          System.out.println("Foo created here: " + new Exception 
> ().getStackTrace()[1].toString());
>      }
> 
> in lieu of this:
> 
>      @After("call (net.kedges.Foo+.new(..))")
>      public void fooCreatedHere(JoinPoint.StaticPart  
> thisStaticJoinPoint) {
>          final SourceLocation sl =  
> thisStaticJoinPoint.getSourceLocation();
>          final StringBuilder sb = new StringBuilder(sl.getWithinType 
> ().getName());
>          sb.append('(').append(sl).append(')');
>          System.out.println("Foo created here: " + sb.toString());
>      }
> 
> I won't generate the JoinPoint data, static or otherwise, because I  
> used a signature that didn't require it (BIG ASSUMPTION) and I will  
> be doing the exact same process that is performed within the  
> JoinPoint. I would tend to agree with anyone that contend that using  
> JoinPoint is consistent and familiar in the writing of aspects even  
> if JoinPoint employed stack traces...
> 
> Sorry if I am over obsessing on this but, asking helps me learn AND  
> move on... :-}
> 
> Greg K.
> gregATkedgesNOSPAMcom
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 



Back to the top