[
https://issues.jboss.org/browse/JASSIST-207?page=com.atlassian.jira.plugi...
]
Scott Marlow commented on JASSIST-207:
--------------------------------------
I cloned test4.LocalVars.run() into test4.JASSIST207.test() (see
https://github.com/scottmarlow/javassist/tree/JASSIST-207) and also went back to the
original inserted code (could possibly be hitting dead code issues).
{quote}
<testcase time="0.005" classname="javassist.JvstTest4"
name="testThrowExpression">
<error message="StackMapTable error: bad offset in method
test4.JASSIST207.test()I"
type="java.lang.VerifyError">java.lang.VerifyError: StackMapTable error: bad
offset in method test4.JASSIST207.test()I
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2413)
at java.lang.Class.getConstructor0(Class.java:2723)
at java.lang.Class.newInstance0(Class.java:345)
at java.lang.Class.newInstance(Class.java:327)
at javassist.JvstTestRoot.make(JvstTestRoot.java:37)
at javassist.JvstTest4.testThrowExpression(JvstTest4.java:827)
</error>
{quote}
If I instead insert conditional code that tests a public class variable setting and then
throws the assertion, no error occurs. In the test code, [you can see this around
here|https://github.com/scottmarlow/javassist/commit/93ec9f78e61c4784b27d...].
I'm using JDK 1.7.0_21 (on Fedora 19).
{quote}
If the Javassist compiler is skipping cleaning up the local variable table or stack map
table because of unreachable code, that would be a good explanation. As a library user I
would then expect a BadBytecode exception to be thrown during Javassist compile-time, and
not a non-related exception during class-loading time.
{quote}
It is possible that we have identified a problem (dead code detection may be causing this)
and workaround (avoid asking Javassist to generate dead code). Could you try working
around the error in your real case, by avoiding asking Javassist to generate dead code (if
that is possible for you to try)?
I also agree, that if this is a problem with "dead code detection", that a
compile time error would be better.
Inconsistent Stack Map when inserting throw Expression with Java 7
------------------------------------------------------------------
Key: JASSIST-207
URL:
https://issues.jboss.org/browse/JASSIST-207
Project: Javassist
Issue Type: Bug
Affects Versions: 3.18.0-GA
Reporter: Ben Romberg
Assignee: Shigeru Chiba
Priority: Critical
I wrote a unit-test for javassist, reproducing the issue:
{code}
public class ThrowExpressionCorruptsStackMapTableTest extends JvstTestRoot {
public ThrowExpressionCorruptsStackMapTableTest(String name) {
super(name);
}
public void testInsertLocalVars() throws Exception {
CtClass cc = sloader.get("test4.LocalVars");
CtMethod m1 = cc.getDeclaredMethod("run");
m1.insertBefore("throw new AssertionError((Object) \"assertion
error\");");
cc.writeFile();
Object obj = make(cc.getName());
assertEquals(10, invoke(obj, "run"));
}
}
{code}
Throws:
java.lang.VerifyError: Expecting a stack map frame in method test4.LocalVars.run()I at
offset 45
My use-case is almost the same, inserting a "throw AssertionError(...)"
expression with insertBefore. However, I get a slightly different error message:
Stack map does not match the one at exception handler 37 in method
timeofday.TimeOfDay.getSecond()I at offset 27
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira