{"record":{"id":"81449ec0d0aae069","repo":"apache/flink","slug":"object-array-type-expected","errorCode":null,"errorMessage":"Object array type expected.","messagePattern":"Object array type expected\\.","errorType":"exception","errorClass":"InvalidTypesException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java","lineNumber":1629,"sourceCode":"                if (component instanceof TypeVariable<?>) {\n                    component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component);\n                    if (component instanceof TypeVariable) {\n                        return;\n                    }\n                }\n\n                validateInfo(\n                        typeHierarchy,\n                        component,\n                        ((BasicArrayTypeInfo<?, ?>) typeInfo).getComponentInfo());\n\n            }\n            // check for object array\n            else if (typeInfo instanceof ObjectArrayTypeInfo<?, ?>) {\n                // check if array at all\n                if (!(type instanceof Class<?> && ((Class<?>) type).isArray())\n                        && !(type instanceof GenericArrayType)) {\n                    throw new InvalidTypesException(\"Object array type expected.\");\n                }\n\n                // check component\n                Type component;\n                if (type instanceof Class<?>) {\n                    component = ((Class<?>) type).getComponentType();\n                } else {\n                    component = ((GenericArrayType) type).getGenericComponentType();\n                }\n\n                if (component instanceof TypeVariable<?>) {\n                    component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component);\n                    if (component instanceof TypeVariable) {\n                        return;\n                    }\n                }\n\n                validateInfo(","sourceCodeStart":1611,"sourceCodeEnd":1647,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java#L1611-L1647","documentation":"Thrown by TypeExtractor.validateInfo when an ObjectArrayTypeInfo is expected but the extracted Java type is neither a Class array nor a GenericArrayType. This means the type extractor expected an object array (e.g., MyPojo[]) but the reflected type was not recognized as an array at all.","triggerScenarios":"Called during validateInfo when the TypeInformation is an ObjectArrayTypeInfo but the reflected Type is not Class.isArray() and not a GenericArrayType. This happens when a UDF signature declares a custom object array but the type argument is erased, a raw type, a TypeVariable, or a Collection instead.","commonSituations":"Returning List<MyPojo> where MyPojo[] was expected, or using raw types / generic type variables that do not carry array info at runtime. Common in generic base classes where the type parameter T[] loses its array nature through erasure.","solutions":["Declare the return type as a concrete object array (e.g., MyPojo[]) in the UDF signature.","Provide explicit TypeInformation using .returns(TypeInformation.of(new TypeHint<MyPojo[]>(){})).","Avoid using List/Collection in signatures where an object array type info is expected; align the declared type with the actual runtime type.","If generics are the problem, use a non-generic subclass to preserve type information for the extractor."],"exampleFix":"// before\npublic T[] map(MyRecord r) { ... } // T[] with erasure fails\n// after\npublic MyPojo[] map(MyRecord r) { ... }\n// or\n.returns(TypeInformation.of(new TypeHint<MyPojo[]>(){}))","handlingStrategy":"validation","validationCode":"// Check that the type is an array before extraction\nType type = method.getGenericReturnType();\nboolean isObjectArray = (type instanceof Class<?> && ((Class<?>) type).isArray())\n    || (type instanceof GenericArrayType);\nif (!isObjectArray) {\n    ti = TypeInformation.of(new TypeHint<MyPojo[]>(){});\n}","typeGuard":"static boolean isObjectArrayType(Type t) {\n    return (t instanceof Class<?> && ((Class<?>) t).isArray())\n        || (t instanceof GenericArrayType);\n}","tryCatchPattern":"try {\n    TypeInformation<?> ti = TypeExtractor.createTypeInfo(myFunction.getClass());\n} catch (InvalidTypesException e) {\n    ti = TypeInformation.of(new TypeHint<MyPojo[]>(){});\n}","preventionTips":["Use concrete object array types (MyPojo[]) not List<MyPojo> in UDF signatures.","Supply explicit TypeInformation with TypeHint for complex generics.","Avoid raw TypeVariables in array positions."],"tags":["type-extraction","object-array","typeinfo","udf"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}