{"record":{"id":"a3588dfc2fa5474a","repo":"hibernate/hibernate-orm","slug":"cannot-erase-type-type","errorCode":null,"errorMessage":"Cannot erase type: \" + type","messagePattern":"Cannot erase type: \" \\+ type","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/util/GenericsHelper.java","lineNumber":146,"sourceCode":"\t * @return The erased type\n\t */\n\tpublic static Class<?> erasedType(Type type) {\n\t\tif ( type instanceof Class<?> clazz ) {\n\t\t\treturn clazz;\n\t\t}\n\t\telse if ( type instanceof ParameterizedType parameterizedType ) {\n\t\t\treturn erasedType( parameterizedType.getRawType() );\n\t\t}\n\t\telse if ( type instanceof TypeVariable<?> typeVariable ) {\n\t\t\treturn erasedType( typeVariable.getBounds()[0] );\n\t\t}\n\t\telse if ( type instanceof GenericArrayType genericArrayType ) {\n\t\t\treturn genericArrayType.getGenericComponentType() instanceof Class<?> elementClass\n\t\t\t\t\t? elementClass.arrayType()\n\t\t\t\t\t: Object[].class;\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalArgumentException( \"Cannot erase type: \" + type );\n\t\t}\n\t}\n\n\t/**\n\t * Get the type argument of the instantiation of the given generic\n\t * type constructor which is a supertype of the given type expression.\n\t * @param genericType A generic type constructor\n\t * @param implementingType A type expression\n\t * @return The type arguments assigned to parameters of the generic type constructor\n\t */\n\tpublic static Type[] typeArguments(Class<?> genericType, Type implementingType) {\n\t\tif ( genericType.getTypeParameters().length == 0 ) {\n\t\t\treturn EMPTY_TYPE_ARRAY;\n\t\t}\n\t\telse {\n\t\t\tfinal var instantiation =\n\t\t\t\t\tsupertypeInstantiation( genericType, implementingType );\n\t\t\tif ( instantiation == null ) {","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/util/GenericsHelper.java#L128-L164","documentation":"Error \"Cannot erase type: \" + type\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/internal/util/GenericsHelper.java:146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a Class, ParameterizedType, or GenericArrayType to erase(); other Type kinds (wildcards, type variables) cannot be erased directly."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}