{"record":{"id":"df2ff5252f5c9dcb","repo":"quarkusio/quarkus","slug":"type-has-no-raw-type-class","errorCode":null,"errorMessage":"Type has no raw type class: ","messagePattern":"Type has no raw type class: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/util/ReflectUtil.java","lineNumber":77,"sourceCode":"\n    public static boolean isOptionalOf(Type type, Class<?> nestedType) {\n        return isThingOf(type, Optional.class, nestedType);\n    }\n\n    public static boolean isThingOf(Type type, Class<?> thing, Class<?> nestedType) {\n        return type instanceof ParameterizedType && rawTypeIs(type, thing)\n                && rawTypeExtends(typeOfParameter(type, 0), nestedType);\n    }\n\n    public static Class<?> rawTypeOf(final Type type) {\n        if (type instanceof Class<?>) {\n            return (Class<?>) type;\n        } else if (type instanceof ParameterizedType) {\n            return rawTypeOf(((ParameterizedType) type).getRawType());\n        } else if (type instanceof GenericArrayType) {\n            return Array.newInstance(rawTypeOf(((GenericArrayType) type).getGenericComponentType()), 0).getClass();\n        } else {\n            throw new IllegalArgumentException(\"Type has no raw type class: \" + type);\n        }\n    }\n\n    private static final Class<?>[] NO_CLASSES = new Class[0];\n\n    public static Class<?>[] rawTypesOfDestructive(final Type[] types) {\n        if (types.length == 0) {\n            return NO_CLASSES;\n        }\n        Type t;\n        Class<?> r;\n        for (int i = 0; i < types.length; i++) {\n            t = types[i];\n            r = rawTypeOf(t);\n            if (r != t) {\n                types[i] = r;\n            }\n        }","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/util/ReflectUtil.java#L59-L95","documentation":"ReflectUtil.rawTypeOf extracts the raw Class behind a java.lang.reflect Type. Only Class, ParameterizedType and GenericArrayType have a raw type; if the Type is anything else (TypeVariable, WildcardType) it throws this IllegalArgumentException. It typically appears when reflection-based code receives an unresolved generic type where a concrete type was expected.","triggerScenarios":"Calling rawTypeOf/rawTypeOfParameter/rawTypesOfDestructive with a Type that is a TypeVariable or WildcardType — e.g. obtaining a generic return/field type from an unparameterized generic class (getClass() on new Foo<T>() or a raw-typed reference).","commonSituations":"Instantiating a generic class without a type argument (new AsyncBuilder() instead of new AsyncBuilder<String>()), reading generic method return types via reflection on raw classes, integrating with Quarkus utilities expecting fully-resolved types (e.g. reactive config/REST client type resolution).","solutions":["Provide the type argument so the reflective type is parameterized: use anonymous subclassing or TypeLiteral to capture generics (new TypeLiteral<List<String>>() {}).","Ensure the reflected member is accessed from a concrete (non-raw) class.","Check that generics aren't lost through an intermediate raw-typed variable or erasure at the call site.","If you cannot guarantee resolution, pre-check with instanceof ParameterizedType / Class before calling rawTypeOf."],"exampleFix":"// before\nFoo<String> f = (Foo<String>) new Foo(); // raw -> TypeVariable leaks\n// after\nFoo<String> f = new Foo<>() {} or use TypeLiteral: new TypeLiteral<Foo<String>>() {}","handlingStrategy":"type-guard","validationCode":"static boolean hasRawType(java.lang.reflect.Type t) {\n    return t instanceof Class || t instanceof ParameterizedType || t instanceof GenericArrayType;\n}","typeGuard":"boolean resolvable = !(type instanceof TypeVariable || type instanceof WildcardType);","tryCatchPattern":"try { Class<?> raw = ReflectUtil.rawTypeOf(type); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Type has no raw type class\")) { /* type is TypeVariable/Wildcard: resolve generics first */ } else throw e; }","preventionTips":["Never instantiate or reference generic classes raw","Use TypeLiteral/anonymous subclasses to capture generic types","Check member generic resolution at the concrete class, not the raw base"],"tags":["reflection","generics","type-erasure"],"backgroundTag":"raw-type-required","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}