Fix reading bytecode version for java1 #1510
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Java class file format (doc) stores the bytecode version in the bytes 4 to 8 just after the famous
0xCAFEBABE
magic value.In practice, the minor version hasn't been used since Java1, and both minor and major can be read as single bytes.
When reading the version of an existing class compiled for Java 1, the minor version (3) is read at the wrong offset and is thus ignored, however the major version (45) is properly read, which makes it as if we were attempting to read a class that was compiled for Java 1.0 (doc), which is not covered by ASM as there isn't any
Opcodes.V1_0
.This PR fixes the bug in version reading and adds a test to cover it.