3

Why is FunctionalInterface's retention policy RetentionPolicy.RUNTIME and not RetentionPolicy.CLASS.

As far as i know this annotation is in place only to ensure that the interface does not have more than one method besides static and default ones.

Rahul
  • 866
  • 8
  • 19
  • 2
    "RetentionPolicy.RUNTIME - Annotations are to be recorded in the class file by the compiler and retained by the VM at run time, so they may be read reflectively."... well, maybe you want to be able to use reflection to determine if an interface is a functional one? – daniu Jan 15 '18 at 11:46
  • we can create functional interface w/o using this annotation, and i mentioned couple of its uses at compile time. I cant think of a scenario where this is needed at runtime. – Rahul Jan 15 '18 at 11:52
  • see this answer: https://stackoverflow.com/questions/35496105/how-does-functionalinterface-influence-the-jvms-runtime-behavior essentially functional is part of platform and not only part of the language - this way other JVM based languages, or tools can benefit from having access to functional aspects. – diginoise Jan 15 '18 at 12:10

0 Answers0