{"record":{"id":"385dbbbb2ddc0383","repo":"apache/flink","slug":"the-given-type-is-not-a-parameterized-type","errorCode":null,"errorMessage":"The given type {} is not a parameterized type.","messagePattern":"The given type (.+?) is not a parameterized type\\.","errorType":"exception","errorClass":"InvalidTypesException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractionUtils.java","lineNumber":222,"sourceCode":"     * @throws InvalidTypesException if the given type does not have any type arguments or if the\n     *     index exceeds the number of type arguments.\n     */\n    public static Type extractTypeArgument(Type t, int index) throws InvalidTypesException {\n        if (t instanceof ParameterizedType) {\n            Type[] actualTypeArguments = ((ParameterizedType) t).getActualTypeArguments();\n\n            if (index < 0 || index >= actualTypeArguments.length) {\n                throw new InvalidTypesException(\n                        \"Cannot extract the type argument with index \"\n                                + index\n                                + \" because the type has only \"\n                                + actualTypeArguments.length\n                                + \" type arguments.\");\n            } else {\n                return actualTypeArguments[index];\n            }\n        } else {\n            throw new InvalidTypesException(\n                    \"The given type \" + t + \" is not a parameterized type.\");\n        }\n    }\n\n    /**\n     * Extracts a Single Abstract Method (SAM) as defined in Java Specification (4.3.2. The Class\n     * Object, 9.8 Functional Interfaces, 9.4.3 Interface Method Body) from given class.\n     *\n     * @param baseClass a class that is a FunctionalInterface to retrieve a SAM from\n     * @throws InvalidTypesException if the given class does not implement FunctionalInterface\n     * @return single abstract method of the given class\n     */\n    public static Method getSingleAbstractMethod(Class<?> baseClass) {\n\n        if (!baseClass.isInterface()) {\n            throw new InvalidTypesException(\n                    \"Given class: \" + baseClass + \"is not a FunctionalInterface.\");\n        }","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractionUtils.java#L204-L240","documentation":"Thrown by TypeExtractionUtils.extractTypeArgument when the provided Type is not an instance of ParameterizedType. This means the type does not carry runtime generic information (it is a raw Class or a TypeVariable without resolved bindings). Type argument extraction requires a ParameterizedType so that getActualTypeArguments() returns concrete type bindings.","triggerScenarios":"The function's output type is a raw type (e.g. List.class instead of List<String>). A type variable (T) was not resolved through the type hierarchy. Lambda erasure causes the output type to be a raw Class with no parameterization.","commonSituations":"Using raw types instead of parameterized types (e.g. returning List instead of List<String>). Lambda functions where the compiler could not infer the generic type argument. Subclassing a Flink function interface without specifying the generic type parameters.","solutions":["Specify all generic type parameters explicitly on your function class or anonymous class.","Use .returns(TypeInformation.of(new TypeHint<List<String>>(){})) to provide the type explicitly.","Replace the lambda with an anonymous class that specifies concrete generics.","Implement ResultTypeQueryable on your function to return the TypeInformation directly."],"exampleFix":"// before\nds.map(x -> Arrays.asList(x.split(\",\"))) // List without generic info\n// after\nds.map(x -> Arrays.asList(x.split(\",\")))\n  .returns(TypeInformation.of(new TypeHint<List<String>>(){}));","handlingStrategy":"type-guard","validationCode":"if (!(t instanceof ParameterizedType)) {\n    throw new IllegalArgumentException(\n        \"Type must be parameterized; got raw type \" + t);\n}","typeGuard":"static boolean isParameterized(Type t) {\n    return t instanceof ParameterizedType;\n}","tryCatchPattern":null,"preventionTips":["Always specify concrete generic type arguments on function classes (e.g. MapFunction<String, Integer>, not MapFunction<T, O>).","Use TypeHint to capture parameterized types at compile time.","Implement ResultTypeQueryable for full control over type information."],"tags":["type-extraction","generics","raw-type","type-argument"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}