{"record":{"id":"907af57b260b2ed2","repo":"bazelbuild/bazel","slug":"method-s-getassociatedtypeconstructor-has-an-inva","errorCode":null,"errorMessage":"Method %s#getAssociatedTypeConstructor has an invalid signature; expected 'public static TypeConstructor getAssociatedTypeConstructor()'","messagePattern":"Method (.+?)#getAssociatedTypeConstructor has an invalid signature; expected 'public static TypeConstructor getAssociatedTypeConstructor\\(\\)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/net/starlark/java/eval/CallUtils.java","lineNumber":471,"sourceCode":"        if (found != null) {\n          throw new IllegalArgumentException(\n              String.format(\n                  \"Class %s has multiple methods named getAssociatedTypeConstructor\",\n                  clazz.getName()));\n        }\n        found = m;\n      }\n    }\n    if (found == null) {\n      return null;\n    }\n\n    // Signature check.\n    if (!Modifier.isPublic(found.getModifiers())\n        || !Modifier.isStatic(found.getModifiers())\n        || !found.getReturnType().equals(TypeConstructor.class)\n        || found.getParameterCount() != 0) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Method %s#getAssociatedTypeConstructor has an invalid signature; \"\n                  + \"expected 'public static TypeConstructor getAssociatedTypeConstructor()'\",\n              clazz.getName()));\n    }\n\n    try {\n      return (TypeConstructor) found.invoke(null);\n    } catch (IllegalAccessException | InvocationTargetException | RuntimeException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Error invoking %s#getAssociatedTypeConstructor\", clazz.getName()), e);\n    }\n  }\n}\n","sourceCodeStart":453,"sourceCodeEnd":486,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/net/starlark/java/eval/CallUtils.java#L453-L486","documentation":"After finding a unique getAssociatedTypeConstructor method, CallUtils validates it is exactly 'public static TypeConstructor getAssociatedTypeConstructor()' — public, static, no parameters, return type exactly TypeConstructor. Any deviation (private, non-static, parameters, or a subtype/boxed return) throws this IllegalArgumentException naming the class.","triggerScenarios":"Declaring the method as an instance method; adding a parameter; returning a TypeConstructor subclass or void; marking it protected/package-private.","commonSituations":"Following an interface that prescribes an instance-style getter instead of the static convention; refactor changing return type to a more specific constructor class; access reduced during API cleanup.","solutions":["Declare exactly: public static TypeConstructor getAssociatedTypeConstructor() { return ...; }.","Return the exact TypeConstructor type (assign the subtype to a TypeConstructor variable if needed).","Remove any parameters; obtain context from static configuration instead."],"exampleFix":"// before\npublic static MyTypeConstructor getAssociatedTypeConstructor(Flag f) {...}\n\n// after\npublic static TypeConstructor getAssociatedTypeConstructor() {...}","handlingStrategy":"validation","validationCode":"// Validate the accessor shape reflectively\nstatic void checkAccessorSignature(Class<?> c) {\n  for (Method m : c.getDeclaredMethods()) {\n    if (!m.getName().equals(\"getAssociatedTypeConstructor\")) continue;\n    if (!Modifier.isPublic(m.getModifiers()) || !Modifier.isStatic(m.getModifiers())\n        || m.getParameterCount() != 0\n        || !m.getReturnType().equals(TypeConstructor.class)) {\n      throw new IllegalArgumentException(\"bad signature: \" + m);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy the canonical declaration: public static TypeConstructor getAssociatedTypeConstructor().","Return the exact TypeConstructor type, not a subclass.","Keep the accessor parameterless; move configuration into static constants."],"tags":["starlark","reflection","type-system","java"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}