Thursday 28 January 2021

Java9: Annotations pipeline 2.0

Annotation is a kind of metadata, that do not directly affect program semantics, but they do affect the way programs are treated by tools and libraries, which can in turn affect the semantics of the running program. Annotations can be read from source files, class files, or reflectively at run time.

 

What changed for Developers?

From developers point of view there is no change. This is enhancement from javac end. As part of Java8 release, there are couple of features (Repeating Annotations ‘JEP 120’ and Annotations on Java Types ‘JSR 308 / JEP 104’) that impact the annotations. In addition to this, Lambda Expressions (JSR 335 / JEP 126) added new syntactic position for annotations.

 

These features can be combined and can lead to following pattern.

 

Function<String, String> fss = (@Annotation @Annotation String s) -> s;

 

This kind of snippets are not handled out of the box. To address this issue, javac code is refactored and improved.

 

Reference

https://openjdk.java.net/jeps/217

Previous                                                    Next                                                    Home

No comments:

Post a Comment