Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to inject a static field into a multitude of types with AspectJ?

I converted your sample code above into a file I could play with in
AJDT.  It became apparent that the declare parents wasn't applying
because the aspect is abstract. (Your sample snippets didn't include a
concrete sub-aspect).  But anyway, I imagine that isn't quite what you
were hitting:

> Interestingly enough, the error marker does not appear in the Problems view> and does not prevent the code from compiling and running.

When an error appears in the editor window but not in the problems
view, this indicates it is a reconciling error that AJDT is producing
but it isn't really a problem (always trust the problems view, as that
is what the compiler fills in - if there are no errors in there, then
there are no errors).

However, AJDT does have a hard time of things - basically it can only
know about some of these relationships (how itds and declare parents
are affecting things) if the code is correct and consistent.  This
means if you have a problem somewhere in your code, AJDT may not be
able to compute that your getLogger() call is in fact just fine.  I
took the code I was playing with above, added a concrete aspect and it
was all fine.  If your concrete aspects aren't in the same project as
the abstract one (and the calls to getLogger()) you could get into
this situation.  If you think all the code within a project is
consistent and yet you are still seeing these 'editor only' errors
then please raise a bugzilla and we'll take a look.

> I have examined BaseDummyInterceptor and DummyInterceptor with JD-GUI (alas,
> could not find anything better). DummyInterceptor does not even contain the
> getLogger method and this is the problem.

Wouldn't really matter if DummyInterceptor contained getLogger() since
this.getClass() will return the class of the runtime instance type
whether you are in the type (BaseDummyInterceptor) or subtype
(DummyInterceptor). I usually use javap to look at code, gave up on
decompilers a long time ago :)

> The problem is that ILoggable.getLogger method retrieves the
> LoggerHolderAspect instance using  this.getClass() as the key, which is
> determined polymorphically, while I need a statically determined value.

tricky.  I can't immediately think of a neat solution.  Maybe when
I've had a bit more time to chew on it.

Andy

On 25 December 2011 23:52, Mark <mark.kharitonov@xxxxxxxxx> wrote:
> Anyone? Andy?
>
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/How-to-inject-a-static-field-into-a-multitude-of-types-with-AspectJ-tp4168355p4234036.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top