26

With the current developments regarding Oracle announcing its intention to charge for a pro (or whatever you call it) version of JVM, and IBM announcing its intention to support OpenJDK, things are getting quite complicated for a large set of Java developers. We have a large piece of work in Java, and we did not have any issues in choosing our licensing terms up until now. It appears that we'll have to switch to OpenJDK where IBM will be putting their support. But OpenJDK is GPL V2, and as far as I know, any code linking to GPL V2 must be GPL V2. We also have some JNI code, which is going to get even larger. Given these facts, does it mean that if we use OpenJDK to run our software, we'll have to switch to GPL for our licensing? Needless to say, this would blow away our whole licensing & business model setup.

mahonya
  • 9,247
  • 7
  • 39
  • 68
  • My understanding of this is that so long as you are not extending the JVM you don't have to worry about what licence the code is released under. Now if your code extends the OpenJDK then you might have issues, but 99.999% (I made that up) of users only use it as a VM. – Goibniu Nov 10 '10 at 10:55
  • Can you provide me a link about Oracle's announcement and of IBM's? – Buhake Sindi Nov 10 '10 at 10:56
  • 4
    I'm voting to close this question as off-topic because it is about licensing or legal issues, not programming or software development. [See here](http://meta.stackoverflow.com/questions/274963/questions-about-licensing/274964#274964) and [here](http://meta.stackexchange.com/questions/139804/can-licensing-questions-ever-be-on-topic) for details, and the [help] for more. – JasonMArcher Jun 11 '15 at 20:15

3 Answers3

38

The license for OpenJDK is not "GPL v2", it's "GPL v2 with the Classpath Exception". Quote:

As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library.

Chris Lercher
  • 37,264
  • 20
  • 99
  • 131
  • 1
    Ah, so this is the road out of this mess! Thanks Chris, I was having a bad day thinking about this :) – mahonya Nov 10 '10 at 11:02
  • +1 This is a common misconception – Martijn Verburg Nov 10 '10 at 12:03
  • 1
    @[Chris Lercher](http://stackoverflow.com/users/291741/chris-lercher) but the OpenJDK by default carry HotSpot which only licensed as GPLv2 (no classpath exception). Isn't it still a legal risk if you bundle OpenJDK (With Hotspot) in your closed source commercial application? – Yudhistira Arya Dec 18 '16 at 13:08
  • 1
    @YudhistiraArya I cannot tell you, that there is no legal risk (I guess there always is). I would say, that it depends mostly on the question if you _link_ your code with GPL code or not. – Chris Lercher Dec 19 '16 at 17:05
  • Actually thats not completely true, there is also a "ASSEMBLY_EXCEPTION" license for OpenJDK which states some OpenJDK code is purely GPL. Its quite confusing (especially since that exception talks about "Sun"). – eckes Feb 26 '18 at 14:21
  • I looked at the section with the classpath exception, and in our reading, the exception only applies to "certain source files distributed by Oracle" that specifically have to have a notice calling this exception that they are subject to this exception. From this reading, the exception does not seem to apply to anything else, and so the application that bundles the OpenJDK seems to be still bound by the GPLv2. – Gerald Holmann Nov 02 '18 at 16:46
  • 1
    @GeraldHolmann The question is not about bundling, it's about linking code. In any case, it is definitely necessary to check, which exact files the Classpath Exception applies to. – Chris Lercher Nov 02 '18 at 18:01
17

Do I need to open my source code if I use OpenJDK as JVM?

Absolutely not.

There are many commercial, closed-source Java applications out there that use OpenJDK-based JVMs. The "Classpath exception" that @Chris Lercher mentions specifically makes this legal.

Incidentally, the "Classpath exception" was invented by FSF's lawyers specifically to allow the GNU Classpath libraries (a cleanroom reimplementation of the Java SE libraries) to be used to run proprietary / closed source applications. Hence, the name ...

The only cases where you would need to worry are things like:

  • Closed source JVMs that make use of the OpenJDK code base in their implementation.
  • Closed source applications that contain modified copies of OpenJDK classes without including source code for the modifications.
  • Closed source applications that link to certain OpenJDK GPLv2 classes that are not marked as with the Classpath exception.

In OpenJDK 11, the last category seems to consist of a large number of "test" classes that are not included in an OpenJDK distro anyway, and internal classes that you shouldn't (and probably can't) link to in an application. These classes are easy to identify. Search for Java source files in the OpenJDK source tree that contain the word "GNU" and not the word "Classpath"

It is worth noting that a significant proportion of the OpenJDK Java code base is 3rd-party code with permissive open source licenses. Linking to those classes is permitted.

Bundling OpenJDK with closed-source is not a problem. The GPL permits you to distribute binaries for GPL software together with binaries for closed source software.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • See my comment in the above answer: The classpath exception seems to apply only to some Oracle source code, not to any commercial product that uses the OpenJDK. – Gerald Holmann Nov 02 '18 at 16:48
  • The classpath exception refers to *this license* which is a license for Java. There is no requirement for a supplier (commercial or otherwise) of software implemented in Java to include the same exception in their license. – Stephen C Mar 27 '20 at 13:03
9

Please read the lines at the beginning of the classpath exception. The classpath exception doesn't seem to apply to the entire library.

Certain source files distributed by Sun Microsystems, Inc. are subject to the following clarification and special exception to the GPL, but only where Sun has expressly included in the particular source file's header the words "Sun designates this particular file as subject to the "Classpath" exception as provided by Sun in the LICENSE file that accompanied this code."

Don
  • 91
  • 1
  • 3
    @[Don](http://stackoverflow.com/users/542434/don) This is one of my concern when bundling OpenJDK with commercial application since Hotspot itself is only GPLv2 without any classpath exception. – Yudhistira Arya Dec 18 '16 at 13:12