-3

Is it true that if I copy and change the sourcecode of java and use it in my commercial software, then my complete program will get GPL?

I need to change a function of TreeMap.

Christian Wilkie
  • 3,693
  • 5
  • 34
  • 49
lalelu
  • 103
  • 9
  • 3
    class MyOwnTreeMap extends TreeMap { void myShinyFunction(){...} } -> no licensing issues? – escitalopram Jul 15 '14 at 20:13
  • You shouldn't need to change java source code. As escitalopram mentioned, you can simply extend any classes you want to change, and can override existing methods or add new ones. – forgivenson Jul 15 '14 at 20:16
  • But if i override, i can't access on privat member variables... ;( I will Add a Note to a TreeMap without creating a new Note. – lalelu Jul 15 '14 at 20:23
  • 1
    This is silly. You don't have the capability to do what you're suggesting. Learn to program first. – Software Engineer Jul 15 '14 at 20:28
  • You are not supposed to change the java source code for many reasons. Create your own data structure and benefit from existing Java data structure by inheritance (if needed). You can have access to private methods and variables from java reflection, but this is an advanced feature and most of the time (99.999999%) you don't need it. – pms Jul 15 '14 at 20:36
  • I'm sorry my english is not the best and I've expressed myself wrong. I dont like to change the source code. I will wirte my own TreeMap which can add Notes instead of Key and Value. For this i must access to the private virables "root" and "size" and the private method "fixAfterInsertion". if i overwrite TreeMap i wont have access to this functions. I don't figure how this will work with reflection. – lalelu Jul 15 '14 at 21:28
  • The problem is, i want get the notes from one map, change the entrys (key and value) and put it in a new map. So i recycle the entrys and the GC has no work. But i dont know how i can solve this problem.. – lalelu Jul 16 '14 at 10:03
  • @leony I really don't get what you want. There is no such method (`fixAfterInsertion`) in Java TreeMap (neither public not private). Anyways, for accessing private methods using java reflection have a look at this link: http://stackoverflow.com/questions/880365/any-way-to-invoke-a-private-method – pms Jul 16 '14 at 17:49
  • Why don't you use just HashMap? Ho do you know you recycle the entries so that GC has nothing to do? If your keys and values are String (or any immutable object) then when you change them you are creating new object of them. So anyways, GC needs to clean up after you. My suggestion is to just worry about your logic and not GC. – pms Jul 16 '14 at 17:54

1 Answers1

1

You should not change the sourcecode of TreeMap, instead you should extend it as escitalopram said in the comments:

class MyTreeMap extends TreeMap {
    void myShinyFunction() { ... }

    @Override
    void someNiceFunctionInTreeMap() { ... }
}

If you are not extending the functionality of TreeMap (for example, you want to change the private methods/fields rather than public API for some reason), then you should implement a new class yourself rather than modifying the source code.

But to try and answer your original question directly:

As far as I understand, Java SE is under the Oracle Binary Code license:

Java SE continues to be available under the Oracle Binary Code License (BCL) free of charge.

and the OpenJDK source code is released under GPL v2:

What open-source license is OpenJDK published under?

GPL v2 for almost all of the virtual machine, and GPL v2 + the Classpath exception for the class libraries and those parts of the virtual machine that expose public APIs.

If you modified the OpenJDK source code and put that in your commercial program, then from my understanding your entire program would need to be GPL. However, I'm not a lawyer, and this information may very well be incorrect. Consulting with one would be a good idea if you plan on doing this.

Christian Wilkie
  • 3,693
  • 5
  • 34
  • 49
  • If i implement a new class myself, than i copy a TreeMap, only one function will be different. This will be also GPL? – lalelu Jul 15 '14 at 21:34
  • @leony As far as I understand - yes. See this part of the [GPL FAQ](http://www.gnu.org/licenses/gpl-faq.html#GPLCommercially) `If I use a piece of software that has been obtained under the GNU GPL, am I allowed to modify the original code into a new program, then distribute and sell that new program commercially?` Answer: `You are allowed to sell copies of the modified program commercially, but only under the terms of the GNU GPL.` Again - I am not a lawyer and this should not be taken as legal advice. I again recommend consulting one. – Christian Wilkie Jul 15 '14 at 21:43