[
https://issues.jboss.org/browse/JASSIST-241?page=com.atlassian.jira.plugi...
]
Sajal Agarwal commented on JASSIST-241:
---------------------------------------
[~chiba] I'm facing the below error
"java.lang.VerifyError: StackMapTable error: bad offset error "
when I'm using CtMethod.insertAfter method to modify one of the methods in my java web
application. It seems similar to the error you were facing. Can you please explain me what
changes you made in the insertAfter() method that solved your issue.
VerifyError: Expecting a stackmap frame - Switch case statement Java
7
----------------------------------------------------------------------
Key: JASSIST-241
URL:
https://issues.jboss.org/browse/JASSIST-241
Project: Javassist
Issue Type: Bug
Affects Versions: 3.19.0-GA
Environment: jdk7
Reporter: Patson Luk
Assignee: Shigeru Chiba
Fix For: 3.20.0-GA
This could be a duplicate of issue 215 and 205.
Tested it on the master (3.19.0-GA) with java 7. Running the below class
{code}
import java.util.Random;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
public class TestDriver {
public static void main(String[] args) throws Exception {
ClassPool pool = ClassPool.getDefault();
CtClass cc = pool.get("TestClass");
CtMethod testMethod = cc.getMethod("test",
"(Ljava/lang/Object;)V");
testMethod.insertAfter("System.out.println(\"inserted!\");");
cc.toClass();
//invoke it
TestClass.test(new Object());
}
}
class TestClass {
public static void test(Object o) {
//part 1
if (o == null) {
return;
}
//part 2
int oper = new Random().nextInt();
switch (oper) {
case 1:
break;
}
}
}
{code}
Triggers error message as below:
{quote}
Exception in thread "main" java.lang.VerifyError: Expecting a stackmap frame at
branch target 9 in method TestClass.test(Ljava/lang/Object;)V at offset 1
at TestDriver.main(TestDriver.java:19)
{quote}
*Please take note that:*
# This is observed on Java 7. When the same code is run on Java 6, it is fine
# Both the "part 1" - return statement (commented in the code above) and
"part 2" - switch/case statement have to be there to trigger the error. If
either of those are commented out, then the code runs fine
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)