Question

Assume that I have library X which contains class A with method b and that library X is realeased under GPL licence.

public class A {
  public void b() {
     // this is an example of b method's body. But assume that the body of method b 
     // is very complex
     System.out.println("operation a");
     System.out.println("operation b");
     System.out.prinltn("operation c");
   }    
}

Assume that I am using library X and that I need a behaviour similar to the behaviour of the method b but with one addtition which I cannot achieve by simple extension of class A and overriding some of theirs methods.

The first question is: May I extend class A and override method b in shown below way and is it really still allowed by the GPL licence.

public class AExt extends A {
  public void b() {
     // this is an example of b method's body. But assume that the body of method b 
     // is very complex
     System.out.println("operation a");
     System.out.println("operation b");
     doOperationINeed();
     System.out.prinltn("operation c");
   }    
}

The 2nd question is: Which from the common used opensource licences allow such extension and which do not?

Was it helpful?

Solution

That depends on what you mean exactly by "allow". All free software licenses (see http://opensource.org/licenses/alphabetical ) will allow such code. What you are doing is typically not considered a modification but rather just using the code/library. If you were to change the code of the original class it would be a modification.

However the nature of GPL is that it is "viral" that means that any application you might be writing that uses GPL code must be licensed under the terms of the GPL or a compatible license (AGPL for example) as well. You can try to lawyer this because of the dynamic linking nature of java, this however is shaky ground and you might want to ask a (few) lawyer(s) about it.

A weaker free software license would allow you to use the code without "infecting" your code with it's license examples of such licenses are Apache Software License, Eclipse Public License, LGPL (as you are not actually modifying code but using the library and subclassing a class you won't even have to redistributed "modified" sourcecode), BSD, MIT, zlib, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top