3

Что значит - типы, полностью доступные во время выполнения (reifiable types)?

1 ответ 1

7

The Java™ Tutorials

A reifiable type is a type whose type information is fully available at runtime. This includes primitives, non-generic types, raw types, and invocations of unbound wildcards.

Non-reifiable types are types where information has been removed at compile-time by type erasure — invocations of generic types that are not defined as unbounded wildcards. A non-reifiable type does not have all of its information available at runtime. Examples of non-reifiable types are List<String> and List<Number>; the JVM cannot tell the difference between these types at runtime. As shown in Restrictions on Generics, there are certain situations where non-reifiable types cannot be used: in an instanceof expression, for example, or as an element in an array.

Reifiable тип это тип информация о котором полностью доступна во время выполнения программы. Такие типы включают примитивы, не обобщенные типы, сырые типы(List list = new LinkedList();) и вызовы unbound wildcards (например List<?> list).

Non-reifiable типы это типы где информация была удалена во время компиляции механизмом стирания типов - вызовы обобщенных типов которые не определены как unbounded wildcards. У Non-reifiable типов вся эта информация не доступна во время работы программы. Примеры таких типов это List<String> и List<Number>; виртуальная машина Java не может определить разницу между такими типами во время выполнения программы. Как показано в "Ограничения Обобщений", существуют определенные ситуации когда non-reifiable типы не могут быть использованы: например c выражением instanceof или как элемент массива.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.