I'm having problems with Types.isAssignable()
from annotations processing API. I have this two variables:
TypeMirror someType; // with some value
TypeMirror objectType = elementUtils.getTypeElement("java.lang.Object").asType();
When I execute typeUtils.isAssignable(someType, objectType)
it returns false
.
Why does this happen? Any type could be assigned to an Object
. What am I misunderstanding?
Note: isAssignable
returns the expected value with this trick:
TypeElement typeElement = (TypeElement) typeUtils.asElement(someType);
String qualifiedName = typeElement.getQualifiedName().toString();
TypeMirror copy = elementUtils.getTypeElement(qualifiedName).asType();
typeUtils.isAssignable(copy, objectType); // returns true