Menu

Dependency on LGPL libraries

2009-03-12
2013-05-29
  • Erlend Viddal

    Erlend Viddal - 2009-03-12

    Hello,

    I work on a project considering using JUNG. Our main concern is the licensing; JUNG depends on Colt, of which part of the code is released under LGPL. Since our project already depends on Apache libraries, we cannot link with LGPLed libraries.

    Are there any feasible approaches to using JUNG without LGPL dependencies? Any idea on how much effort it would take to remove the LGPLed parts of Colt?

    Thanks,
    Erlend

     
    • Joshua O'Madadhain

      Erlend:

      I haven't looked at the status of the Colt libraries in JUNG recently.  Whether you need them or not for your purposes at all depends on which parts of the library you're using; if you can say a bit more about what you want to use JUNG for then I could be at least a bit more helpful.  I'm not even sure whether JUNG uses the part of the Colt libraries that's LGPL-licensed; have you checked?  (If it doesn't, you might be able to create your own jar based on a subset of their source.)

      I've considered creating a stripped-down version of Colt (including just the parts that we actually use) with support for generics.  (I'd have to look into the licensing issues for that.)  There are a lot of other things higher on our priority list, though.

      Joshua

       
    • Erlend Viddal

      Erlend Viddal - 2009-03-13

      Joshua,

      Thanks for your quick reply. We primarily need JUNG as a graph and tree data structure, and it would be very useful to have access to algorithms and rudimentary visualization (quite possibly through an intermediary file). Other features of JUNG, such as IO and interactive manipulation of graphs are nice options to have but not strictly necessary for our current plans. We'll consider stripping down and repacking colt without the LGPLed code.

      Thanks,
      Erlend

       
      • Joshua O'Madadhain

        Erlend:

        Here's the most recent scoop on where the Colt stuff is.

        Executive summary: we don't use any of the LGPL stuff (that was all hep.aida stuff), and in fact we never have. 

        I found this stuff by searching for "cern" and "aida" in our source files.  That should cover everything, since one of those strings appears in every Colt import statement.

        I can summarize by saying that what we were using (until a few minutes ago) was
        (1) DoubleMatrix{1,2}D and implementations
        (2) linalg.Algebra
        (3) cern.jet.RandomEngine and implementations
        (4) corejava.Format
        (5) DoubleArrayList

        Some of the instances of (1), and all those of (3), (4), and (5), have been removed.  All instances of (2) are still there.  These changes will be in CVS sometime today.
        (I used to be more worried about the quality of Java's default random number generators.  Later I realized that given how we were using them that it really wasn't that important, so I just now finally got around to removing them.)

        Here's a list of where the libraries {were, are} being used:

        jung-algorithms
        * FRLayout, ISOMLayout: these made very light (and in one case, completely unnecessary) use of (1).  They don't any more.
        * VoltageClusterer, KMeansClusterer: used to use (3), doesn't any more
        * GraphMatrixOperations: not surprisingly, uses (1) and (2) all over the place.
        * RandomWalkSTBetweenness, MarkovCentrality: uses GraphMatrixOperations.

        jung-io
        * MatrixFile: uses (1) and GraphMatrixOperations, used to use (4) and (5)

        So at this point, it's down to GraphMatrixOperations (and the classes that use it, noted above) and MatrixFile (which arguably doesn't really need to use Colt).  That should tell you all you need to know so far as sorting out your dependencies.

        As for creating the stripped-down version of Colt: as you can see, there's really not much left that we're using it for (we used to use it considerably more extensively, but improvements in the Java API made this unnecessary).  So for our current purposes, it's not worth the trouble.

        Hope you find this useful.  And thanks for possibly unintentionally prodding me to reduce our dependency on Colt.  :)

        Joshua

         
    • Erlend Viddal

      Erlend Viddal - 2009-03-18

      Joshua,

      We have looked at stripping out the LGPL code from Colt.
      There were some interdependencies from the methods you mentioned to LGPLed code, so we had to do a few minor modifications to colt itself. The resulting library seems to work with JUNG (it compiles well and all tests run successfully).

      Short description of modifications to Colt and testing with JUNG in order to remove LGPL libraries and their dependencies from colt:

      Removed the following files and directories from colt:
      ----------------------------------------------------------------------
      rm -rf src/hep
      rm -rf src/corejava

      rm src/cern/jet/random/Benchmark.java
      rm src/cern/jet/stat/quantile/Quantile1Test.java
      rm src/cern/colt/matrix/bench/BenchmarkMatrix.java
      rm src/cern/colt/matrix/doublealgo/Statistic.java
      rm src/cern/colt/matrix/doublealgo/Sorting.java
      rm src/cern/colt/matrix/doublealgo/Formatter.java
      rm src/cern/colt/matrix/impl/TestMatrix2D.java
      rm src/cern/colt/matrix/impl/BenchmarkMatrix2D.java
      rm src/cern/colt/GenericSortingTest.java

      ----------------------------------------------------------------------
      Modified a few lines in a couple of files, the patch is attached
      as text below.

      From colt directory:
      patch -p1 < ../colt-1.2.0-colt-1.2.0-remove_dependencies.patch

      ----------------------------------------------------------------------
      The resulting colt.jar file was then put into the maven repository
      ~/.m2/repository to test building JUNG using the modified colt.jar
      file. (Alternatively, the pom.xml files can be modified)

      cp colt-1.2.0-remove_dependencies/lib/colt.jar ~/.m2/repository/colt/colt/1.2.0/colt-1.2.0.jar
      cd ~/.m2/repository/
      sha1sum ./colt/colt/1.2.0/colt-1.2.0.jar > colt/colt/1.2.0/colt-1.2.0.jar.sha1

      # Check:
      sha1sum -c colt/colt/1.2.0/colt-1.2.0.*.sha1

      Checked out from JUNG via CVS:
      cvs -z3 -d:pserver:anonymous@jung.cvs.sourceforge.net:/cvsroot/jung co -P jung2

      Compiling:
      cd jung2
      mvn install

      The tests performed during 'mvn install' run and do not report any
      failures.
      ----------------------------------------------------------------------

      -Erlend

      ----------------------------------------------------------------------
      The patch ( colt-1.2.0-colt-1.2.0-remove_dependencies.patch ) of our changes to colt:

      Only in colt-1.2.0/src/cern/colt: GenericSortingTest.java
      Only in colt-1.2.0/src/cern/colt/matrix/bench: BenchmarkMatrix.java
      Only in colt-1.2.0/src/cern/colt/matrix/doublealgo: Formatter.java
      Only in colt-1.2.0/src/cern/colt/matrix/doublealgo: Sorting.java
      Only in colt-1.2.0/src/cern/colt/matrix/doublealgo: Statistic.java
      diff -ur colt-1.2.0/src/cern/colt/matrix/DoubleMatrix1D.java colt-1.2.0-remove_dependencies/src/cern/colt/matrix/DoubleMatrix1D.java
      --- colt-1.2.0/src/cern/colt/matrix/DoubleMatrix1D.java    2004-02-25 15:25:06.000000000 +0100
      +++ colt-1.2.0-remove_dependencies/src/cern/colt/matrix/DoubleMatrix1D.java    2009-03-18 14:51:27.000000000 +0100
      @@ -544,7 +544,8 @@
        * @see cern.colt.matrix.doublealgo.Formatter
        */
      public String toString() {
      -    return new cern.colt.matrix.doublealgo.Formatter().toString(this);
      +    //    return new cern.colt.matrix.doublealgo.Formatter().toString(this);
      +    return "FIXME: cern.colt.matrix.DoubleMatrix1D.toString";
      }
      /**
        * Constructs and returns a new view equal to the receiver.
      @@ -666,16 +667,16 @@
        * @return  a new view.
        */
      protected abstract DoubleMatrix1D viewSelectionLike(int[] offsets);
      -/**
      -Sorts the vector into ascending order, according to the <i>natural ordering</i>.
      -This sort is guaranteed to be <i>stable</i>.
      -For further information, see {@link cern.colt.matrix.doublealgo.Sorting#sort(DoubleMatrix1D)}.
      -For more advanced sorting functionality, see {@link cern.colt.matrix.doublealgo.Sorting}.
      -@return a new sorted vector (matrix) view.
      -*/
      -public DoubleMatrix1D viewSorted() {
      -    return cern.colt.matrix.doublealgo.Sorting.mergeSort.sort(this);
      -}
      +// /**
      +// Sorts the vector into ascending order, according to the <i>natural ordering</i>.
      +// This sort is guaranteed to be <i>stable</i>.
      +// For further information, see {@link cern.colt.matrix.doublealgo.Sorting#sort(DoubleMatrix1D)}.
      +// For more advanced sorting functionality, see {@link cern.colt.matrix.doublealgo.Sorting}.
      +// @return a new sorted vector (matrix) view.
      +// */
      +// public DoubleMatrix1D viewSorted() {
      +//     return cern.colt.matrix.doublealgo.Sorting.mergeSort.sort(this);
      +// }
      /**
      Constructs and returns a new <i>stride view</i> which is a sub matrix consisting of every i-th cell.
      More specifically, the view has size <tt>this.size()/stride</tt> holding cells <tt>this.get(i*stride)</tt> for all <tt>i = 0..size()/stride - 1</tt>.
      Only in colt-1.2.0-remove_dependencies/src/cern/colt/matrix: DoubleMatrix1D.java~
      diff -ur colt-1.2.0/src/cern/colt/matrix/DoubleMatrix2D.java colt-1.2.0-remove_dependencies/src/cern/colt/matrix/DoubleMatrix2D.java
      --- colt-1.2.0/src/cern/colt/matrix/DoubleMatrix2D.java    2004-02-25 15:25:08.000000000 +0100
      +++ colt-1.2.0-remove_dependencies/src/cern/colt/matrix/DoubleMatrix2D.java    2009-03-18 14:52:41.000000000 +0100
      @@ -490,7 +490,8 @@
        * @see cern.colt.matrix.doublealgo.Formatter
        */
      public String toString() {
      -    return new cern.colt.matrix.doublealgo.Formatter().toString(this);
      +    //    return new cern.colt.matrix.doublealgo.Formatter().toString(this);
      +    return "FIXME: cern.colt.matrix.DoubleMatrix2D.toString";
      }
      /**
        * Constructs and returns a new view equal to the receiver.
      @@ -776,17 +777,17 @@
        * @return  a new view.
        */
      protected abstract DoubleMatrix2D viewSelectionLike(int[] rowOffsets, int[] columnOffsets);
      -/**
      -Sorts the matrix rows into ascending order, according to the <i>natural ordering</i> of the matrix values in the given column.
      -This sort is guaranteed to be <i>stable</i>.
      -For further information, see {@link cern.colt.matrix.doublealgo.Sorting#sort(DoubleMatrix2D,int)}.
      -For more advanced sorting functionality, see {@link cern.colt.matrix.doublealgo.Sorting}.
      -@return a new sorted vector (matrix) view.
      -@throws IndexOutOfBoundsException if <tt>column < 0 || column >= columns()</tt>.
      -*/
      -public DoubleMatrix2D viewSorted(int column) {
      -    return cern.colt.matrix.doublealgo.Sorting.mergeSort.sort(this,column);
      -}
      +// /**
      +// Sorts the matrix rows into ascending order, according to the <i>natural ordering</i> of the matrix values in the given column.
      +// This sort is guaranteed to be <i>stable</i>.
      +// For further information, see {@link cern.colt.matrix.doublealgo.Sorting#sort(DoubleMatrix2D,int)}.
      +// For more advanced sorting functionality, see {@link cern.colt.matrix.doublealgo.Sorting}.
      +// @return a new sorted vector (matrix) view.
      +// @throws IndexOutOfBoundsException if <tt>column < 0 || column >= columns()</tt>.
      +// */
      +// public DoubleMatrix2D viewSorted(int column) {
      +//     return cern.colt.matrix.doublealgo.Sorting.mergeSort.sort(this,column);
      +// }
      /**
      Constructs and returns a new <i>stride view</i> which is a sub matrix consisting of every i-th cell.
      More specifically, the view has <tt>this.rows()/rowStride</tt> rows and <tt>this.columns()/columnStride</tt> columns holding cells <tt>this.get(i*rowStride,j*columnStride)</tt> for all <tt>i = 0..rows()/rowStride - 1, j = 0..columns()/columnStride - 1</tt>.
      Only in colt-1.2.0-remove_dependencies/src/cern/colt/matrix: DoubleMatrix2D.java~
      diff -ur colt-1.2.0/src/cern/colt/matrix/DoubleMatrix3D.java colt-1.2.0-remove_dependencies/src/cern/colt/matrix/DoubleMatrix3D.java
      --- colt-1.2.0/src/cern/colt/matrix/DoubleMatrix3D.java    2004-02-25 15:25:06.000000000 +0100
      +++ colt-1.2.0-remove_dependencies/src/cern/colt/matrix/DoubleMatrix3D.java    2009-03-18 14:53:25.000000000 +0100
      @@ -484,7 +484,8 @@
        * @see cern.colt.matrix.doublealgo.Formatter
        */
      public String toString() {
      -    return new cern.colt.matrix.doublealgo.Formatter().toString(this);
      +    //    return new cern.colt.matrix.doublealgo.Formatter().toString(this);
      +    return "FIXME: cern.colt.matrix.DoubleMatrix3D.toString";
      }
      /**
        * Constructs and returns a new view equal to the receiver.
      @@ -741,17 +742,17 @@
      public DoubleMatrix3D viewSliceFlip() {
           return (DoubleMatrix3D) (view().vSliceFlip());
      }
      -/**
      -Sorts the matrix slices into ascending order, according to the <i>natural ordering</i> of the matrix values in the given <tt>[row,column]</tt> position.
      -This sort is guaranteed to be <i>stable</i>.
      -For further information, see {@link cern.colt.matrix.doublealgo.Sorting#sort(DoubleMatrix3D,int,int)}.
      -For more advanced sorting functionality, see {@link cern.colt.matrix.doublealgo.Sorting}.
      -@return a new sorted vector (matrix) view.
      -@throws IndexOutOfBoundsException if <tt>row < 0 || row >= rows() || column < 0 || column >= columns()</tt>.
      -*/
      -public DoubleMatrix3D viewSorted(int row, int column) {
      -    return cern.colt.matrix.doublealgo.Sorting.mergeSort.sort(this,row,column);
      -}
      +// /**
      +// Sorts the matrix slices into ascending order, according to the <i>natural ordering</i> of the matrix values in the given <tt>[row,column]</tt> position.
      +// This sort is guaranteed to be <i>stable</i>.
      +// For further information, see {@link cern.colt.matrix.doublealgo.Sorting#sort(DoubleMatrix3D,int,int)}.
      +// For more advanced sorting functionality, see {@link cern.colt.matrix.doublealgo.Sorting}.
      +// @return a new sorted vector (matrix) view.
      +// @throws IndexOutOfBoundsException if <tt>row < 0 || row >= rows() || column < 0 || column >= columns()</tt>.
      +// */
      +// public DoubleMatrix3D viewSorted(int row, int column) {
      +//     return cern.colt.matrix.doublealgo.Sorting.mergeSort.sort(this,row,column);
      +// }
      /**
      Constructs and returns a new <i>stride view</i> which is a sub matrix consisting of every i-th cell.
      More specifically, the view has <tt>this.slices()/sliceStride</tt> slices and <tt>this.rows()/rowStride</tt> rows and <tt>this.columns()/columnStride</tt> columns
      Only in colt-1.2.0-remove_dependencies/src/cern/colt/matrix: DoubleMatrix3D.java~
      Only in colt-1.2.0/src/cern/colt/matrix/impl: BenchmarkMatrix2D.java
      diff -ur colt-1.2.0/src/cern/colt/matrix/impl/FormerFactory.java colt-1.2.0-remove_dependencies/src/cern/colt/matrix/impl/FormerFactory.java
      --- colt-1.2.0/src/cern/colt/matrix/impl/FormerFactory.java    2004-02-25 15:25:18.000000000 +0100
      +++ colt-1.2.0-remove_dependencies/src/cern/colt/matrix/impl/FormerFactory.java    2009-03-18 14:55:10.000000000 +0100
      @@ -47,16 +47,19 @@
      public Former create(final String format) {
           return new Former() {
               //private FormatStringBuffer f = (format!=null ? new corejava.FormatStringBuffer(format) : null);
      -        private corejava.Format f = (format!=null ? new corejava.Format(format) : null);
      +        //private corejava.Format f = (format!=null ? new corejava.Format(format) : null);
               //private corejava.PrintfFormat f = (format!=null ? new corejava.PrintfFormat(format) : null);
      +            private java.util.Formatter f = new java.util.Formatter();
      +
               public String form(double value) {
      -            if (f==null || value == Double.POSITIVE_INFINITY || value == Double.NEGATIVE_INFINITY || value != value) {
      +            if (value == Double.POSITIVE_INFINITY || value == Double.NEGATIVE_INFINITY || value != value) {
                       // value != value <==> Double.isNaN(value)
                       // Work around bug in corejava.Format.form() for inf, -inf, NaN
                       return String.valueOf(value);
                   }
      +            return f.format("%G", value).toString();
               //return f.format(value).toString();
      -        return f.format(value);
      +        //return f.format(value);
               //return f.sprintf(value);
               }
           };
      Only in colt-1.2.0-remove_dependencies/src/cern/colt/matrix/impl: FormerFactory.java~
      Only in colt-1.2.0/src/cern/colt/matrix/impl: TestMatrix2D.java
      diff -ur colt-1.2.0/src/cern/colt/matrix/linalg/Property.java colt-1.2.0-remove_dependencies/src/cern/colt/matrix/linalg/Property.java
      --- colt-1.2.0/src/cern/colt/matrix/linalg/Property.java    2004-02-25 15:25:20.000000000 +0100
      +++ colt-1.2.0-remove_dependencies/src/cern/colt/matrix/linalg/Property.java    2009-03-18 14:44:35.000000000 +0100
      @@ -214,7 +214,8 @@
        */
      public void checkRectangular(DoubleMatrix2D A) {
           if (A.rows() < A.columns()) {
      -        throw new IllegalArgumentException("Matrix must be rectangular: "+cern.colt.matrix.doublealgo.Formatter.shape(A));
      +        //        throw new IllegalArgumentException("Matrix must be rectangular: "+cern.colt.matrix.doublealgo.Formatter.shape(A));
      +        throw new IllegalArgumentException("Matrix must be rectangular: ");
           }
      }
      /**
      @@ -222,7 +223,8 @@
        * @throws IllegalArgumentException if <tt>A.rows() != A.columns()</tt>.
        */
      public void checkSquare(DoubleMatrix2D A) {
      -    if (A.rows() != A.columns()) throw new IllegalArgumentException("Matrix must be square: "+cern.colt.matrix.doublealgo.Formatter.shape(A));
      +    //    if (A.rows() != A.columns()) throw new IllegalArgumentException("Matrix must be square: "+cern.colt.matrix.doublealgo.Formatter.shape(A));
      +    if (A.rows() != A.columns()) throw new IllegalArgumentException("Matrix must be square: ");
      }
      /**
        * Returns the matrix's fraction of non-zero cells; <tt>A.cardinality() / A.size()</tt>.
      Only in colt-1.2.0-remove_dependencies/src/cern/colt/matrix/linalg: Property.java~
      Only in colt-1.2.0/src/cern/jet/random: Benchmark.java
      Only in colt-1.2.0/src/cern/jet/stat/quantile: Quantile1Test.java
      Only in colt-1.2.0/src: corejava
      Only in colt-1.2.0/src: hep

       

Log in to post a comment.