{"record":{"id":"e50f8e95d486cdaa","repo":"apache/flink","slug":"the-given-class-is-no-subclass-of-writable-class","errorCode":null,"errorMessage":"The given class is no subclass of {Writable.class.getName()}","messagePattern":"The given class is no subclass of (.+?)","errorType":"validation","errorClass":"InvalidTypesException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java","lineNumber":155,"sourceCode":"\n        } else {\n            return false;\n        }\n    }\n\n    @Override\n    public boolean canEqual(Object obj) {\n        return obj instanceof WritableTypeInfo;\n    }\n\n    // --------------------------------------------------------------------------------------------\n\n    @PublicEvolving\n    static <T extends Writable> TypeInformation<T> getWritableTypeInfo(Class<T> typeClass) {\n        if (Writable.class.isAssignableFrom(typeClass) && !typeClass.equals(Writable.class)) {\n            return new WritableTypeInfo<T>(typeClass);\n        } else {\n            throw new InvalidTypesException(\n                    \"The given class is no subclass of \" + Writable.class.getName());\n        }\n    }\n}\n","sourceCodeStart":137,"sourceCodeEnd":160,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java#L137-L160","documentation":"Thrown by the package-private factory WritableTypeInfo.getWritableTypeInfo(typeClass) when the supplied class is not an assignable subclass of Hadoop's Writable (or is exactly Writable.class). This is a type-extraction-time guard: only concrete Writable subclasses are admissible, and passing anything else raises InvalidTypesException. The message names the expected base class.","triggerScenarios":"Produced when the type extractor resolves a type as a Writable and calls getWritableTypeInfo(typeClass) with a class that is not Writable-assignable or is the raw Writable class itself — e.g. annotating/declaring a type as Writable that is actually a non-Writable class, or requesting Writable type info for Writable.class directly.","commonSituations":"Declaring a POJO/non-Writable class where a Writable is expected; calling WritableTypeInfo on Writable.class (the base interface, not a subclass); a class that was Writable at build time but no longer is at runtime; misuse of the type-extraction API with a class that fails isAssignableFrom.","solutions":["Make the target class a concrete subclass of org.apache.hadoop.io.Writable (not the raw Writable type).","Ensure the class passed to WritableTypeInfo/getWritableTypeInfo actually implements Writable.","If you did not intend a Writable type, use the correct TypeInformation (POJO, generic, tuple) for that class.","Double-check imports so you pass your Writable subclass, not org.apache.hadoop.io.Writable itself."],"exampleFix":"// before — passing the raw Writable interface\nTypeInfo.of(org.apache.hadoop.io.Writable.class);\n// after — pass a concrete Writable subclass\nTypeInfo.of(MyWritable.class); // where MyWritable implements Writable","handlingStrategy":"type-guard","validationCode":"// Before requesting Writable type info, validate the class is a concrete Writable subclass\nClass<?> c = candidateClass;\nif (!org.apache.hadoop.io.Writable.class.isAssignableFrom(c) || c.equals(org.apache.hadoop.io.Writable.class)) {\n    throw new IllegalArgumentException(c.getName()\n        + \" is not a concrete subclass of org.apache.hadoop.io.Writable\");\n}","typeGuard":"org.apache.hadoop.io.Writable.class.isAssignableFrom(candidateClass) && !candidateClass.equals(org.apache.hadoop.io.Writable.class)","tryCatchPattern":null,"preventionTips":["Pass only concrete Writable subclasses to WritableTypeInfo/getWritableTypeInfo.","Do not pass the raw org.apache.hadoop.io.Writable class.","Choose the correct TypeInformation (POJO/tuple/generic) for non-Writable classes.","Verify imports so the subclass, not the base interface, is used."],"tags":["hadoop","type-info","validation","writable","type-extraction"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}