[JBoss JIRA] (JASSIST-146) ClassFile.compact mangles large class files
by Paul Rupe (Created) (JIRA)
ClassFile.compact mangles large class files
-------------------------------------------
Key: JASSIST-146
URL: https://issues.jboss.org/browse/JASSIST-146
Project: Javassist
Issue Type: Bug
Affects Versions: 3.15.0-GA
Environment: Fedora Linux 14 x86_64, Java 1.6.0_27
Reporter: Paul Rupe
Assignee: Shigeru Chiba
I have a large .class file (1307829 bytes). Simply reading it in using javassist, calling ClassFile.compact(), then writing it out to a new file creates an invalid class file that is substantially larger (1996560 bytes).
javap -c throws an EOFException:
java.io.EOFException
at java.io.DataInputStream.readFully(DataInputStream.java:197)
at java.io.DataInputStream.readFully(DataInputStream.java:169)
at sun.tools.javap.AttrData.read(AttrData.java:54)
at sun.tools.javap.FieldData.read(FieldData.java:91)
at sun.tools.javap.ClassData.readFields(ClassData.java:211)
at sun.tools.javap.ClassData.read(ClassData.java:114)
at sun.tools.javap.ClassData.<init>(ClassData.java:70)
at sun.tools.javap.JavapPrinter.<init>(JavapPrinter.java:48)
at sun.tools.javap.Main.displayResults(Main.java:208)
at sun.tools.javap.Main.perform(Main.java:79)
at sun.tools.javap.Main.entry(Main.java:67)
at sun.tools.javap.Main.main(Main.java:52)
javassist throws an exception trying to read back the class file it just created:
java.lang.ClassCastException: javassist.bytecode.FieldrefInfo cannot be cast to javassist.bytecode.Utf8Info
at javassist.bytecode.ConstPool.getUtf8Info(ConstPool.java:615)
at javassist.bytecode.AttributeInfo.read(AttributeInfo.java:76)
at javassist.bytecode.FieldInfo.read(FieldInfo.java:253)
at javassist.bytecode.FieldInfo.<init>(FieldInfo.java:63)
at javassist.bytecode.ClassFile.read(ClassFile.java:783)
at javassist.bytecode.ClassFile.<init>(ClassFile.java:109)
at Test.compact(Test.java:21)
at Test.main(Test.java:12)
Attempting to use the new class file in an application results in
java.lang.ClassFormatError: Invalid this class index 537 in constant pool in class file WorldGenCreateGuild
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years