[Git][java-team/snappy-java][upstream] New upstream version 1.1.10.7

Tony Mancill (@tmancill) gitlab at salsa.debian.org
Mon Nov 18 03:48:12 GMT 2024



Tony Mancill pushed to branch upstream at Debian Java Maintainers / snappy-java


Commits:
a277dd2b by tony mancill at 2024-11-17T19:01:38-08:00
New upstream version 1.1.10.7
- - - - -


17 changed files:

- .github/workflows/build-native.yml
- .github/workflows/release-drafter.yml
- .github/workflows/release.yml
- .github/workflows/snapshot.yml
- .github/workflows/test.yml
- .scalafmt.conf
- Makefile.common
- build.sbt
- project/build.properties
- project/plugins.sbt
- src/main/java/org/xerial/snappy/OSInfo.java
- src/main/java/org/xerial/snappy/SnappyFramed.java
- src/main/java/org/xerial/snappy/SnappyFramedInputStream.java
- src/main/java/org/xerial/snappy/SnappyFramedOutputStream.java
- + src/main/resources/META-INF/native-image/org.xerial.snappy/snappy-java/resource-config.json
- src/test/java/org/xerial/snappy/SnappyHadoopCompatibleOutputStreamTest.java
- src/test/java/org/xerial/snappy/SnappyOutputStreamTest.java


Changes:

=====================================
.github/workflows/build-native.yml
=====================================
@@ -31,7 +31,7 @@ jobs:
     steps:
       - uses: actions/checkout at v4
       - name: Setup cmake
-        uses: jwlawson/actions-setup-cmake at v1.14
+        uses: jwlawson/actions-setup-cmake at v2.0
         with:
           cmake-version: '3.16.x'
       - name: Build native libraries
@@ -40,7 +40,7 @@ jobs:
           OCI_EXE: docker
       - name: Create Pull Request
         if: ${{ github.event_name != 'pull_request' }}
-        uses: peter-evans/create-pull-request at v5
+        uses: peter-evans/create-pull-request at v7
         with:
           title: Update native libraries
           commit-message: Update native libraries for ${{ github.sha }}


=====================================
.github/workflows/release-drafter.yml
=====================================
@@ -22,6 +22,6 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       # Runs only pull-request labeler
-      - uses: release-drafter/release-drafter at v5
+      - uses: release-drafter/release-drafter at v6
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


=====================================
.github/workflows/release.yml
=====================================
@@ -17,7 +17,7 @@ jobs:
       # Fetch all tags so that sbt-dynver can find the previous release version
       - run: git fetch --tags -f
       # Install OpenJDK 11
-      - uses: actions/setup-java at v3
+      - uses: actions/setup-java at v4
         with:
           distribution: 'zulu'
           java-version: '11'


=====================================
.github/workflows/snapshot.yml
=====================================
@@ -27,7 +27,7 @@ jobs:
       - uses: olafurpg/setup-scala at v14
         with:
           java-version: adopt at 1.11
-      - uses: actions/cache at v3
+      - uses: actions/cache at v4
         with:
           path: ~/.cache
           key: ${{ runner.os }}-snapshot-${{ hashFiles('**/*.sbt') }}


=====================================
.github/workflows/test.yml
=====================================
@@ -31,67 +31,22 @@ jobs:
       - uses: actions/checkout at v4
       - name: scalafmt test
         run: ./sbt scalafmtCheckAll
-  test:
-    name: test jdk11
+  test-jdk:
+    strategy:
+      matrix:
+        version: [ '8', '11', '17', '21' ]
+    name: test jdk${{ matrix.version }}
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout at v4
-      - uses: actions/setup-java at v3
+      - uses: actions/setup-java at v4
         with:
           distribution: 'zulu'
-          java-version: '11'
-      - uses: actions/cache at v3
+          java-version: ${{ matrix.version }}
+      - uses: actions/cache at v4
         with:
           path: ~/.cache
-          key: ${{ runner.os }}-jdk11-${{ hashFiles('**/*.sbt') }}
-          restore-keys: ${{ runner.os }}-jdk11-
-      - name: Test
-        run: ./sbt test
-  test_jdk8:
-    name: test jdk8
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout at v4
-      - uses: actions/setup-java at v3
-        with:
-          distribution: 'zulu'
-          java-version: '8'
-      - uses: actions/cache at v3
-        with:
-          path: ~/.cache
-          key: ${{ runner.os }}-jdk8-${{ hashFiles('**/*.sbt') }}
-          restore-keys: ${{ runner.os }}-jdk8-
-      - name: Test
-        run: ./sbt test
-  test_jdk17:
-    name: test jdk17
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout at v4
-    - uses: actions/setup-java at v3
-      with:
-        distribution: 'zulu'
-        java-version: '17'
-    - uses: actions/cache at v3
-      with:
-        path: ~/.cache
-        key: ${{ runner.os }}-jdk17-${{ hashFiles('**/*.sbt') }}
-        restore-keys: ${{ runner.os }}-jdk17-
-    - name: Test
-      run: ./sbt test
-  test_jdk21:
-    name: test jdk21
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout at v4
-      - uses: actions/setup-java at v3
-        with:
-          distribution: 'zulu'
-          java-version: '21'
-      - uses: actions/cache at v3
-        with:
-          path: ~/.cache
-          key: ${{ runner.os }}-jdk21-${{ hashFiles('**/*.sbt') }}
-          restore-keys: ${{ runner.os }}-jdk21-
+          key: ${{ runner.os }}-jdk${{ matrix.version }}-${{ hashFiles('**/*.sbt') }}
+          restore-keys: ${{ runner.os }}-jdk${{ matrix.version }}-
       - name: Test
         run: ./sbt test


=====================================
.scalafmt.conf
=====================================
@@ -1,4 +1,4 @@
-version = 3.7.14
+version = 3.8.3
 runner.dialect = scala213source3
 maxColumn = 180
 style = defaultWithAlign


=====================================
Makefile.common
=====================================
@@ -51,7 +51,7 @@ endif
 # os=Default is meant to be generic unix/linux
 
 # To support new CPU architecture, add a new target name here
-known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armv6 Linux-armv7 Linux-android-arm Linux-android-aarch64 Linux-aarch64 Linux-ppc Linux-ppc64 Linux-ppc64le Linux-s390 Linux-s390x Mac-x86 Mac-x86_64 Mac-aarch64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 Windows-aarch64 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc AIX-ppc64 Linux-riscv Linux-riscv64
+known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armv6 Linux-armv7 Linux-android-arm Linux-android-aarch64 Linux-aarch64 Linux-ppc Linux-ppc64 Linux-ppc64le Linux-s390 Linux-s390x Mac-x86 Mac-x86_64 Mac-aarch64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 Windows-aarch64 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc AIX-ppc64 Linux-riscv Linux-riscv64 Linux-loongarch Linux-loongarch64
 os_arch := $(OS_NAME)-$(OS_ARCH)
 IBM_JDK_7 := $(findstring IBM, $(shell $(JAVA) -version 2>&1 | grep IBM | grep "JRE 1.7"))
 
@@ -310,6 +310,20 @@ Windows-aarch64_CXXFLAGS  := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mar
 Windows-aarch64_LINKFLAGS := -Wl,--kill-at -shared -static
 Windows-aarch64_LIBNAME   := snappyjava.dll
 
+Linux-loongarch_CXX       := $(CROSS_PREFIX)g++
+Linux-loongarch_STRIP     := $(CROSS_PREFIX)strip
+Linux-loongarch_CXXFLAGS  := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
+Linux-loongarch_LINKFLAGS := -shared
+Linux-loongarch_LIBNAME   := libsnappyjava.so
+Linux-loongarch_SNAPPY_FLAGS:=
+
+Linux-loongarch64_CXX       := $(CROSS_PREFIX)g++
+Linux-loongarch64_STRIP     := $(CROSS_PREFIX)strip
+Linux-loongarch64_CXXFLAGS  := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
+Linux-loongarch64_LINKFLAGS := -shared
+Linux-loongarch64_LIBNAME   := libsnappyjava.so
+Linux-loongarch64_SNAPPY_FLAGS:=
+
 
 CXX        := $($(os_arch)_CXX)
 STRIP     := $($(os_arch)_STRIP)


=====================================
build.sbt
=====================================
@@ -73,12 +73,12 @@ crossPaths       := false
 
 libraryDependencies ++= Seq(
   "junit"               % "junit"              % "4.13.2" % "test",
-  "org.codehaus.plexus" % "plexus-classworlds" % "2.7.0"  % "test",
+  "org.codehaus.plexus" % "plexus-classworlds" % "2.8.0"  % "test",
   "org.xerial.java"     % "xerial-core"        % "2.1"    % "test",
-  "org.wvlet.airframe" %% "airframe-log"       % "23.9.2" % "test",
+  "org.wvlet.airframe" %% "airframe-log"       % "24.9.0" % "test",
   "org.osgi"            % "org.osgi.core"      % "6.0.0"  % "provided",
   "com.github.sbt"      % "junit-interface"    % "0.13.3" % "test",
-  "org.apache.hadoop"   % "hadoop-common"      % "2.10.2" % "test" exclude ("org.xerial.snappy", "snappy-java")
+  "org.apache.hadoop"   % "hadoop-common"      % "3.4.0"  % "test" exclude ("org.xerial.snappy", "snappy-java")
 )
 
 enablePlugins(SbtOsgi)
@@ -110,6 +110,7 @@ OsgiKeys.additionalHeaders := Map(
     "org/xerial/snappy/native/Linux/armv7/libsnappyjava.so;osname=linux;processor=arm_le",
     "org/xerial/snappy/native/Linux/ppc64/libsnappyjava.so;osname=linux;processor=ppc64le",
     "org/xerial/snappy/native/Linux/s390x/libsnappyjava.so;osname=linux;processor=s390x",
+    "org/xerial/snappy/native/Linux/loongarch64/libsnappyjava.so;osname=linux;processor=loongarch64",
     "org/xerial/snappy/native/AIX/ppc/libsnappyjava.a;osname=aix;processor=ppc",
     "org/xerial/snappy/native/AIX/ppc64/libsnappyjava.a;osname=aix;processor=ppc64",
     "org/xerial/snappy/native/SunOS/x86/libsnappyjava.so;osname=sunos;processor=x86",


=====================================
project/build.properties
=====================================
@@ -1,2 +1,2 @@
-sbt.version=1.9.6
+sbt.version=1.10.1
 


=====================================
project/plugins.sbt
=====================================
@@ -1,5 +1,5 @@
-addSbtPlugin("org.xerial.sbt"   % "sbt-sonatype" % "3.9.21")
-addSbtPlugin("com.github.sbt"   % "sbt-pgp"      % "2.2.1")
-addSbtPlugin("com.typesafe.sbt" % "sbt-osgi"     % "0.9.6")
-addSbtPlugin("org.scalameta"    % "sbt-scalafmt" % "2.5.2")
-addSbtPlugin("com.github.sbt"   % "sbt-dynver"   % "5.0.1")
+addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.11.3")
+addSbtPlugin("com.github.sbt" % "sbt-pgp"      % "2.2.1")
+addSbtPlugin("com.github.sbt" % "sbt-osgi"     % "0.10.0")
+addSbtPlugin("org.scalameta"  % "sbt-scalafmt" % "2.5.2")
+addSbtPlugin("com.github.sbt" % "sbt-dynver"   % "5.0.1")


=====================================
src/main/java/org/xerial/snappy/OSInfo.java
=====================================
@@ -48,6 +48,7 @@ public class OSInfo {
     public static final String IBMZ_64 = "s390x";
     public static final String AARCH_64 = "aarch64";
     public static final String RISCV_64 = "riscv64";
+    public static final String LOONGARCH_64 = "loongarch64";
 
     static {
         // x86 mappings
@@ -97,6 +98,9 @@ public class OSInfo {
 
         // RISC-V mappings
         archMapping.put(RISCV_64, RISCV_64);
+
+        // LoongArch64 mappings
+        archMapping.put(LOONGARCH_64, LOONGARCH_64);
     }
 
     public static void main(String[] args) {


=====================================
src/main/java/org/xerial/snappy/SnappyFramed.java
=====================================
@@ -4,6 +4,7 @@
 package org.xerial.snappy;
 
 import java.io.IOException;
+import java.lang.invoke.LambdaMetafactory;
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
@@ -37,21 +38,27 @@ final class SnappyFramed
         Supplier<Checksum> supplier = null;
         try
         {
-            final Class crc32cClazz = Class.forName("java.util.zip.CRC32C");
-            final MethodHandles.Lookup lookup = MethodHandles.publicLookup();
-            
-            final MethodHandle conHandle = lookup.findConstructor(crc32cClazz, MethodType.methodType(void.class))
-                                                 .asType(MethodType.methodType(Checksum.class));
-            supplier = () -> {
-                try
-                {
-                    return (Checksum) conHandle.invokeExact();
-                }
-                catch (Throwable e)
-                {
-                    throw new IllegalStateException(e);
-                }
-            };
+            final Class<?> crc32cClazz = Class.forName("java.util.zip.CRC32C");
+            // using LambdaMetafactory requires a caller sensitive lookup
+            final MethodHandles.Lookup lookup = MethodHandles.lookup();
+            final MethodHandle conHandle = lookup.findConstructor(crc32cClazz, MethodType.methodType(void.class));
+
+            // use LambdaMetafactory to generate an implementation of Supplier<Checksum> which invokes
+            // the java.util.zip.CRC32C default constructor
+            supplier = (Supplier<Checksum>) LambdaMetafactory.metafactory(lookup, 
+                                                                          // method name on Supplier
+                                                                          "get",
+                                                                          // functional interface to be created by factory
+                                                                          MethodType.methodType(Supplier.class),
+                                                                          // type of the functional interface
+                                                                          // uses a generic, so erasure to Object
+                                                                          MethodType.methodType(Object.class), 
+                                                                          // the method handle to call
+                                                                          conHandle,
+                                                                          // type as used at call site
+                                                                          MethodType.methodType(Checksum.class))
+                                                             .getTarget()
+                                                             .invoke();
         }
         catch(Throwable t)
         {


=====================================
src/main/java/org/xerial/snappy/SnappyFramedInputStream.java
=====================================
@@ -16,6 +16,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 import java.nio.channels.Channels;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.ReadableByteChannel;
@@ -28,7 +29,7 @@ import org.xerial.snappy.pool.DefaultPoolFactory;
 
 /**
  * Implements the <a
- * href="http://snappy.googlecode.com/svn/trunk/framing_format.txt"
+ * href="https://github.com/google/snappy/blob/main/framing_format.txt"
  * >x-snappy-framed</a> as an {@link InputStream} and
  * {@link ReadableByteChannel}.
  *
@@ -669,17 +670,9 @@ public final class SnappyFramedInputStream
     private FrameData getFrameData(ByteBuffer content)
             throws IOException
     {
-        return new FrameData(getCrc32c(content), 4);
-    }
-
-    private int getCrc32c(ByteBuffer content)
-    {
-
-        final int position = content.position();
-
-        return ((content.get(position + 3) & 0xFF) << 24)
-                | ((content.get(position + 2) & 0xFF) << 16)
-                | ((content.get(position + 1) & 0xFF) << 8)
-                | (content.get(position) & 0xFF);
+        // the first 4 bytes are the crc32c value in little endian order
+        content.order(ByteOrder.LITTLE_ENDIAN);
+        final int crc32c = content.getInt(content.position());
+        return new FrameData(crc32c, 4);
     }
 }


=====================================
src/main/java/org/xerial/snappy/SnappyFramedOutputStream.java
=====================================
@@ -24,7 +24,7 @@ import org.xerial.snappy.pool.DefaultPoolFactory;
 
 /**
  * Implements the <a
- * href="http://snappy.googlecode.com/svn/trunk/framing_format.txt"
+ * href="https://github.com/google/snappy/blob/main/framing_format.txt"
  * >x-snappy-framed</a> as an {@link OutputStream} and
  * {@link WritableByteChannel}.
  *


=====================================
src/main/resources/META-INF/native-image/org.xerial.snappy/snappy-java/resource-config.json
=====================================
@@ -0,0 +1,11 @@
+{
+  "resources": {
+    "includes": [
+      {"pattern":".*libsnappyjava.dylib"},
+      {"pattern":".*libsnappyjava.so"},
+      {"pattern":".*libsnappyjava.dll"},
+      {"pattern":".*libsnappyjava.a"}
+    ]
+  },
+  "bundles": []
+}
\ No newline at end of file


=====================================
src/test/java/org/xerial/snappy/SnappyHadoopCompatibleOutputStreamTest.java
=====================================
@@ -2,7 +2,6 @@ package org.xerial.snappy;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.SystemUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.compress.SnappyCodec;
 import org.junit.AfterClass;
@@ -25,13 +24,13 @@ public class SnappyHadoopCompatibleOutputStreamTest
     {
         final String libResourceFolder;
         Map<String, String> libraryNames = new LinkedHashMap<>();
-        if (SystemUtils.IS_OS_LINUX) {
+        if (OSInfo.getOSName() == "Linux") {
             libResourceFolder = "/lib/Linux";
             libraryNames.put("libhadoop.so", "libhadoop.so");
             // certain Linux systems need these shared library be copied before the JVM started, see build.sbt
             libraryNames.put("libsnappy.so", "libsnappy.so");
             libraryNames.put("libsnappy.so.1", "libsnappy.so");
-        } else if (SystemUtils.IS_OS_MAC_OSX) {
+        } else if (OSInfo.getOSName() == "Mac") {
             libResourceFolder = "/lib/MacOSX";
             libraryNames.put("libhadoop.dylib", "libhadoop.dylib");
             libraryNames.put("libsnappy.dylib", "libsnappy.dylib");


=====================================
src/test/java/org/xerial/snappy/SnappyOutputStreamTest.java
=====================================
@@ -179,6 +179,9 @@ public class SnappyOutputStreamTest
         // compression quality:
         if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
             assertEquals(90992, expectedCompressedData.length);
+        else if(OSInfo.getArchName() == "aarch64")
+            // Arm has a better compression ratio
+            assertEquals(91051, expectedCompressedData.length);
         else
             assertEquals(91080, expectedCompressedData.length);
         // The chunk size should not affect the size of the compressed output:



View it on GitLab: https://salsa.debian.org/java-team/snappy-java/-/commit/a277dd2b6e7e5e53dd78411c0e7e11178335608f

-- 
View it on GitLab: https://salsa.debian.org/java-team/snappy-java/-/commit/a277dd2b6e7e5e53dd78411c0e7e11178335608f
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20241118/4aef8ea1/attachment.htm>


More information about the pkg-java-commits mailing list