Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-dev] Bug? with accessing thisJoinPoint in around advice using AspectJ 1.1.1

I bet that you're running on 3.0M4 or later.  There was a change in that
release that caused this bug in AspectJ.  The bug is now fixed in the tree
for our next release:
  https://bugs.eclipse.org/bugs/show_bug.cgi?id=45441

The problem is that AspectJ tries to optimize your advice by converting
thisJoinPoint to thisJoinPointStaticPart when possible in order to improve
performance.  thisJoinPoint requires the creation of a new object which
includes this, target and an Object[] of args for each matching join point.
This is expensive.  thisJoinPointStaticPart can be created once statically.

The code for this optimization was broken by a change in 3.0M4.  When you
assign thisJoinPoint to a local variable you disable the optimization code.
A different solution would be to use thisJoinPointStaticPart.getSignature()
in order to make it clear that you only need static information about the
join point for your advice.

-Jim

-----Original Message-----
From: aspectj-dev-admin@xxxxxxxxxxx [mailto:aspectj-dev-admin@xxxxxxxxxxx]
On Behalf Of Russell Miles
Sent: Thursday, November 20, 2003 4:28 AM
To: aspectj-dev@xxxxxxxxxxx
Subject: [aspectj-dev] Bug? with accessing thisJoinPoint in around advice
using AspectJ 1.1.1

Hi Developer List !

I have come across a strange feature with around advice. If I access the
thisJoinPoint as the first line in my advice, attempting to get it's
signature using the getSignature() call, an exception is thrown (something
to do with a class change exception ? I can get the output if this is not a
known issue - tricky at the moment as I'm at college and can't hook up my
laptop to their network).

However, if I assign thisJoinPoint to something first, say to an object such
as:

Object temp = thisJoinPoint;

Then the call to thisJoinPoint.getSignature() works fine after that. But not
as the first line in the advice, which seems odd. Anyone had anything like
this in the past ? I can supply more information including coe samples,
outputs, etc once I get back to my own network if this is an unkown problem.
As  a matter of interest, I am using Mac OS X 10.3 using JDK 1.4.1, does
this have any impact ? I am unable to try this out on anything else
unfortunately.

Cheers for any guidance on this, currently I am simply setting up a
temporary reference as per the above example to get around the problem, but
this is ugly.

Russ Miles





Back to the top