{"record":{"id":"953ad63438fb9a3a","repo":"oracle/graal","slug":"unsupported-class-file-version-s-s","errorCode":null,"errorMessage":"Unsupported class file version: %s.%s","messagePattern":"Unsupported class file version: (.+?)\\.(.+?)","errorType":"exception","errorClass":"UnsupportedClassVersionError","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/classfile/Classfile.java","lineNumber":77,"sourceCode":"    // Graal change when updating to a newer JDK.\n\n    /**\n     * Creates a {@link Classfile} by parsing the class file bytes for {@code type} loadable from\n     * {@code context}.\n     *\n     * @throws NoClassDefFoundError if there is an IO error while parsing the class file\n     */\n    public Classfile(ResolvedJavaType type, DataInputStream stream, ClassfileBytecodeProvider context) throws IOException {\n        this.type = type;\n\n        // magic\n        int magic = stream.readInt();\n        assert magic == MAGIC : Assertions.errorMessage(magic);\n\n        int minor = stream.readUnsignedShort();\n        int major = stream.readUnsignedShort();\n        if (major < MAJOR_VERSION_JAVA_MIN) {\n            throw new UnsupportedClassVersionError(\"Unsupported class file version: \" + major + \".\" + minor);\n        }\n\n        try {\n            ClassfileConstantPool cp = new ClassfileConstantPool(stream, context);\n\n            // access_flags, this_class, super_class\n            skipFully(stream, 6);\n\n            // interfaces\n            skipFully(stream, stream.readUnsignedShort() * 2);\n\n            // fields\n            skipFields(stream);\n\n            // methods\n            codeAttributes = readMethods(stream, cp);\n\n            // attributes","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/classfile/Classfile.java#L59-L95","documentation":"Classfile is the minimal class-file parser used by ClassfileBytecodeProvider to read snippet/replacement classes. After reading magic it reads minor/major version and rejects the file with UnsupportedClassVersionError if major is below MAJOR_VERSION_JAVA_MIN (the oldest class file version Graal will parse).","triggerScenarios":"Parsing a class file compiled with an ancient -target/--release value below the supported minimum, or a stream whose version fields read low because the data is truncated/corrupt (though the magic assert must have matched in checked builds).","commonSituations":"Old third-party jars compiled for very old Java targets on the snippet path; builds that pin --release to a too-low value; truncated or corrupted class files in a jar.","solutions":["Recompile the offending classes with a supported target (raise javac --release/-target to at least the minimum Graal supports).","Upgrade the dependency that ships the ancient class files.","Verify the class file with javap -v and check the 'major version' line; if unreadable, replace the artifact (bad download/transfer)."],"exampleFix":"// before\njavac --release 7 Snippet.java\n\n// after\njavac --release 17 Snippet.java","handlingStrategy":"try-catch","validationCode":"// Cheap pre-check of a class file's version before parsing\nstatic boolean versionSupported(java.nio.file.Path classFile) throws java.io.IOException {\n    try (var in = new java.io.DataInputStream(java.nio.file.Files.newInputStream(classFile))) {\n        in.readInt();                 // magic\n        int minor = in.readUnsignedShort();\n        int major = in.readUnsignedShort();\n        return major >= 45 + 8;      // use the same minimum your provider enforces\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    Classfile cf = new Classfile(type, stream, provider);\n} catch (UnsupportedClassVersionError e) {\n    // Report which class is too old and rebuild/upgrade it; do not retry with the same bytes\n    throw new IllegalStateException(\"Class file too old for Graal parsing: \" + type.toJavaName(), e);\n}","preventionTips":["Pin --release to a currently supported Java version in all build configs that feed snippet classes.","Fail the build when a dependency jar contains class files below the supported major version (e.g. with a maven/gradle enforcer rule)."],"tags":["classfile","class-version","parsing","graal"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}