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
at serp.bytecode.Local.getEnd(Local.java:114)
at serp.bytecode.Local.updateTargets(Local.java:155)
at serp.bytecode.LocalTable.updateTargets(LocalTable.java:163)
at serp.bytecode.Code.read(Code.java:2031)
at serp.bytecode.Attributes.readAttributes(Attributes.java:152)
at serp.bytecode.BCMember.read(BCMember.java:365)
at serp.bytecode.BCClass.read(BCClass.java:123)
at serp.bytecode.Project.loadClass(Project.java:211)
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.
Just hit this again. See my comment at https://issues.apache.org/jira/browse/OPENJPA-888
Anyone working on this?