{"record":{"id":"c3b0edfab6e8d932","repo":"apache/beam","slug":"unknown-method-method-invoked-with-args-args","errorCode":null,"errorMessage":"Unknown method [<method>] invoked with args [<args>].","messagePattern":"Unknown method \\[<method>\\] invoked with args \\[<args>\\]\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java","lineNumber":244,"sourceCode":"        // Lazy bind the default to the method.\n        Object value =\n            jsonOptions.containsKey(propertyName)\n                ? getValueFromJson(propertyName, method)\n                : getDefault((PipelineOptions) proxy, method);\n        options.put(propertyName, BoundValue.fromDefault(value));\n      }\n      return options.get(propertyName).getValue();\n    } else if (properties.settersToPropertyNames.containsKey(methodName)) {\n      BoundValue prev =\n          options.put(\n              properties.settersToPropertyNames.get(methodName),\n              BoundValue.fromExplicitOption(args[0]));\n      if (prev == null ? args[0] != null : !Objects.equals(args[0], prev.getValue())) {\n        revision.incrementAndGet();\n      }\n      return Void.TYPE;\n    }\n    throw new RuntimeException(\n        \"Unknown method [\" + method + \"] invoked with args [\" + Arrays.toString(args) + \"].\");\n  }\n\n  public String getOptionName(Method method) {\n    return computedProperties.gettersToPropertyNames.get(method.getName());\n  }\n\n  private void writeObject(java.io.ObjectOutputStream stream) throws IOException {\n    throw new NotSerializableException(\n        \"PipelineOptions objects are not serializable and should not be embedded into transforms \"\n            + \"(did you capture a PipelineOptions object in a field or in an anonymous class?). \"\n            + \"Instead, if you're using a DoFn, access PipelineOptions at runtime \"\n            + \"via ProcessContext/StartBundleContext/FinishBundleContext.getPipelineOptions(), \"\n            + \"or pre-extract necessary fields from PipelineOptions \"\n            + \"at pipeline construction time.\");\n  }\n\n  /** Track whether options values are explicitly set, or retrieved from defaults. */","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java#L226-L262","documentation":"ProxyInvocationHandler.invoke received a Method it does not handle — neither a getter/setter of a known option nor a supported special method (e.g., as, populateDisplayData paths it understands). It throws a RuntimeException naming the method and args. This indicates the proxy was called with a method outside its known surface.","triggerScenarios":"Calling a method on a PipelineOptions proxy object that isn't a declared option property or supported handler method, e.g. an interface added method invoked reflectively, or a test invoking an unknown Method.","commonSituations":"Default/static interface methods invoked via raw reflection on the proxy; mixing proxies/options instances across classloaders (Beam classloader changes) so computed method maps don't match; unit tests probing unknown methods.","solutions":["Only invoke declared option getter/setter methods or supported helper methods (as(), cloneAs(), etc.) on the proxy","Regenerate/refresh the options instance after classloader changes instead of reusing a stale proxy","Fix the test/reflective call to target a real option method"],"exampleFix":"// before\nMethod m = opts.getClass().getMethod(\"nonExistentMethod\");\nm.invoke(opts);\n// after\nopts.setJobName(\"my-job\"); // use a real declared option method","handlingStrategy":"try-catch","validationCode":"Method m = MyOptions.class.getMethod(name); // fails early if not a real option method\nif (!PropertyNames.isOptionMethod(m)) throw new IllegalArgumentException(name + \" is not an option\");","typeGuard":null,"tryCatchPattern":"try { m.invoke(proxy, args); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Unknown method\")) { /* use correct option API */ } }","preventionTips":["Invoke only declared getters/setters or documented helper methods on proxies","Recreate options objects after classloader refresh","Avoid raw reflection on Beam proxy instances in tests"],"tags":["java","apache-beam","reflection","proxy","pipeline-options"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}