{"record":{"id":"22f5fd0e35d19cd6","repo":"apache/beam","slug":"is-not-a-parameterizedtype","errorCode":null,"errorMessage":" is not a ParameterizedType","messagePattern":" is not a ParameterizedType","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java","lineNumber":427,"sourceCode":"   * Coder} for a particular type variable cannot be inferred. Instead, it results in a {@code null}\n   * in the array. It is the responsibility of the caller (usually {@link\n   * #getCoderFromTypeDescriptor} to extract the desired coder or throw a {@link\n   * CannotProvideCoderException} when appropriate.\n   *\n   * @param subClass the concrete type whose specializations are being inferred\n   * @param baseClass the base type, a parameterized class\n   * @param knownCoders an array corresponding to the set of base class type parameters. Each entry\n   *     can be either a {@link Coder} (in which case it will be used for inference) or {@code null}\n   *     (in which case it will be inferred). May be {@code null} to indicate the entire set of\n   *     parameters should be inferred.\n   * @throws IllegalArgumentException if baseClass doesn't have type parameters or if the length of\n   *     {@code knownCoders} is not equal to the number of type parameters of {@code baseClass}.\n   */\n  private <T> Coder<?>[] getDefaultCoders(\n      Class<? extends T> subClass, Class<T> baseClass, @Nullable Coder<?>[] knownCoders) {\n    Type type = TypeDescriptor.of(subClass).getSupertype(baseClass).getType();\n    if (!(type instanceof ParameterizedType)) {\n      throw new IllegalArgumentException(type + \" is not a ParameterizedType\");\n    }\n    ParameterizedType parameterizedType = (ParameterizedType) type;\n    Type[] typeArgs = parameterizedType.getActualTypeArguments();\n    if (knownCoders == null) {\n      knownCoders = new Coder<?>[typeArgs.length];\n    } else if (typeArgs.length != knownCoders.length) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Class %s has %d parameters, but %d coders are requested.\",\n              baseClass.getCanonicalName(), typeArgs.length, knownCoders.length));\n    }\n\n    SetMultimap<Type, Coder<?>> context = HashMultimap.create();\n    for (int i = 0; i < knownCoders.length; i++) {\n      if (knownCoders[i] != null) {\n        try {\n          verifyCompatible(knownCoders[i], typeArgs[i]);\n        } catch (IncompatibleCoderException exn) {","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java#L409-L445","documentation":"CoderRegistry.getDefaultCoders resolves the supertype of subClass up to baseClass and expects it to be a ParameterizedType (the base class must carry generic type arguments). If the resolved supertype is a raw Class — e.g. DoFn was subclassed without type parameters — it throws IllegalArgumentException '<type> is not a ParameterizedType'.","triggerScenarios":"Subclassing a generic base (e.g. DoFn or CombineFn) without supplying type arguments (raw subclass), then calling getDefaultCoders/getDefaultOutputCoder; passing a baseClass that is not actually a generic supertype of subClass.","commonSituations":"Raw-type DoFn subclasses written before generics were considered; Scala/other-JVM classes erasing to raw types; refactorings that removed <InputT, OutputT> from the extends clause.","solutions":["Parameterize the base class in the extends clause: class MyFn extends DoFn<String, Long>","Ensure the baseClass argument passed to getDefaultCoders is the generic supertype actually used by subClass","If the type is genuinely non-generic, do not use getDefaultCoders — register or supply the coder explicitly instead"],"exampleFix":"// before\nclass MyFn extends DoFn { ... } // raw type\n// after\nclass MyFn extends DoFn<String, Long> { ... }","handlingStrategy":"type-guard","validationCode":"Type sup = TypeDescriptor.of(subClass).getSupertype(baseClass).getType();\nif (!(sup instanceof ParameterizedType)) throw new IllegalStateException(\"Parameterize \" + baseClass.getSimpleName());","typeGuard":"boolean isParameterized = TypeDescriptor.of(subClass).getSupertype(baseClass).getType() instanceof ParameterizedType;","tryCatchPattern":null,"preventionTips":["Always parameterize generic Beam base classes in the extends clause","Enable rawtypes/unchecked lint warnings and fix them in DoFn/CombineFn subclasses","Write a unit test calling getDefaultCoders on every custom DoFn to catch raw types early"],"tags":["java","apache-beam","coders","generics","raw-type"],"backgroundTag":"type-mismatch","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"}