{"record":{"id":"08f2f5bd0b3d6e86","repo":"apache/beam","slug":"method-creator-is-not-static","errorCode":null,"errorMessage":"Method ${creator} is not static","messagePattern":"Method (.+?) is not static","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/ByteBuddyUtils.java","lineNumber":1554,"sourceCode":"  }\n\n  /**\n   * Invokes a static factory method registered using SchemaCreate. As the method parameters might\n   * not be in the same order as the schema fields, reorders the parameters as necessary before\n   * calling the constructor.\n   */\n  static class StaticFactoryMethodInstruction extends InvokeUserCreateInstruction {\n    private final Method creator;\n\n    StaticFactoryMethodInstruction(\n        List<FieldValueTypeInformation> fields,\n        Class<?> targetClass,\n        Method creator,\n        TypeConversionsFactory typeConversionsFactory) {\n      super(\n          fields, targetClass, Lists.newArrayList(creator.getParameters()), typeConversionsFactory);\n      if (!Modifier.isStatic(creator.getModifiers())) {\n        throw new IllegalArgumentException(\"Method \" + creator + \" is not static\");\n      }\n      this.creator = creator;\n    }\n\n    @Override\n    public InstrumentedType prepare(InstrumentedType instrumentedType) {\n      return instrumentedType;\n    }\n\n    @Override\n    protected StackManipulation afterPushingParameters() {\n      return MethodInvocation.invoke(new ForLoadedMethod(creator));\n    }\n  }\n\n  static class InvokeUserCreateInstruction implements Implementation {\n    protected final List<FieldValueTypeInformation> fields;\n    protected final Class<?> targetClass;","sourceCodeStart":1536,"sourceCodeEnd":1572,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/ByteBuddyUtils.java#L1536-L1572","documentation":"The ByteBuddy static-method creator implementation requires the annotated creator method to be static, because it will invoke the method without an instance. When a @SchemaCreate-style creator method is an instance method, the constructor throws IllegalArgumentException. The creator must be callable as a pure factory.","triggerScenarios":"Marking a non-static (instance) method as a schema creator/factory for a class used in a schema — e.g. a method annotated for from-row conversion that lacks the static modifier.","commonSituations":"Refactoring a static factory into an instance method while forgetting to update schema annotations; copying a factory example but dropping 'static'; using a builder method instead of a static factory as creator.","solutions":["Add the static modifier to the creator method.","Use a different, static factory method as the creator.","If the creator needs instance state, restructure: use a builder type or a static method taking all fields as parameters."],"exampleFix":"// before\npublic MyClass fromSchema(String a, int b) { return new MyClass(a, b); }\n// after\npublic static MyClass fromSchema(String a, int b) { return new MyClass(a, b); }","handlingStrategy":"validation","validationCode":"if (!java.lang.reflect.Modifier.isStatic(creatorMethod.getModifiers())) throw new IllegalArgumentException(\"Creator must be static: \" + creatorMethod);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all @SchemaCreate-style factory methods static.","Add an ArchUnit/unit test asserting creator methods are static.","Review factory method signatures after refactors."],"tags":["java","schema","bytebuddy","static-method"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}