[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Re: Using args in LTW
|
Have you tried putting "-XnoInline" as an option in your weaver
options within aop.xml to see if that helps?
Andy.
On 09/02/07, Craig Ching <craigching@xxxxxxxxx> wrote:
Last night I decompiled the class file for the TraceTest class and found
this:
private static final void
doGet_aroundBody1$advice(AbstractServletLogger this,
AroundClosure ajc_aroundClosure, JoinPoint thisJoinPoint, Object args[],
Request request, Response response, JoinPoint joinpoint)
{
Object aobj[] = joinpoint.getArgs();
Request request1 = (Request)aobj[0];
Response response1 = (Response)aobj[1];
System.out.println("[Trace, request]: " + request1.getRequest ());
System.out.println("[Trace, response]: " + response1.getResponse());
AbstractServletLogger.ajc$around$com_foo_aspects_AbstractServletLogger$1$c8fd8333proceed(response);
}
Shouldn't that last line include the request object as well since the
original java method takes a request and response? Contrast that with the
coded example:
private static final void
doGet_aroundBody1$advice(ServletLogger this, AroundClosure
ajc_aroundClosure, JoinPoint thisJoinPoint, Object args[], Request request,
Response response, JoinPoint joinpoint)
{
Object aobj[] = joinpoint.getArgs();
Request request1 = (Request)aobj[0];
Response response1 = (Response)aobj[1];
System.out.println("[Trace, request]: " + request1.getRequest ());
System.out.println("[Trace, response]: " + response1.getResponse());
Response response2 = response;
doGet_aroundBody0(this, ajc_aroundClosure, thisJoinPoint,
((JoinPoint) (args)));
}
Is there a developer's list or something? This doesn't look right. Does
anyone have any advice for where I might track this down in the aspectj
code?
Cheers,
Craig
On 2/8/07, Craig Ching <craigching@xxxxxxxxx> wrote:
> Hi,
>
> This is a follow-on to my query a couple of days ago about using pointcuts
defined in an external file. I guess I was a bit premature in posting. It
had been a few months since I had looked at my problems and I should have
taken the time to review. So, sorry for the noise.
>
> Ok, so here's where I'm at. I'm thinking this is a bug, but it could be a
misunderstanding on my part. I have written a small test program that
simulates what I'm trying to do. I have the following aspect:
>
> package com.foo.aspects;
>
> import com.foo.test.Request;
> import com.foo.test.Response;
>
> public abstract aspect AbstractServletLogger {
>
> public abstract pointcut loggedGetOperations2 ();
>
> void around () : loggedGetOperations2 () {
> Object [] args = thisJoinPoint.getArgs();
>
> Request request = (Request)args[0];
> Response response = (Response)args[1];
>
> System.out.println("[AbstractServletLoggerTrace, request]: " +
request.getRequest ());
> System.out.println("[AbstractServletLoggerTrace, response]: " +
response.getResponse());
>
> proceed ();
> }
> }
>
>
> Here is the aop.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <aspectj>
> <aspects>
> <concrete-aspect name="
com.foo.aspects.ServletLoggerInstance"
>
extends="com.foo.aspects.AbstractServletLogger">
> <pointcut name="loggedGetOperations2"
> expression="execution (void
com.foo.test.TraceTest.doGet(com.foo.test.Request, com.foo.test.Response))"
/>
> </concrete-aspect>
> </aspects>
> <weaver options="-verbose -debug">
> <dump within=" com.foo.test.*"/>
> </weaver>
> </aspectj>
>
> Here is the main set of code which I'm instrumenting:
>
> package com.foo.test;
>
> public class TraceTest {
>
> public void doGet (Request request, Response response) {
> if (request == null) {
> System.err.println("Request is NULL");
> }
>
> if (response == null) {
> System.err.println("Response is NULL");
> }
> System.out.println ("Request: " + request.getRequest() + ",
Response: " + response.getResponse());
> }
>
> public static void main(String[] args) {
>
> Request request = new Request ("This is the request");
> Response response = new Response ("This is the response");
> TraceTest t = new TraceTest ();
> t.doGet(request, response);
> }
>
> }
>
> // Simulates the HttpServletRequest class
> package com.foo.test;
>
> public class Request {
>
> private String request;
>
> public Request (String request) {
> this.request = request;
> }
>
> public String getRequest () {
> return this.request;
> }
>
> }
>
> // Simulates the HttpServletResponse class
> package com.foo.test;
>
> public class Response {
>
> private String response;
>
> public Response (String response) {
> this.response = response;
> }
>
> public String getResponse () {
> return this.response;
> }
>
> }
>
> And here is what I'm getting:
>
> [AppClassLoader@92e78c] info AspectJ Weaver Version 1.5.3 built on
Wednesday Nov 22, 2006 at 11:18:15 GMT
> [AppClassLoader@92e78c ] info register classloader
sun.misc.Launcher$AppClassLoader@92e78c
> [AppClassLoader@92e78c] info using configuration
/C:/dev/workspace/AOPTest/bin/META-INF/aop.xml
> [AppClassLoader@92e78c] info define aspect
com.foo.aspects.ServletLoggerInstance
> [AppClassLoader@92e78c] debug weaving
'com.foo.aspects.ServletLoggerInstance'
> [AppClassLoader@92e78c] debug generating class
'com.foo.aspects.ServletLoggerInstance'
> [AppClassLoader@92e78c] debug weaving ' com.foo.test.TraceTest'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.Factory'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.lang.reflect.SourceLocation'
> [ AppClassLoader@92e78c ] debug cannot weave
'org.aspectj.runtime.reflect.MethodSignatureImpl'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.lang.reflect.MethodSignature'
> [AppClassLoader@92e78c] debug cannot weave '
org.aspectj.runtime.reflect.CodeSignatureImpl'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.MemberSignatureImpl'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.SignatureImpl '
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.ConstructorSignatureImpl'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.lang.reflect.ConstructorSignature'
> [ AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.UnlockSignatureImpl'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.lang.reflect.UnlockSignature'
> [AppClassLoader@92e78c ] debug cannot weave
'org.aspectj.runtime.reflect.LockSignatureImpl'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.lang.reflect.LockSignature'
> [AppClassLoader@92e78c] debug cannot weave '
org.aspectj.runtime.reflect.AdviceSignatureImpl'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.lang.reflect.AdviceSignature'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.CatchClauseSignatureImpl '
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.lang.reflect.CatchClauseSignature'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.FieldSignatureImpl'
> [AbstractServletLoggerTrace, request]: This is the request
> [AbstractServletLoggerTrace, response]: This is the response
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.lang.reflect.FieldSignature'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.InitializerSignatureImpl '
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.lang.reflect.InitializerSignature'
> [AppClassLoader@92e78c] debug weaving 'com.foo.test.Request'
> [AppClassLoader@92e78c] debug weaving ' com.foo.test.Response'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.SignatureImpl$Cache'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.JoinPointImpl$StaticPartImpl '
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.SourceLocationImpl'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.reflect.JoinPointImpl'
> [AppClassLoader@92e78c ] debug cannot weave
'org.aspectj.lang.NoAspectBoundException'
> [AppClassLoader@92e78c] debug cannot weave
'org.aspectj.runtime.internal.AroundClosure'
> Exception in thread "main" java.lang.NullPointerException
> at
com.foo.aspects.AbstractServletLogger.ajc$around$com_foo_aspects_AbstractServletLogger$1$c8fd8333proceed(AbstractServletLogger.aj:1)
> at
com.foo.test.TraceTest.doGet_aroundBody1$advice(TraceTest.java:119)
> at com.foo.test.TraceTest.doGet(TraceTest.java:1)
> at com.foo.test.TraceTest.main(TraceTest.java:21)
>
> When I do the same thing but put the pointcut in the aspect (and change it
from an abstract aspect to a concrete aspect in the code), it works fine,
e.g. here is an example of the concrete aspect code:
>
> package com.foo.aspects;
>
> import com.foo.test.Request;
> import com.foo.test.Response;
>
> public aspect ServletLogger {
>
> public pointcut loggedGetOperations2 () : execution (void
com.foo.test.TraceTest.doGet(Request, Response));
>
> void around () : loggedGetOperations2 () {
> Object [] args = thisJoinPoint.getArgs();
>
> Request request = (Request)args[0];
> Response response = (Response)args[1];
>
> System.out.println("[Trace, request]: " + request.getRequest ());
> System.out.println("[Trace, response]: " + response.getResponse
());
>
> proceed ();
> }
> }
>
> Can anyone tell me how to proceed? Thanks for any replies.
>
> Cheers,
> Craig
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users