ClassReader/ClassWriter producing less byte codes than original class file
Team, I am using ClassReader and ClassWriter to generate bytecodes without making any modifications to the original bytecodes. Given that there is no modification to the bytecodes during the visiting process, I would expect the number of weaved byte codes to equal that of the original byte codes. However, I have a handful of cases where this is not true. Is this a known issue? Bug? Basic POC code below: final byte originalCodes = Files.readAllBytes(/* some class file */); final ClassReader reader = new ClassReader(originalCodes); final ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); reader.accept(writer, 0); final byte weavedCodes = writer.toByteArray(); assert(weavedCodes.length >= originalCodes.length); // fails An example class that fails is from the Jackson Json library: com/fasterxml/jackson/annotation/JsonAutoDetect$1.class The weaved codes for this class is of length 1125 whereas the original byte code length is 1131. What might have been lost? Happy to attach faulty classes for tests if this is indeed a new issue. Thanks and keep up the great work!
To upload designs, you'll need to enable LFS. More information