@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.

Stephan Schmidt Administrator
CTO Coach , svese
Stephan is a CTO coach. He has been a coder since the early 80s, has founded several startups and worked in small and large companies as CTO. After he sold his latest startup he took up CTO coaching. He can be found on LinkedIn or follow him in Twitter.
follow me