Javassist causes java.lang.ClassFormatError: Invalid length 561 in
LocalVariableTable in class file
---------------------------------------------------------------------------------------------------
Key: JASSIST-99
URL:
https://jira.jboss.org/jira/browse/JASSIST-99
Project: Javassist
Issue Type: Bug
Affects Versions: 3.11.0.GA
Reporter: Martin Burger
Assignee: Shigeru Chiba
Fix For: 3.12.0.GA
Attachments: after, before, CodeIterator.r506.patch, JASSIST-99.zip
I am instrumenting field accesses in Java classes. Unfortunately, this fails in some
cases, the manipulated byte code causes a java.lang.ClassFormatError:
Exception in thread "main" java.lang.ClassFormatError: Invalid length 561 in
LocalVariableTable in class file
de/unisb/cs/st/deltadebugging/jinsi/test/integration/events/outgoing/fieldaccesses/SuperClassOfObserved
at java.lang.ClassLoader.defineClass1(Native Method)
...
This issue occurred in 3.11.0.GA and is not fixed in r505. Maybe this is related to
JASSIST-98. In 3.10.0.GA, this issue does not exist, the affected class can be loaded
without any error.
I tried to analyze the corrupt class file with javassist.tools.framedump, but the
analysis fails:
Exception in thread "main" java.lang.RuntimeException:
javassist.bytecode.BadBytecode: Could not find class in descriptor [pos = 8]:
de.unisb.cs.st.deltadebugging.jinsi.test.integration.events.outgoing.fieldaccesses.Unobserved
at javassist.bytecode.analysis.FramePrinter.print(FramePrinter.java:89)
...
I decompiled both classes (the working one and the corrupt one) using JAD, the output
differs slightly:
43c43
< /* 16*/ JVM INSTR new #96 <Class Long>;
---
> /* 16*/ JVM INSTR new #102 <Class Long>;
59c59
< /* 16*/ JVM INSTR new #96 <Class Long>;
---
> /* 16*/ JVM INSTR new #102 <Class Long>;
Here is the corrupt decompiled code of line 16. Compared to the working class, lines 43
and 59 seem to be switched:
28 /* 16*/ obj = this;
29 /* 16*/ Unobserved unobserved1 = null;
30 /* 16*/ unobserved1 = ((SuperClassOfObserved) (obj)).unobserved;
31 /* 16*/ EventRecorderFactory.getInstance().recordOutgoingFieldRead(this,
JinsiClassUtils.getClassOfObject(this), obj,
Desc.getClazz("de.unisb.cs.st.deltadebugging.jinsi.test.integration.events.outgoing.fieldaccesses.SuperClassOfObserved"),
"unobserved", unobserved1,
Desc.getType("Lde/unisb/cs/st/deltadebugging/jinsi/test/integration/events/outgoing/fieldaccesses/Unobserved;"),
"SuperClassOfObserved.java", 16, Context.METHOD);
32 /* 16*/ EventRecorderFactory.getInstance().recordIncomingFieldRead(this,
JinsiClassUtils.getClassOfObject(this), obj,
Desc.getClazz("de.unisb.cs.st.deltadebugging.jinsi.test.integration.events.outgoing.fieldaccesses.SuperClassOfObserved"),
"unobserved", unobserved1,
Desc.getType("Lde/unisb/cs/st/deltadebugging/jinsi/test/integration/events/outgoing/fieldaccesses/Unobserved;"),
"SuperClassOfObserved.java", 16, Context.METHOD);
33 /* 16*/ obj = unobserved1;
34 /* 16*/ l = 0L;
35 /* 16*/ l = ((Unobserved) (obj)).fieldLong;
36 /* 16*/ EventRecorderFactory.getInstance();
37 /* 16*/ this;
38 /* 16*/ JinsiClassUtils.getClassOfObject(this);
39 /* 16*/ obj;
40 /* 16*/
Desc.getClazz("de.unisb.cs.st.deltadebugging.jinsi.test.integration.events.outgoing.fieldaccesses.Unobserved");
41 /* 16*/ "fieldLong";
42 /* 16*/ l;
43 /* 16*/ JVM INSTR new #102 <Class Long>;
44 /* 16*/ JVM INSTR dup ;
45 /* 16*/ Long();
46 /* 16*/ Desc.getType("J");
47 /* 16*/ "SuperClassOfObserved.java";
48 /* 16*/ 16;
49 /* 16*/ Context.METHOD;
50 /* 16*/ recordOutgoingFieldRead();
51 /* 16*/ JVM INSTR pop ;
52 /* 16*/ EventRecorderFactory.getInstance();
53 /* 16*/ this;
54 /* 16*/ JinsiClassUtils.getClassOfObject(this);
55 /* 16*/ obj;
56 /* 16*/
Desc.getClazz("de.unisb.cs.st.deltadebugging.jinsi.test.integration.events.outgoing.fieldaccesses.Unobserved");
57 /* 16*/ "fieldLong";
58 /* 16*/ l;
59 /* 16*/ JVM INSTR new #102 <Class Long>;
60 /* 16*/ JVM INSTR dup ;
61 /* 16*/ Long();
62 /* 16*/ Desc.getType("J");
63 /* 16*/ "SuperClassOfObserved.java";
64 /* 16*/ 16;
65 /* 16*/ Context.METHOD;
66 /* 16*/ recordIncomingFieldRead();
67 /* 16*/ JVM INSTR pop ;
68 /* 16*/ long fieldLong = l;
However, I don't know if this is related to the defect.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: