Open
Description
The following code produces an invalid class file when writing it back to the disk.
Only adding one long seems to work and adding any amount of utf8 constants works too, however adding a long constant and any other does not. Decompilers and disassemblers are unable to read the file.
import org.gjt.jclasslib.io.ClassFileReader
import org.gjt.jclasslib.io.writeToByteArray
import org.gjt.jclasslib.structures.ConstantPoolUtil
import org.gjt.jclasslib.structures.constants.ConstantLongInfo
import java.io.File
fun main() {
val cf = ClassFileReader.readFromFile(file = File("Main.class"))
ConstantPoolUtil.addConstantPoolEntry(cf, ConstantLongInfo(cf).apply { long = 123456789123456789 });
ConstantPoolUtil.addConstantPoolEntry(cf, ConstantLongInfo(cf).apply { long = 987654321987654321 });
File("Main-out.class").writeBytes(cf.writeToByteArray())
}
Javap:
$ javap -v Main-out.class
Error: unexpected end of file while reading Main-out.class
Metadata
Metadata
Assignees
Labels
No labels