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

10,508

Solution 1

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.

Solution 2

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.

Solution 3

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

Share:
10,508

Related videos on Youtube

mahonya
Author by

mahonya

Updated on January 02, 2021

Comments

  • mahonya
    mahonya over 3 years

    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.

    • Goibniu
      Goibniu over 13 years
      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.
    • Buhake Sindi
      Buhake Sindi over 13 years
      Can you provide me a link about Oracle's announcement and of IBM's?
    • JasonMArcher
      JasonMArcher almost 9 years
      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 and here for details, and the help center for more.
  • mahonya
    mahonya over 13 years
    Ah, so this is the road out of this mess! Thanks Chris, I was having a bad day thinking about this :)
  • Martijn Verburg
    Martijn Verburg over 13 years
    +1 This is a common misconception
  • Yudhistira Arya
    Yudhistira Arya over 7 years
    @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
    Yudhistira Arya over 7 years
    @Don This is one of my concern when bundling OpenJDK with commercial application since Hotspot itself is only GPLv2 without any classpath exception.
  • Chris Lercher
    Chris Lercher over 7 years
    @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.
  • Prashant
    Prashant about 6 years
    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").
  • Gerald Holmann
    Gerald Holmann over 5 years
    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
    Gerald Holmann over 5 years
    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.
  • Chris Lercher
    Chris Lercher over 5 years
    @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.
  • Stephen C
    Stephen C about 4 years
    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.