Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Only before advice is supported on handler join points (compiler limitation)

Thanks,
The line 530 in projectDao is a synnchronized() statement, which is enclosed
in try.. catch block.
I did change the pointcut definition to a more restrictive scope instead of
!within(TraceAspect) and it did compile fine.


Regards,
Arun N

-----Original Message-----
From: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx]On Behalf Of Erik Hilsdale
Sent: Tuesday, January 20, 2004 11:44 AM
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] Only before advice is supported on handler
join points (compiler limitation)


Here's two ways of approaching this error message:

Bottom up:

There's an error on ProjectDao.java:530.  That line number almost certainly
has the word "catch" on
it or just above it.  This is paired with an error on TraceAspect:25, which
I'm betting is in

  after() :tracePoints() { ... }

The compiler is following your program and attempting to set things up so
the the advice from
TraceAspect:25 runs after running the catch block from ProjectDao.java:530.
However, the compiler
knows that it's limited:  it can't run anything but _before_ advice on catch
join points.  So it
tells you so.

Now let's look top down:

The program is saying that we want to run some advice both before and after
"tracePoints()".  What
is the tracePoints() pointcut?

  !within(TraceAspect)

That matches _every join point in the universe_ that isn't associated with
code in TraceAspect.
That's a lot of join points.  This _might_ be what you want for an academic
project, but is never
what you want for a real system.

So how to get rid of the message?  Well, if you _really_ want to advise all
those join points (don't
check it into your project, for heaven's sake!), do this:

    after() :tracePoints() && !handler(*) { ... }

That is, the error message says only before advice can be run on handler
join points, so tell the
compiler to stop trying to run after advice on handler join points.

-erik


-----Original Message-----
From: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Arun
Natarajan
Sent: Thursday, January 15, 2004 11:47 AM
To: AspectJ Eclipse
Subject: [aspectj-users] Only before advice is supported on handler join
points (compiler
limitation)


Hello all,
Newbie here trying to use AspectJ in a project after trying out some
examples. I get the following
warnings when I build my project and could not figure out what it meant.
"Only before advice is
supported on handler join points (compiler limitation)"

I have a simple tracing aspect(code listed below). I have a whole bunch of
classes and get several
pages of the same warning on multiple classes. However when I run the
application I do see before
and after messages.

Thanks,
Arun N

-----
Several lines of the same warining are output

[iajc] C:\WorkSpace\LifeCycleTool\src\com\lct\dao\ProjectDao.java:530 Only
before advice is
supported on handler join points (compiler limitation)
        [iajc] C:\WorkSpace\LifeCycleTool\src\com\lct\TraceAspect.java:25
Only before advice is supported on handler join points (compiler limitation)
        [iajc]
C:\WorkSpace\LifeCycleTool\src\com\lct\dao\ProjectDao.java:538 Only before
advice is
supported on handler join points (compiler limitation)
        [iajc] C:\WorkSpace\LifeCycleTool\src\com\lct\TraceAspect.java:25
Only before advice is supported on handler join points (compiler limitation)
        [iajc]
C:\WorkSpace\LifeCycleTool\src\com\lct\design\LinkSchemaAction.java:85 Only
before
advice is supported on handler join points (compiler limitation)
-----


TracingAspect.java

public aspect TraceAspect {
private int _callDepth = -1;

pointcut tracePoints() : !within(TraceAspect);

before() :tracePoints() {
	_callDepth++;
	print("+++ Before", thisJoinPoint);
}

after() :tracePoints() {
	print("+++ After", thisJoinPoint);
	_callDepth--;
}

private void print(String prefix, Object message) {
	for(int i=0,spaces = _callDepth*2; i <spaces; i++) {
		System.out.print(" ");
	}
	System.out.println(prefix + ":" + message);
}
}

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top