0

In my project I use ASM to change methods signatures. I choose methods which are using RMI and change them this way:

from:

String f(int i, String s) {
    ...
}

to

String f(int i, String s, ThreadId t) {
    log(t)
    ...
    log(t)
}

and from

a.f(i,s);

to

a.f(i, s, t);

So both definition and calling is changed.

Surprisingly it works in some cases and ThreadId is passed with control flow.

But one method cause:

java.rmi.ServerError: Error occurred in server thread; nested exception is:
            java.lang.AbstractMethodError: some.package.SomeClass.method(I;String;ThreadId;)String;

I have no idea why this error occurs. Could you please explain it? Or maybe give some suggestions how I should solve it? Any help would be great!

alicjasalamon
  • 4,171
  • 15
  • 41
  • 65

1 Answers1

1

The method is abstract. Did you modify the method signature of an abstract method (which is ok) and then try to change the implementation (it has none)? Just check if it is abstract and skip any code modifications.

John Watts
  • 8,717
  • 1
  • 31
  • 35
  • I modified method signature in Interface and Class as both are needed for RMI. then I checked where the method is called and changed way it is called. Is it OK? – alicjasalamon Sep 07 '12 at 11:20
  • But somehow your new parameter must be used. Otherwise these changes affect only the bytecode, not your app's behavior. Doesn't this mean you add at least one instruction to the method which accesses ThreadId? – John Watts Sep 07 '12 at 11:25
  • Ok, now I see your point. But I split my modifications. If I instrument interface I only change signature. if I instrument class I use ThreadId to log some messages. (I've changed a little bit my example) – alicjasalamon Sep 07 '12 at 11:29
  • Yes. And you need to change the logic of your split. The question is not "is this an interface or a class?" It is, for each method "is the method abstract or concrete?" Being an interface implies that all methods are abstract but being a class implies nothing of the sort. An abstract class can have abstract methods. – John Watts Sep 07 '12 at 11:35
  • I understand, thanks! But what if method which cause this error isn't abstract? I've check it in source code. – alicjasalamon Sep 07 '12 at 11:47