Asm classreader failed to parse class file – probably due to a new java class file version that isn’t supported yet

Explanation of “ASM ClassReader failed to parse class file” error

The error message “ASM ClassReader failed to parse class file – probably due to a new Java class file version that isn’t supported yet” indicates that the version of the Java class file you are trying to parse is not supported by the ASM library you are using.

The ASM library is a popular Java bytecode manipulation framework that provides various tools for analyzing, modifying, and generating bytecode. It supports different versions of the Java class file format, but some older or newer versions may not be supported by the particular version of ASM you are using.

To fix this error, you have a few options:

  1. Upgrade your ASM library: If you are using an older version of ASM, try upgrading to a newer version that supports the Java class file version you are working with. Check the documentation or release notes of the ASM library to find the supported class file versions for each ASM release.
  2. Downgrade the Java class file version: If upgrading ASM is not an option, you can try compiling your Java source code with a lower target version. For example, if you are using Java 8 and encounter this error, you can try compiling your code with the -target parameter set to a lower version like 7 or 6. This will generate class files compatible with the older Java versions supported by ASM.
  3. Use an alternative library: If neither upgrading ASM nor downgrading the class file version is feasible, you may consider using an alternative bytecode manipulation library that supports the specific Java class file version you are working with. Some popular alternatives to ASM include Byte Buddy, Javassist, and CGLIB.

Here’s an example of how you can upgrade ASM from version 5.2 to version 7.2 to support newer Java class file versions:

<dependency>
    <groupId>org.ow2.asm</groupId>
    <artifactId>asm</artifactId>
    <version>7.2</version>
</dependency>

Read more

Leave a comment