{"record":{"id":"28dbe029699a6f02","repo":"oracle/graal","slug":"failsverification","errorCode":"FailsVerification","errorMessage":"{}","messagePattern":"\\{\\}","errorType":"error_code","errorClass":"RedefinitionException","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/redefinition/ClassRedefinition.java","lineNumber":456,"sourceCode":"                        ObjectKlass newKlass = classRegistry.defineKlass(context, type, classInfo.getBytes());\n                        assert newKlass != loadedKlass && newKlass == classRegistry.findLoadedKlass(context.getClassLoadingEnv(), type);\n\n                        packet.info.setKlass(newKlass);\n                    } else if (classInfo.isNewInnerTestKlass()) {\n                        // New inner test classes cannot be loaded because they'll\n                        // have a versioned name on disk, so let's define them directly\n                        classRegistry.defineKlass(context, type, classInfo.getBytes());\n                    }\n                    return;\n            }\n        } catch (EspressoException ex) {\n            // TODO(Gregersen) - return appropriate error code based on the exception type\n            // we get from parsing the class file\n            throw new RedefinitionException(RedefinitionError.InvalidClassFormat);\n        } catch (EspressoClassLoadingException.ClassCircularityError e) {\n            throw new RedefinitionException(RedefinitionError.CircularClassDefinition);\n        } catch (EspressoClassLoadingException e) {\n            throw new RedefinitionException(RedefinitionError.FailsVerification, e.getMessage());\n        }\n    }\n\n    // detect all types of class changes, but return early when a change that require arbitrary\n    // changes\n    private static ClassChange detectClassChanges(ParserKlass newParserKlass, ObjectKlass oldKlass, DetectedChange collectedChanges, ParserKlass finalParserKlass, boolean jvmtiRestrictions)\n                    throws RedefinitionException {\n        if (oldKlass.getSuperKlass() == oldKlass.getMeta().java_lang_Enum) {\n            detectInvalidEnumConstantChanges(newParserKlass, oldKlass);\n        }\n        ConstantPool oldConstantPool = oldKlass.getConstantPool();\n        ConstantPool newConstantPool = newParserKlass.getConstantPool();\n        // detect invalid attribute changes for jvmti restrictions\n        if (jvmtiRestrictions) {\n            if (attrChanged(oldKlass.getAttribute(NestHostAttribute.NAME), newParserKlass.getAttribute(NestHostAttribute.NAME), oldConstantPool, newConstantPool)) {\n                throw new RedefinitionException(RedefinitionError.ClassAttributeChanged);\n            }\n            if (attrChanged(oldKlass.getAttribute(NestMembersAttribute.NAME), newParserKlass.getAttribute(NestMembersAttribute.NAME), oldConstantPool, newConstantPool)) {","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/redefinition/ClassRedefinition.java#L438-L474","documentation":"RedefinitionException with RedefinitionError.FailsVerification thrown at the end of the redefinition flow when defining the new class version raises an EspressoClassLoadingException (verification/linkage failure); the exception message is passed through. Note the sibling catch arms: plain EspressoException maps to InvalidClassFormat and ClassCircularityError to CircularClassDefinition, so this code specifically means the class parsed but failed loading/verification.","triggerScenarios":"Redefining a class whose new bytecode fails Espresso's verifier (bad stack shapes, incompatible method descriptors across the change, missing StackMapTable) or whose linkage fails while defining the new version in the ClassRegistry (e.g. defineKlass during schema-change handling).","commonSituations":"Incremental compilers or instrumentation agents generating bytecode without proper stack-map frames; redefinition bytes that violate verifier constraints for the changed method bodies; partial recompiles where a dependent class's new signature breaks linkage of the redefined class.","solutions":["Read the carried EspressoClassLoadingException message to find the exact verification/linkage failure.","Recompile with a conforming compiler (javac or ASM with COMPUTE_FRAMES) so StackMapTable frames are regenerated, and resubmit.","If a transformer agent is involved, disable it to confirm it is producing unverifiable bytecode, then fix or update the agent.","Verify that any signature changes in the new version are consistent with already-loaded dependent classes, or reload those dependents too."],"exampleFix":"// before: ASM-generated method without frames\ncw.visit(Opcodes.V1_8, flags, name, null, \"java/lang/Object\", null);\n// ... emit method with jumps but no StackMapTable\n// after: let ASM compute frames\nClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (RedefinitionException e) {\n    if (e.getError() == RedefinitionError.FailsVerification) {\n        // e.getMessage() carries the verification error; fix bytecode/frames and resubmit\n    }\n}","preventionTips":["Generate bytecode with COMPUTE_FRAMES so StackMapTable is always correct.","Verify replacement classes by loading them in a scratch class loader first.","Keep signature changes consistent across all classes in a hotswap batch."],"tags":["espresso","hotswap","class-redefinition","verification","linking"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}