Java Annotations – Why Use @Native Annotations?

javajava8

link : http://download.java.net/jdk8/docs/api/java/lang/annotation/Native.html

In Java 8, there will be @Native annotations.

Indicates that a field defining a constant value may be referenced from native code. The annotation may be used as a hint by tools that generate native header files to determine whether a header file is required, and if so, what declarations it should contain.

Problem is: What for?
Do you have any idea on which problematics would be efficiently solved by this feature?

Best Answer

Imagine a header which defines constants to be used in messaging. One party of the conversation might be developed in C++, and they'd like to #include a header. Now maintaining two similar but separate files is a risk; deriving the C++ header from @Native constants is safer.