{"record":{"id":"1423c86992a41d4b","repo":"oracle/graal","slug":"namesdontmatch","errorCode":"NamesDontMatch","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":240,"sourceCode":"            TypeSymbols typeSymbols = klass.getContext().getTypes();\n            try {\n                parserKlass = ParserKlassProvider.parseKlassWithHostErrors(ClassRegistry.ClassDefinitionInfo.EMPTY, context.getClassLoadingEnv(), loader,\n                                typeSymbols.fromClassNameEntry(hotSwapInfo.getName()), bytes);\n                if (hotSwapInfo.isPatched()) {\n                    byte[] patched = hotSwapInfo.getPatchedBytes();\n                    newParserKlass = parserKlass;\n                    // we detect changes against the patched bytecode\n                    parserKlass = ParserKlassProvider.parseKlassWithHostErrors(ClassRegistry.ClassDefinitionInfo.EMPTY, context.getClassLoadingEnv(), loader,\n                                    typeSymbols.fromClassNameEntry(hotSwapInfo.getNewName()),\n                                    patched);\n                }\n            } catch (ValidationException | ParserException.ClassFormatError validationOrBadFormat) {\n                throw new RedefinitionException(RedefinitionError.InvalidClassFormat, validationOrBadFormat.getMessage());\n            } catch (ParserException.UnsupportedClassVersionError unsupportedClassVersionError) {\n                throw new RedefinitionException(RedefinitionError.UnsupportedVersion, unsupportedClassVersionError.getMessage());\n            } catch (ParserException.NoClassDefFoundError noClassDefFoundError) {\n                // see HotSpot VM_RedefineClasses::load_new_class_versions\n                throw new RedefinitionException(RedefinitionError.NamesDontMatch, noClassDefFoundError.getMessage());\n            } catch (ParserException parserException) {\n                throw EspressoError.shouldNotReachHere(\"Not a validation nor parser exception\", parserException);\n            }\n            classChange = detectClassChanges(parserKlass, klass, detectedChange, newParserKlass, jvmtiRestrictions);\n            if (classChange == ClassChange.CLASS_HIERARCHY_CHANGED && detectedChange.getSuperKlass() != null) {\n                // keep track of unhandled changed super classes\n                ObjectKlass superKlass = detectedChange.getSuperKlass();\n                ObjectKlass oldSuperKlass = klass.getSuperKlass();\n                ObjectKlass commonSuperKlass = (ObjectKlass) oldSuperKlass.findLeastCommonAncestor(superKlass);\n                while (superKlass != commonSuperKlass) {\n                    superClassChanges.add(superKlass);\n                    superKlass = superKlass.getSuperKlass();\n                }\n            }\n            ChangePacket packet = new ChangePacket(hotSwapInfo, newParserKlass != null ? newParserKlass : parserKlass, classChange, detectedChange);\n            result.add(packet);\n            temp.put(klass, packet);\n        }","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/redefinition/ClassRedefinition.java#L222-L258","documentation":"RedefinitionException with RedefinitionError.NamesDontMatch thrown when parsing the replacement class bytes triggers ParserException.NoClassDefFoundError. Following HotSpot's VM_RedefineClasses::load_new_class_versions semantics, a class referenced during parsing (typically a superclass or interface of the new version) could not be found, which surfaces as a names-do-not-match failure. The '{}' is the underlying parser message naming the missing dependency.","triggerScenarios":"Submitting hotswap bytes for class A whose new version references a superclass/interface (or the class name itself differs from the class being redefined) that is not loadable by the defining class loader; redefining a class with bytes compiled from a renamed source file.","commonSituations":"Refactoring that renames a class while a hotswap tool still submits old/new name pairs; adding an interface or superclass in the new version that is not on the runtime classpath; multi-module builds where the dependency containing the new supertype was not deployed before the swap.","solutions":["Ensure the replacement bytes define exactly the same class name as the class being redefined (no renames).","Deploy/load every new superclass or interface referenced by the replacement class before triggering the redefinition.","Check the exception message for the missing type name and add that dependency to the runtime classpath.","If the rename is intentional, use class retransformation with a compatible toolchain or restart the context instead of hotswap."],"exampleFix":"// before: bytes define com.example.NewName but redefining com.example.OldName\nredefine(oldNameKlass, new nameBytes);\n// after: keep the class name identical in the replacement bytes\nredefine(oldNameKlass, sameNameBytes); // bytes must declare com.example.OldName","handlingStrategy":"validation","validationCode":"// verify the bytes define the same class you are redefining\nString defined = new org.objectweb.asm.ClassReader(bytes).getClassName();\nif (!defined.equals(klass.getType().toString().replace('/', '.'))) {\n    throw new IllegalArgumentException(\"bytes define \" + defined + \", expected \" + klass.getName());\n}\n// also ensure any new supertype is loadable by the defining loader\nfor (String supertype : collectSupertypes(bytes)) {\n    Class.forName(supertype, false, hostLoaderFor(klass));\n}","typeGuard":null,"tryCatchPattern":"catch (RedefinitionException e) {\n    if (e.getError() == RedefinitionError.NamesDontMatch) { /* deploy missing dependency or fix class name, then retry */ }\n}","preventionTips":["Never rename classes that participate in hotswap.","Deploy new supertypes before the classes that reference them.","Log the missing-type message; it names exactly what failed to load."],"tags":["espresso","hotswap","class-redefinition","class-loading","naming"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}