{"record":{"id":"cc2fe758fbcb6529","repo":"oracle/graal","slug":"node-class-must-have-at-least-one-protected-constr","errorCode":null,"errorMessage":"Node class must have at least one protected constructor","messagePattern":"Node class must have at least one protected constructor","errorType":"validation","errorClass":"ElementException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.processor/src/jdk/graal/compiler/nodeinfo/processor/GraphNodeVerifier.java","lineNumber":222,"sourceCode":"        return null;\n    }\n\n    void verify(TypeElement node) {\n        scanFields(node);\n\n        boolean foundValidConstructor = false;\n        for (ExecutableElement constructor : ElementFilter.constructorsIn(node.getEnclosedElements())) {\n            if (constructor.getModifiers().contains(PRIVATE)) {\n                continue;\n            } else if (!constructor.getModifiers().contains(PUBLIC) && !constructor.getModifiers().contains(PROTECTED)) {\n                throw new ElementException(constructor, \"Node class constructor must be public or protected\");\n            }\n\n            foundValidConstructor = true;\n        }\n\n        if (!foundValidConstructor) {\n            throw new ElementException(node, \"Node class must have at least one protected constructor\");\n        }\n    }\n}\n","sourceCodeStart":204,"sourceCodeEnd":226,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.processor/src/jdk/graal/compiler/nodeinfo/processor/GraphNodeVerifier.java#L204-L226","documentation":"A @NodeInfo node class must expose at least one constructor that is public or protected. If all declared constructors are private (or the loop never finds a non-private one), the instantiation machinery generated for the node has no usable constructor, so GraphNodeVerifier throws this ElementException on the class itself. Private constructors are allowed only alongside at least one accessible constructor.","triggerScenarios":"foundValidConstructor stays false after iterating all constructors — i.e. every constructor has modifiers.contains(PRIVATE) (GraphNodeVerifier.java:210-223). Example: a singleton-style node with only 'private MyNode() { ... }'.","commonSituations":"Singleton/utility-style node classes with only private constructors; making constructors private to force factory creation; refactoring away the protected constructor during cleanup.","solutions":["Widen at least one constructor to protected (the idiomatic choice for nodes) or public.","Keep private constructors only as additional helpers, never as the sole ones.","Rebuild to confirm the processor accepts the class."],"exampleFix":"// before\nprivate MyNode() {\n    super(TYPE, ...);\n}\n\n// after\nprotected MyNode() {\n    super(TYPE, ...);\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Every node class needs at least one public or protected constructor.","When privatizing constructors for factory patterns, leave one protected constructor for the generated machinery."],"tags":["java","graalvm","annotation-processing","graal-node","constructors","compile-time"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}