What is reifiable and non-reifiable java ?
a reifiable type is one whose runtime representation contains same information than its compile-time representa-tion
a non-reifiable type is one whose runtime representation contains less information than its compile-time representa-tion
Arrays are reifiable as arrays remains as it is at runtime While generic information attached with List is erased at runtime by erasures
So List<String> list=new ArrayList<String>
at runtime will be
List list=new ArrayList();
all generic information is erased. This is done to support the legacy code that is written without using generics.
But in case of arrays
Object[] ojb=new Object[0]
will remain the same at runtime as well. Generics are not mixed with arrays.
a reifiable type is one whose runtime representation contains same information than its compile-time representa-tion
a non-reifiable type is one whose runtime representation contains less information than its compile-time representa-tion
Arrays are reifiable as arrays remains as it is at runtime While generic information attached with List is erased at runtime by erasures
So List<String> list=new ArrayList<String>
at runtime will be
List list=new ArrayList();
all generic information is erased. This is done to support the legacy code that is written without using generics.
But in case of arrays
Object[] ojb=new Object[0]
will remain the same at runtime as well. Generics are not mixed with arrays.
No comments:
Post a Comment