GoogleContainerTools/jib · error · UnsupportedOperationException
Check the full stace trace, and if the root cause is from AS
Error message
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
What it means
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'.
Source
Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/api/MainClassFinder.java:233
LogEvent.debug("MainClassFinder: " + file + " is not a regular file; skipping"));
continue;
}
if (!file.toString().endsWith(".class")) {
logger.accept(
LogEvent.debug("MainClassFinder: " + file + " is not a class file; skipping"));
continue;
}
MainClassVisitor mainClassVisitor = new MainClassVisitor();
try (InputStream classFileInputStream = Files.newInputStream(file)) {
ClassReader reader = new ClassReader(classFileInputStream);
reader.accept(mainClassVisitor, 0);
if (mainClassVisitor.visitedMainClass) {
mainClasses.add(reader.getClassName().replace('/', '.'));
}
} catch (IllegalArgumentException ex) {
throw new UnsupportedOperationException(
"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",
ex);
} catch (ArrayIndexOutOfBoundsException ignored) {
// Not a valid class file (thrown by ClassReader if it reads an invalid format)
logger.accept(LogEvent.warn("Invalid class file found: " + file));
} catch (IOException ignored) {
// Could not read class file.
logger.accept(LogEvent.warn("Could not read file: " + file));
}
}
if (mainClasses.size() == 1) {
// Valid class found.View on GitHub (pinned to fb949e2676)
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.
Example fix
// Maven: allow ASM in jib-core to read Java 17 classes // before: jib 2.x on JDK 17 compiled classes // after <plugin> <groupId>com.google.cloud.tools</groupId> <artifactId>jib-maven-plugin</artifactId> <version>3.4.0</version> </plugin> // or lower bytecode: <maven.compiler.release>11</maven.compiler.release>
Defensive patterns
Strategy: try-catch
Validate before calling
// Check highest class file major version before finding main classes
int major = readClassMajorVersion(new File(classesDir, "com/app/Main.class"));
if (major > MAX_SUPPORTED_MAJOR) throw new IllegalStateException("Recompile with lower --release"); Type guard
null
Try / catch
try { finder.find(); } catch (UnsupportedOperationException e) {
Throwable root = ExceptionUtils.getRootCause(e);
if (root instanceof IllegalArgumentException) { /* unsupported class file version: upgrade Jib or lower --release */ }
throw e;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Dependency required by the JAR (as specified in `Class-Path`
- NoSuchFileException: <directory>
- NotDirectoryException: <directory>
- extension configured but not discovered on Jib runtime class
- extension configured but not discovered on Jib runtime class
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/7183d439bc2a8a94.
Report an issue: GitHub.