Inside the JVM, methods with different return types are distinct. After type erasure, FooBarEntity.getEntity()
has return type Object
. Calls via the interface will look specifically for a method with return type Object
, hence why your implementation must return Object
.
Normally, your Java compiler will create bridge methods that forward the result of the concrete method as the erased type, but apparently Javassist doesn't do this for you (I haven't used Javassist so I'm not sure).
For more on how bridge methods are used to implement type erasure, see the official Java Tutorials topic on bridge methods.