We all know that, at compile-time, the compiler has full type information available but this information is intentionally dropped in general when the binary code is generated, in a process known as type erasure.
So to put in different words this feature is offered by javac :)
So to put in different words this feature is offered by javac :)
one needs to realize the concept of type erasure derives from a need of compatibility with previous versions of java.
- Source compatibility (Nice to have...)
- Binary compatibility (Must have!)
- Migration compatibility
- Existing programs must continue to work
- Existing libraries must be able to use generic types
- Must have!
This is done this way due
to compatibility issues... The intention of language designers was
providing full source code compatibility and full binary code
compatibility between versions of the platform. If it was implemented
differently, you would have to recompile your legacy applications when
you migrate to newer versions of the platform. The way it was done, all
method signatures are preserved (source code compatibility) and you
don't need to recompile anything (binary compatibility).
No comments:
Post a Comment