[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] NoSuchMethodError when calling an aspect's superclass method
|
Hi all,
please apologize that I've posted this question already in the Eclipse
AJDT newsgroup (Message-IDs <87eih6gwkh.fsf@xxxxxxxxxxxxxxxx> and
<87zkztk9hp.fsf@xxxxxxxxxxxxxxxx>).
I use AspectJ to do some dynamic analysis of some java system.
Therefore, I have a set of aspects doing different kinds of logging to
some Logging-Server. To make the logging easy for the aspects, there is
an abstract LogClient class which provides a send() method that cares
about synchronization with the server and other complexities.
--8<---------------cut here---------------start------------->8---
abstract public class LogClient {
private boolean enabled = false;
protected final boolean isEnabled() {
return enabled;
}
protected final void send(String message) {
if (!enabled) {
return;
}
// [...]
}
// [...]
}
--8<---------------cut here---------------end--------------->8---
Here's some aspect that extends LogClient:
--8<---------------cut here---------------start------------->8---
public aspect TraceMethodCalls extends LogClient {
private synchronized void log(boolean before, boolean constructor,
String signature) {
// [...] calculate stuff and put a message in a StringBuffer
send(sb.toString());
}
pointcut methodCall() : execution(* foo.bar..*.*(..))
&& !execution(* foo.bar.shared.common.CommonSAX*..*.*(..))
&& !cflow(execution(* foo.bar.client.startup.RailStartup..*.*(..)));
before() : methodCall() {
log(true, false, thisJoinPointStaticPart.getSignature().toLongString());
}
after() : methodCall() {
log(false, false, thisJoinPointStaticPart.getSignature().toLongString());
}
}
--8<---------------cut here---------------end--------------->8---
So the aspects just hook in somewhere, calculate some message and
eventually send them away using the protected method send() inherited
from LogClient.
This works well so far: I run the system to be analyzed and use
load-time weaving for the aspects.
Ok, now I wanted to skip any computations in the aspects if the aspect
is disabled. (See the boolean enabled in LogClient and its isEnabled()
getter.)
But as soon as I put a
if (!isEnabled()) return;
into the aspect's log() method definition, I get this error:
--8<---------------cut here---------------start------------->8---
Exception in thread "main" java.lang.NoSuchMethodError: de.uni_koblenz.aspects.tracing.client.method_calls.TraceMethodCalls.isEnabled()Z
at de.uni_koblenz.aspects.tracing.client.method_calls.TraceMethodCalls.log(TraceMethodCalls.aj:50)
at de.uni_koblenz.aspects.tracing.client.method_calls.TraceMethodCalls.ajc$after$de_uni_koblenz_aspects_tracing_client_method_calls_TraceMethodCalls$4$1e623020(TraceMethodCalls.aj:138)
at
foo.bar.client.startup.FoobarClientApplication.main(FoobarClientApplication.java:150)
--8<---------------cut here---------------end--------------->8---
Putting it in any advice body, I get the same error.
Why can I call the inherited send() method, but not isEnabled()?
Then I made the field LogClient.enabled protected and tried to access
that directly.
==> NoSuchFieldException for enabled
To debug the issue, I removed the isEnabled() calls and duplicated
send() to send2() and tried to call that instead of send().
==> NoSuchMethodError for send2()
Then I commented out the original send() method definition and still
tried to call the send2() method.
==> NoSuchMethodError for send2()
Then I added a method "protected final void bla() {}" to LogClient and
tried to call that.
==> NoSuchMethodError for bla()
I'm totally stunned. It semms I can only call a method with exact name
`send'... Of course, I've tried refreshing and cleaning both the
analyzed project as well as the project containing the aspects.
I'm very happy for any pointers!
Bye,
Tassilo