diff --git a/inject-java/src/main/java/io/micronaut/annotation/processing/GenericUtils.java b/inject-java/src/main/java/io/micronaut/annotation/processing/GenericUtils.java index a363a5a7da3..a2fbaaeaa05 100644 --- a/inject-java/src/main/java/io/micronaut/annotation/processing/GenericUtils.java +++ b/inject-java/src/main/java/io/micronaut/annotation/processing/GenericUtils.java @@ -133,8 +133,9 @@ private Map resolveGenericTypes(DeclaredType type, TypeEleme break; case TYPEVAR: TypeVariable tv = (TypeVariable) mirror; - if (boundTypes.containsKey(tv.toString())) { - resolvedParameters.put(parameterName, boundTypes.get(tv.toString())); + String variableName = tv.asElement().getSimpleName().toString(); + if (boundTypes.containsKey(variableName)) { + resolvedParameters.put(parameterName, boundTypes.get(variableName)); } else { TypeMirror upperBound = tv.getUpperBound(); TypeMirror lowerBound = tv.getLowerBound(); @@ -195,7 +196,7 @@ protected TypeMirror resolveTypeReference(TypeMirror mirror, Map resolvedParamet mirror ); } else if (mirror instanceof TypeVariable tv) { - String variableName = tv.toString(); + String variableName = tv.asElement().getSimpleName().toString(); if (boundTypes.containsKey(variableName)) { resolvedParameters.put( parameterName, diff --git a/inject-java/src/main/java/io/micronaut/annotation/processing/visitor/AbstractJavaElement.java b/inject-java/src/main/java/io/micronaut/annotation/processing/visitor/AbstractJavaElement.java index bb49e23ae1e..9e9b4180bcf 100644 --- a/inject-java/src/main/java/io/micronaut/annotation/processing/visitor/AbstractJavaElement.java +++ b/inject-java/src/main/java/io/micronaut/annotation/processing/visitor/AbstractJavaElement.java @@ -385,7 +385,7 @@ private ClassElement resolveTypeVariable(JavaNativeElement owner, Set visitedTypes, TypeVariable tv, boolean isRawType) { - String variableName = tv.toString(); + String variableName = tv.asElement().getSimpleName().toString(); ClassElement resolvedBound = parentTypeArguments.get(variableName); List bounds = null; io.micronaut.inject.ast.Element declaredElement = this;