Вопрос

What will happen when a Class or Interface who is annotated with an annotation of RetentionPolicy#RUNTIME is loaded in old JREs?

@FunctionalInterface // Java8 @Retention(RetentionPolicy.RUNTIME)
public interface MyFunctional {
}

Is above interface or any class implement that interface can run in JRE 7 or older?

Это было полезно?

Решение

Annotations are handled slightly different than other normal classes. If the JVM cannot load the annotation class for a runtime annotation, this annotation will be dropped and you cannot find hints anymore that there was an annotation.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top