{"record":{"id":"1f09424eb219bec6","repo":"oracle/graal","slug":"type-with-name-s-not-found","errorCode":null,"errorMessage":"Type with name %s not found.","messagePattern":"Type with name (.+?) not found\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.processor/src/jdk/graal/compiler/replacements/processor/APHotSpotSignature.java","lineNumber":145,"sourceCode":"            }\n        }\n\n        String canonicalName = binaryName;\n        if (canonicalName.startsWith(\"L\") && canonicalName.endsWith(\";\")) {\n            canonicalName = canonicalName.substring(1, canonicalName.length() - 1);\n        }\n        env.getMessager().printMessage(Kind.ERROR, canonicalName);\n\n        int arrayDims = 0;\n        while (canonicalName.startsWith(\"[\")) {\n            canonicalName = canonicalName.substring(1, canonicalName.length());\n            arrayDims++;\n        }\n\n        canonicalName = canonicalName.replaceAll(\"/\", \".\");\n        TypeElement typeElement = env.getElementUtils().getTypeElement(canonicalName);\n        if (typeElement == null) {\n            throw new RuntimeException(String.format(\"Type with name %s not found.\", canonicalName));\n        }\n        TypeMirror mirror = typeElement.asType();\n        for (int i = 0; i < arrayDims; i++) {\n            mirror = env.getTypeUtils().getArrayType(mirror);\n        }\n        return mirror;\n    }\n\n    /**\n     * Returns the kind from the character describing a primitive or void.\n     *\n     * @param ch the character\n     * @return the kind\n     */\n    public static TypeKind fromPrimitiveOrVoidTypeChar(char ch) {\n        switch (ch) {\n            case 'Z':\n                return TypeKind.BOOLEAN;","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.processor/src/jdk/graal/compiler/replacements/processor/APHotSpotSignature.java#L127-L163","documentation":"APHotSpotSignature.resolveType converts a descriptor type ('LFoo/Bar;') to a TypeMirror via Elements.getTypeElement. If the element utilities cannot resolve the canonical name (returns null), it throws RuntimeException 'Type with name %s not found.' — meaning the referenced type is not on the annotation processor's classpath/round environment. Note the code first reports the name via env.getMessager().printMessage(Kind.ERROR, ...), so a compiler diagnostic precedes the exception.","triggerScenarios":"A method-substitution signature references a type the processor cannot see: e.g. 'Lcom/foo/Bar;' where com.foo.Bar is not among the compiled sources or processor classpath. env.getElementUtils().getTypeElement(canonicalName) returns null at APHotSpotSignature.java:143-146 and the RuntimeException is thrown.","commonSituations":"Referencing JDK-internal or optional classes not visible to the processor; missing dependency in the mx suite distribution; typos in the '/'-separated name; splitting code across suites so the signature's target class is compiled in a later round; class-file-only deps not passed to the processor path.","solutions":["Verify the fully qualified name in the descriptor is spelled correctly with '/' separators converted properly (the code maps '/' to '.').","Ensure the referenced type is on the annotation processor path: add the containing project/jar as a dependency of the suite that runs the processor (check mx suite deps).","If the type lives in another compilation unit processed in a later round, restructure so it is available (API project or precompiled library).","Replace the reference with a type that is guaranteed visible (e.g. jdk.internal.vm.compiler types) if the signature is only used for matching."],"exampleFix":"// before\n// signature references a type not on the processor path\n\"(Lcom/example/Missing;)V\"\n\n// after\n// add dependency on the project containing com.example.Missing, or use a visible type\n\"(Ljdk/internal/vm/compiler/word/Word;)V\"","handlingStrategy":"try-catch","validationCode":"Elements elements = processingEnv.getElementUtils();\n\nTypeMirror resolveIfPresent(String canonicalName) {\n    String name = canonicalName.replace('/', '.');\n    while (name.startsWith(\"[\")) {\n        name = name.substring(1);\n    }\n    TypeElement el = elements.getTypeElement(name);\n    return el == null ? null : el.asType(); // null => type not visible to this processor\n}","typeGuard":null,"tryCatchPattern":"try {\n    TypeMirror t = sig.getParameterType(env, i);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Type with name\")) {\n        // the descriptor's class is not on the processor path: add the dependency\n        // or defer to a later processing round; do not retry unchanged\n    }\n}","preventionTips":["Ensure every type referenced in substitution signatures is a declared dependency of the suite running the processor.","Run mx build with the complete set of suite dependencies so the processor sees all target classes.","Watch for the preceding Kind.ERROR messager diagnostic — it names the unresolved type before the exception."],"tags":["java","graalvm","annotation-processing","jvm-signatures","classpath","runtime-exception"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}