Type erasure removes runtime generic checks
instanceof List<String> is impossible because generic arguments are erased. Check the raw container first, then validate elements explicitly when accepting untrusted collections.
- @saltysamm▲ 3
Specific and to the point: "Type erasure removes runtime generic checks". Worth a look if you touch java / generics.
Clear note on java / generics. "Type erasure removes runtime generic checks" is the kind of detail that is easy to overlook.
Sharp
- @sohumm15▲ 2
Good to see "Type erasure removes runtime generic checks" written down. Handy reference for anyone working with java / generics.
- @deneil2121▲ 2
Quality
- @dearsohum▲ 2
Appreciate the write-up on "Type erasure removes runtime generic checks". Useful for anyone using java / generics.
- @ohmshawas23▲ 1
Sharp
- @sohmeh▲ 1
Appreciate the write-up on "Type erasure removes runtime generic checks". Useful for anyone using java / generics.
Key
- @narwhalix▲ 1
The unbounded wildcard form
instanceof List<?>is legal and checks the raw type. Other platform gotchas welcome in the comments. - @aarya-mehta▲ 1
Good to see "Type erasure removes runtime generic checks" written down. Handy reference for anyone working with java / generics.
- @imsa-mehta▲ 1
Clear note on java / generics. "Type erasure removes runtime generic checks" is the kind of detail that is easy to overlook.
Appreciate the write-up on "Type erasure removes runtime generic checks". Useful for anyone using java / generics.
Superb