{"record":{"id":"ed483cd58a519e22","repo":"alibaba/nacos","slug":"asm-classreader-failed-to-parse-class-file-proba","errorCode":null,"errorMessage":"ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: {resource}","messagePattern":"ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: (.+?)","errorType":"exception","errorClass":"NestedIoException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/alibaba/nacos/common/packagescan/DefaultPackageScan.java","lineNumber":86,"sourceCode":"                }\n            }\n        } catch (IOException | ClassNotFoundException e) {\n            LOGGER.error(\"scan path: {} failed\", packageSearchPath, e);\n        }\n        return set;\n    }\n    \n    private Class<?> getClassByResource(Resource resource) throws IOException, ClassNotFoundException {\n        String className = getClassReader(resource).getClassName();\n        return Class.forName(ClassUtils.resourcePathToConvertClassName(className));\n    }\n    \n    private static ClassReader getClassReader(Resource resource) throws IOException {\n        try (InputStream is = resource.getInputStream()) {\n            try {\n                return new ClassReader(is);\n            } catch (IllegalArgumentException ex) {\n                throw new NestedIoException(\"ASM ClassReader failed to parse class file - \"\n                        + \"probably due to a new Java class file version that isn't supported yet: \" + resource, ex);\n            }\n        }\n    }\n    \n}\n","sourceCodeStart":68,"sourceCodeEnd":93,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/common/src/main/java/com/alibaba/nacos/common/packagescan/DefaultPackageScan.java#L68-L93","documentation":"Thrown by DefaultPackageScan.getClassReader() when ASM's ClassReader cannot parse a .class file, surfacing as an IllegalArgumentException from ASM that the scan wraps as NestedIoException. The classic cause is a class file compiled for a newer Java bytecode version than the bundled ASM recognizes.","triggerScenarios":"Running a package scan (DefaultPackageScan.scan / resource scanning used to discover subscribers, plugins, or SPI types) over classes compiled with a Java version newer than the ASM library supports; scanning jars built on a newer JDK.","commonSituations":"Building with JDK 21+ but running Nacos/your app on a runtime whose ASM is older; depending on a third-party jar compiled with preview features or a newer class-file major version; the bundled spring/asm version predates the target JDK.","solutions":["Align the build/compile JDK target with the runtime JDK, or lower -target to a bytecode version ASM supports.","Upgrade the ASM dependency (or the transitively-pulled version) to one that supports the class file major version in use.","Exclude the offending jar/package from the scan scope so ASM never reads the unsupported class file.","Recompile the offending library against an older bytecode level if you control it."],"exampleFix":"// before — classes compiled at bytecode 65 (JDK 21) scanned by older ASM\n// -> ASM ClassReader failed to parse class file\n\n// after — compile at a supported level\n// javac --release 17 ...   or in maven:\n// <maven.compiler.release>17</maven.compiler.release>","handlingStrategy":"validation","validationCode":"// ensure compiled bytecode <= what ASM supports\n// compile with --release 17, or verify ASM version supports the major version\nint major = readClassMajorVersion(classFile);\nif (major > ASM_SUPPORTED_MAJOR) {\n    throw new IllegalStateException(\"class file version \" + major + \" too new for ASM\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    scan.scan(packages);\n} catch (NestedIoException e) {\n    if (e.getCause() instanceof IllegalArgumentException) {\n        log.error(\"Unsupported class file version — upgrade ASM or lower --release\", e);\n    }\n    throw e;\n}","preventionTips":["Pin the build --release to a bytecode level your runtime ASM supports.","Upgrade ASM when adopting a newer JDK.","Narrow scan scopes to packages you control to avoid third-party jars with newer bytecode."],"tags":["classpath","asm","package-scan","jdk-version"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}