java
runtime_error
ai_generated
true
java.lang.ClassFormatError
ID: java/class-format-error
78%Fix Rate
84%Confidence
45Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 17 | active | — | — | — |
Root Cause
ClassFormatError indicates the JVM found a class file that does not conform to the class file format specification. Commonly caused by corrupted class files, bytecode manipulation errors, or incompatible bytecode versions.
genericWorkarounds
-
85% success Clean rebuild all class files and verify no bytecode manipulation tools are corrupting output
1. Run 'mvn clean compile' or 'gradle clean build' to regenerate all class files from source. 2. If using bytecode manipulation tools (ASM, ByteBuddy, Javassist), check their version compatibility with your JDK. 3. Run 'javap -v ClassName' to inspect the class file format version. 4. Verify the class file major version matches your JDK (61 for JDK 17, 65 for JDK 21).
-
80% success Check for corrupted JARs in your local Maven/Gradle cache and re-download
1. Delete the suspect JAR from ~/.m2/repository (Maven) or ~/.gradle/caches (Gradle). 2. Re-run the build to force a fresh download. 3. Verify the JAR integrity with 'jar tf suspect.jar' — if it fails, the JAR is corrupted. 4. Check if a proxy or corporate firewall is corrupting downloads (sometimes HTML login pages get cached as JARs).
Dead Ends
Common approaches that don't work:
-
Restarting the JVM hoping the error goes away
95% fail
ClassFormatError is deterministic — the class file itself is malformed. Restarting the JVM will always load the same corrupted class file and produce the same error.
-
Changing the JDK version without rebuilding the corrupted class files
75% fail
If the class file is genuinely corrupted (e.g., truncated, tampered, or generated by a buggy bytecode tool), a different JDK version will still reject it. The file itself must be regenerated.
Error Chain
Leads to:
Preceded by:
Frequently confused with: