While parsing methods, Local.updateTargets is called, while in turns call getEnd. Now, getEnd tries to find the last instruction, or better said "Instruction". Normally, this is the Instruction just before the ReturnInstruction. Anyway, an empty method does not have such an Instruction, but rather a CodeEntry instead, and this causes the exception that follows.
java.lang.ClassCastException: serp.bytecode.CodeEntry cannot be cast to serp.bytecode.Instruction
It took me quite an effort to debug this, and probably I'm missing something, but adding one dummy line of code (long i = System.currentTimeMillis(), just to make sure to create a few instructions) in the empty method solved this issue.
In my scenario, SERP was used by OpenJPA to instrument some classes. OpenJPA still uses 1.13.1 version of SERP, but looking at the code it seems like this is not changed in current trunk.
The empty method was implementing with a no-op implementation a superclass method, which is not an incredibly rare pattern, so it sounds strange this emerged so late.
Log in to post a comment.