@license and @copyright in Java 7 ?
Alex wrote in his latest Java 7 Roundup about my idea of a @license and Paul’s @copyright addendum. I wrote about the idea here.
@License(name = "Apache",version = "2.0")
@Copyright(owner = "Stephan Schmidt")
public class Example {
public void doWhatever() { ... }
}
In the comments of that post Paul Hammant mentioned a @copyright annotation, which could help verify the copyright status of code. The best and easiest way to use @license and @copyright would be to add it at the package level. Few people know that Java got a package level construct called package-info.java where developers can add package level annotations:
“Typically package-info.java contains only a package declaration, preceded immediately by the annotations on the package.”
Hopefully such an annotation would be implemented as a Java standard and used by all major DI containers like Spring, Guice and Apache Composer, because as I wrote in the comments:
“A container could know about licenses and issue a warning when injecting incompatible stuff. This would make some managers in companies happy.”
As I want to pursue the idea further, it would be best to move this with a short JSR into Java 7.
You can leave a Reply here. Of course, you should follow me on twitter here.
You should probably chat to JSR-305/JSR-308 first before thinking about a new JSR.