{"record":{"id":"344d6934cf776a6a","repo":"apache/beam","slug":"classname-is-not-supertype","errorCode":null,"errorMessage":"${className} is not ${superType}","messagePattern":"(.+?) is not (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/euphoria/src/main/java/org/apache/beam/sdk/extensions/euphoria/core/util/InstanceUtils.java","lineNumber":57,"sourceCode":"      constr.setAccessible(true);\n      return constr.newInstance();\n    } catch (Exception e) {\n      throw new IllegalStateException(e);\n    }\n  }\n\n  public static <T> T create(String className, Class<T> superType) {\n    return create(forName(className, superType));\n  }\n\n  @SuppressWarnings(\"unchecked\")\n  public static <T> Class<? extends T> forName(String className, Class<T> superType) {\n    try {\n      Class<?> cls = Thread.currentThread().getContextClassLoader().loadClass(className);\n      if (superType.isAssignableFrom(cls)) {\n        return (Class<? extends T>) cls;\n      } else {\n        throw new IllegalStateException(className + \" is not \" + superType);\n      }\n    } catch (ClassNotFoundException e) {\n      throw new IllegalStateException(e);\n    }\n  }\n}\n","sourceCodeStart":39,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/euphoria/src/main/java/org/apache/beam/sdk/extensions/euphoria/core/util/InstanceUtils.java#L39-L64","documentation":"InstanceUtils.forName loads a class by name from the thread context classloader and verifies it is assignable to the requested superType; if it loads but is not a subtype it throws IllegalStateException with '<className> is not <superType>'. A ClassNotFoundException is also wrapped into IllegalStateException.","triggerScenarios":"Calling InstanceUtils.forName(\"com.example.Foo\", SomeSuper.class) where the class exists but does not extend/implement SomeSuper.","commonSituations":"Misconfigured provider class names in pipeline options (e.g. specifying a combiner/reducer class of the wrong type); copy-pasted FQCNs pointing at unrelated classes.","solutions":["Fix the configured class name so it points to a subclass of the expected superType","Check the FQCN for typos or an outdated class after a refactor","Verify the class's hierarchy (extends/implements) matches what the API expects"],"exampleFix":"// before\noptions.setCombiner(\"com.example.MyHelper\"); // not a WindowedCombiner\n// after\noptions.setCombiner(\"com.example.MyWindowedCombiner\"); // implements WindowedCombiner","handlingStrategy":"validation","validationCode":"Class<?> c = Class.forName(className); if (!superType.isAssignableFrom(c)) throw new IllegalArgumentException(className + \" must be a \" + superType.getSimpleName());","typeGuard":"static <T> boolean isSubtype(String className, Class<T> superType) { try { return superType.isAssignableFrom(Class.forName(className)); } catch (ClassNotFoundException e) { return false; } }","tryCatchPattern":"try { cls = InstanceUtils.forName(name, Super.class); } catch (IllegalStateException e) { /* fix configured class name */ }","preventionTips":["Validate configured FQCNs against the expected interface at config load time","Keep class names in pipeline options in sync after refactors","Add unit tests that load all configured classes"],"tags":["type-mismatch","reflection","classloading"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}