{"record":{"id":"7183d439bc2a8a94","repo":"GoogleContainerTools/jib","slug":"check-the-full-stace-trace-and-if-the-root-cause","errorCode":null,"errorMessage":"Check the full stace trace, and if the root cause is from ASM ClassReader about unsupported class file version, see https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#i-am-seeing-unsupported-class-file-major-version-when-building","messagePattern":"Check the full stace trace, and if the root cause is from ASM ClassReader about unsupported class file version, see https://github\\.com/GoogleContainerTools/jib/blob/master/docs/faq\\.md#i-am-seeing-unsupported-class-file-major-version-when-building","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/api/MainClassFinder.java","lineNumber":233,"sourceCode":"            LogEvent.debug(\"MainClassFinder: \" + file + \" is not a regular file; skipping\"));\n        continue;\n      }\n      if (!file.toString().endsWith(\".class\")) {\n        logger.accept(\n            LogEvent.debug(\"MainClassFinder: \" + file + \" is not a class file; skipping\"));\n        continue;\n      }\n\n      MainClassVisitor mainClassVisitor = new MainClassVisitor();\n      try (InputStream classFileInputStream = Files.newInputStream(file)) {\n        ClassReader reader = new ClassReader(classFileInputStream);\n        reader.accept(mainClassVisitor, 0);\n        if (mainClassVisitor.visitedMainClass) {\n          mainClasses.add(reader.getClassName().replace('/', '.'));\n        }\n\n      } catch (IllegalArgumentException ex) {\n        throw new UnsupportedOperationException(\n            \"Check the full stace trace, and if the root cause is from ASM ClassReader about \"\n                + \"unsupported class file version, see \"\n                + \"https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md\"\n                + \"#i-am-seeing-unsupported-class-file-major-version-when-building\",\n            ex);\n\n      } catch (ArrayIndexOutOfBoundsException ignored) {\n        // Not a valid class file (thrown by ClassReader if it reads an invalid format)\n        logger.accept(LogEvent.warn(\"Invalid class file found: \" + file));\n\n      } catch (IOException ignored) {\n        // Could not read class file.\n        logger.accept(LogEvent.warn(\"Could not read file: \" + file));\n      }\n    }\n\n    if (mainClasses.size() == 1) {\n      // Valid class found.","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/api/MainClassFinder.java#L215-L251","documentation":"MainClassFinder.find scans .class files with the ASM ClassReader to detect main classes. If ASM throws IllegalArgumentException - typically because a class file's major version is newer than the ASM library bundled with Jib supports (e.g. classes compiled with a newer JDK) - it is wrapped in an UnsupportedOperationException pointing to the Jib FAQ about 'unsupported class file major version'.","triggerScenarios":"Calling find() on a directory/jar containing class files compiled with a JDK whose bytecode version exceeds the supported ASM ClassReader API version (e.g. compiled with JDK 17+ while ASM only reads up to Java 11).","commonSituations":"Building with an older JDK/older Jib plugin version while source code targets a newer Java release; a dependency jar in the classpath contains newer-version class files; Gradle/Maven toolchain misconfiguration compiling with a newer JDK than the environment's Jib version supports.","solutions":["Upgrade Jib (plugin or jib-core) to a version whose bundled ASM supports your class file version - see the linked FAQ.","Compile your code with a lower --release/target (e.g. --release 11) matching your Jib/JDK support level.","Upgrade the Maven/Gradle plugin and JDK used to run the build; re-run the build.","Identify the offending jar from the stack trace (which class file version is unsupported) and exclude or rebuild it."],"exampleFix":"// Maven: allow ASM in jib-core to read Java 17 classes\n// before: jib 2.x on JDK 17 compiled classes\n// after\n<plugin>\n  <groupId>com.google.cloud.tools</groupId>\n  <artifactId>jib-maven-plugin</artifactId>\n  <version>3.4.0</version>\n</plugin>\n// or lower bytecode: <maven.compiler.release>11</maven.compiler.release>","handlingStrategy":"try-catch","validationCode":"// Check highest class file major version before finding main classes\nint major = readClassMajorVersion(new File(classesDir, \"com/app/Main.class\"));\nif (major > MAX_SUPPORTED_MAJOR) throw new IllegalStateException(\"Recompile with lower --release\");","typeGuard":"null","tryCatchPattern":"try { finder.find(); } catch (UnsupportedOperationException e) {\n  Throwable root = ExceptionUtils.getRootCause(e);\n  if (root instanceof IllegalArgumentException) { /* unsupported class file version: upgrade Jib or lower --release */ }\n  throw e;\n}","preventionTips":["Keep the Jib plugin updated to match your Java target version","Align --release/target with the JDK running the build","Check dependency jars' class file versions when downgrading","Consult the linked Jib FAQ when this message appears"],"tags":["asm","classpath","jvm-version","container-build"],"backgroundTag":"unsupported-class-file-version","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}