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


3 Responses to “@license and @copyright in Java 7 ?”  

  1. Gravatar Icon 1 Stephen Colebourne

    You should probably chat to JSR-305/JSR-308 first before thinking about a new JSR.

  2. Gravatar Icon 2 stephan

    Thought about that, but it’s neither about defect prevention (JSR 305) nor about new places for annotations (JSR 308). But it should be a good idea to talk to the leads. Thanks.

  3. Gravatar Icon 3 Geoffrey Wiseman

    I was thinking of an @License annotation the other day; what I’d really love is the ability to report on the @License of a project and its dependencies, and, ideally, establish some rules about it, and put that into a Maven plugin or something equally re-usable.

    For instance, if you’re building a commercial application, you might want to exclude GPL dependencies, or generate a report that can be reviewed regularly to ensure that you meet some license compliance goals.

Leave a Reply



RSS