{"record":{"id":"57ddee091a7fc94e","repo":"apache/beam","slug":"unhandled-type-as-method-argument-type","errorCode":null,"errorMessage":"Unhandled type as method argument: ${type}","messagePattern":"Unhandled type as method argument: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/ByteBuddyDoFnInvokerFactory.java","lineNumber":1482,"sourceCode":"    }\n\n    private Object describeType(Type type) {\n      switch (type.getSort()) {\n        case Type.OBJECT:\n          return type.getInternalName();\n        case Type.INT:\n        case Type.BYTE:\n        case Type.BOOLEAN:\n        case Type.SHORT:\n          return Opcodes.INTEGER;\n        case Type.LONG:\n          return Opcodes.LONG;\n        case Type.DOUBLE:\n          return Opcodes.DOUBLE;\n        case Type.FLOAT:\n          return Opcodes.FLOAT;\n        default:\n          throw new IllegalArgumentException(\"Unhandled type as method argument: \" + type);\n      }\n    }\n\n    private void visitFrame(\n        MethodVisitor mv, boolean localsIncludeReturn, @Nullable String stackTop) {\n      boolean hasReturnLocal = (returnVarIndex != null) && localsIncludeReturn;\n\n      Type[] localTypes = Type.getArgumentTypes(instrumentedMethod.getDescriptor());\n      Object[] locals = new Object[1 + localTypes.length + (hasReturnLocal ? 1 : 0)];\n      TypeDescription.Generic receiverType =\n          checkStateNotNull(\n              instrumentedMethod.getReceiverType(),\n              \"invalid static method used as annotated DoFn method\");\n      locals[0] = receiverType.asErasure().getInternalName();\n      for (int i = 0; i < localTypes.length; i++) {\n        locals[i + 1] = describeType(localTypes[i]);\n      }\n      if (hasReturnLocal) {","sourceCodeStart":1464,"sourceCodeEnd":1500,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/ByteBuddyDoFnInvokerFactory.java#L1464-L1500","documentation":"When generating DoFn invoker bytecode, this factory maps JVM argument types to bytecode opcodes for loading/storing locals. If a method argument's type (an int from org.objectweb.asm.Type) is not one of the handled primitives/reference kinds, it throws this IllegalArgumentException. It is an internal invariant violation: it means the signature analysis produced an argument type the bytecode emitter does not know how to handle.","triggerScenarios":"Building an invoker for a DoFn whose @ProcessElement/@OnTimer method has a parameter type the emitter's switch (INT/LONG/DOUBLE/FLOAT/reference) does not cover — effectively any code path where ASM Type sorting yields an unexpected sort value; in practice a bug trigger rather than user error, reached via DoFnInvoker.newInvoker on unusual DoFn signatures.","commonSituations":"Exotic parameter types in DoFn methods after signature-erasure edge cases; Beam version bugs where a new parameter kind (e.g. additional annotation-injected parameters) wasn't added to this switch; repackaged bytecode where ASM Type constants differ across ASM versions on the classpath.","solutions":["Check the DoFn method parameters against the documented allowed ones (ProcessContext, BoundedWindow, timestamp, Duration, Instant, element types) and remove unsupported ones.","Upgrade/align to a Beam version where this emitter bug is fixed; check JIRA for 'Unhandled type as method argument'.","Align the org.ow2.asm ASM dependency version with the one Beam expects (shading/convergence issue).","If reproducible on a supported signature, file a Beam bug with the DoFn signature and full stack trace."],"exampleFix":"// before: unsupported param on DoFn method\n@ProcessElement\npublic void processElement(ProcessContext c, SomeCustomType helper) { ... }\n// after: keep only supported params, capture helper in constructor\n@ProcessElement\npublic void processElement(ProcessContext c) { useHelper(c); }","handlingStrategy":"validation","validationCode":"for (Method m : myDoFn.getClass().getDeclaredMethods()) {\n  if (m.isAnnotationPresent(OnTimer.class) || m.isAnnotationPresent(ProcessElement.class)) {\n    for (Class<?> p : m.getParameterTypes()) {\n      if (!isSupportedDoFnParam(p)) {\n        throw new IllegalStateException(\"Unsupported DoFn param \" + p + \" on \" + m);\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use documented parameter kinds on @ProcessElement/@OnTimer methods","Keep Beam and org.ow2.asm dependency versions converged","Upgrade Beam when hitting the error on a supported signature (known emitter bug pattern)","Reproduce minimal DoFn and file a Beam JIRA with the stack trace"],"tags":["java","bytecode","asm","reflection","apache-beam"],"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-14T11:17:12.474Z"}