Alex Rivera | Logout

java type erasure vs. Field#getGenericType and Method#getGenericReturnType

Asked 2009-05-28T23:05:20.583
11

As I understand them, generics are a compile time feature of Java, and parametrized type information does not exist in the compiled byte code. I have now discovered the Field#getGenericType and Method#getGenericReturnType methods, thusly shattering my world view. Please help me to piece it together.

Edit
Report

1 Answer

4

When you're dealing with a jar of compiled bytecode in your IDE, you can still get generic auto-completion. This is how it's implemented. Basically you're right: types aren't completely erased.

answered 2009-05-28T23:09:04.837

Your Answer