Java generics are implemented using type erasure. That means that if I have a method:
public void setMapParam(Map<String, Integer> p) { ... }
after compilation, it will end up in the .class as:
public void setMapParam(Map p) { ... }
I have a JAR file with generic classes and methods like the above. It is just the binary. No source code no nothing.
But when I use it in code, Eclipse auto completion gives me setMapParam(Map<String, Integer> p)
even though in the binary is like setMapParam(Map p)
.
How does Eclipse now the type (Map<String, Integer>
) even if the method signature has been type erased (to Map
)? Or am I missing something?