[Git][java-team/jffi][master] 11 commits: New upstream version 1.4.0+ds

Jérôme Charaoui (@lavamind) gitlab at salsa.debian.org
Fri Aug 28 16:06:23 BST 2026



Jérôme Charaoui pushed to branch master at Debian Java Maintainers / jffi


Commits:
90b8e32b by Jérôme Charaoui at 2026-08-28T08:09:28-04:00
New upstream version 1.4.0+ds
- - - - -
4ba95c69 by Jérôme Charaoui at 2026-08-28T08:09:30-04:00
Update upstream source from tag 'upstream/1.4.0+ds'

Update to upstream version '1.4.0+ds'
with Debian dir f3ed9a5dccee1a20b58a7e98230ccaea2e69bae3
- - - - -
3c7a775b by Jérôme Charaoui at 2026-08-28T08:10:10-04:00
d/patches: refresh for new upstream version

- - - - -
a971a02f by Jérôme Charaoui at 2026-08-28T12:10:50+00:00
Rely on pre-initialized dpkg-architecture variables.

Changes-By: lintian-brush

- - - - -
3253dac0 by Jérôme Charaoui at 2026-08-28T12:10:50+00:00
Remove redundant Priority: optional from source stanza.

Changes-By: lintian-brush
Fixes: lintian: source: redundant-priority-optional-field
See-also: https://lintian.debian.org/tags/redundant-priority-optional-field.html

- - - - -
3aaea94a by Jérôme Charaoui at 2026-08-28T12:10:50+00:00
Update standards version to 4.7.4, no changes needed.

Upgrade checklist verified:
 4.6.2 → 4.7.0:
  * Package does not use dpkg-divert
 4.7.0 → 4.7.1:
  * Package does not install to non-/usr paths
 4.7.3 → 4.7.4:
  * Package is not in non-free-firmware

Changes-By: lintian-brush
Fixes: lintian: source: ancient-standards-version 4.6.2 (released 2022-12-17) (current is 4.7.4.1)
See-also: https://lintian.debian.org/tags/ancient-standards-version.html

- - - - -
54724ad0 by Jérôme Charaoui at 2026-08-28T08:12:25-04:00
Removed Rules-Requires-Root

Changes-By: lintian-brush
Fixes: lintian: source: redundant-rules-requires-root-no-field [debian/control]
See-also: https://lintian.debian.org/tags/redundant-rules-requires-root-no-field.html

- - - - -
bd613d6f by Jérôme Charaoui at 2026-08-28T08:12:27-04:00
Update watch file format version to 5.

Changes-By: lintian-brush
Fixes: lintian: source: older-debian-watch-file-standard 4
See-also: https://lintian.debian.org/tags/older-debian-watch-file-standard.html

- - - - -
5fbcae68 by Jérôme Charaoui at 2026-08-28T08:21:31-04:00
d/control: build with headless jdk

- - - - -
179f28d0 by Jérôme Charaoui at 2026-08-28T08:22:59-04:00
drop empty d/docs

- - - - -
a0e6207d by Jérôme Charaoui at 2026-08-28T08:48:48-04:00
Update changelog for 1.4.0+ds-1 release

- - - - -


22 changed files:

- .github/build-native-debian.sh
- − .github/experimental-docker.json
- .github/workflows/ci.yml
- .github/workflows/native-linux.yml
- .github/workflows/native-macos.yml
- build.xml
- debian/changelog
- debian/control
- − debian/docs
- debian/patches/0009-optimize-build-targets.patch
- debian/patches/0010-output-test-results-to-console-instead-of-file.patch
- debian/patches/junit_path_for_tests.patch
- debian/patches/nonlinux-platforms.patch
- debian/rules
- debian/watch
- jni/jffi/Foreign.c
- pom.xml
- src/main/java/com/kenai/jffi/MemoryIO.java
- src/main/java/com/kenai/jffi/Platform.java
- src/main/java/com/kenai/jffi/internal/Cleaner.java
- src/main/java/com/kenai/jffi/internal/StubLoader.java
- src/test/java/com/kenai/jffi/PlatformTest.java


Changes:

=====================================
.github/build-native-debian.sh
=====================================
@@ -1,9 +1,16 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
 set -ex
 
 cd "$(dirname "$(dirname "$0")")"
 
+DEBIAN_VERSION=$(grep '^VERSION_ID=' /etc/os-release | cut -d'"' -f2)
+if [[ "$DEBIAN_VERSION" == "10" ]]; then
+  echo "deb http://archive.debian.org/debian buster main" > /etc/apt/sources.list
+  echo "deb http://archive.debian.org/debian-security buster/updates main" >> /etc/apt/sources.list
+  echo "deb http://archive.debian.org/debian buster-updates main" >> /etc/apt/sources.list
+fi
+
 # Add stretch for Java 8
 #cat <<END > /etc/apt/sources.list.d/stretch.list
 #deb http://deb.debian.org/debian stretch main
@@ -17,11 +24,18 @@ wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --
 echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list
 
 apt-get update -y
+if [[ "$(uname -m)" == "riscv64" ]]; then
+    # JDK 8 is not available on RISC-V 64
+    apt-get install -y temurin-17-jdk
+else
+    apt-get install -y temurin-8-jdk
+fi
 
-apt-get install -y temurin-8-jdk
 apt-get install -y --no-install-recommends make gcc libc6-dev texinfo
 # Needs to be split, otherwise a newer version of OpenJDK is pulled
 apt-get install -y --no-install-recommends ant
 rm archive/*
 ant jar && ant archive-platform-jar
 
+# 导出 GLIBC 依赖信息到 build/ 目录下,供外层 Action 使用
+objdump -p build/jni/*.so | grep GLIBC > build/glibc_versions.txt || true


=====================================
.github/experimental-docker.json deleted
=====================================
@@ -1,4 +0,0 @@
-{
-  "cgroup-parent": "/actions_job",
-  "experimental": true
-}


=====================================
.github/workflows/ci.yml
=====================================
@@ -1,6 +1,3 @@
-# This workflow will build a Java project with Maven
-# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
-
 name: CI
 
 on:
@@ -10,32 +7,35 @@ on:
     branches: [ master ]
 
 jobs:
-  jdk8:
 
-    runs-on: ubuntu-latest
+  mvn-test-x86:
 
-    steps:
-    - uses: actions/checkout at v2
-    - name: Set up JDK 8
-      uses: actions/setup-java at v1.4.3
-      with:
-        java-version: 8
-    - name: Build
-      run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
-    - name: Test
-      run: ant test
-      
-  jdk11:
+    runs-on: ${{ matrix.os }}
 
-    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        os: [ubuntu-latest, macos-latest]
+        java-test-version: ['8', '11', '17', '21', '25']
+      fail-fast: false
 
     steps:
     - uses: actions/checkout at v2
-    - name: Set up JDK 11
-      uses: actions/setup-java at v1.4.3
+    - name: Set up JDK 17 for build
+      uses: actions/setup-java at v5
       with:
-        java-version: 11
+        distribution: 'zulu'
+        java-version: |
+          8
+          17
     - name: Build
       run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
+    - name: Set up JDK ${{ matrix.java-test-version }} for test
+      uses: actions/setup-java at v5
+      with:
+        distribution: 'zulu'
+        java-version: ${{ matrix.java-test-version }}
+    - name: Install dependencies on macOS
+      if: matrix.os == 'macos-latest'
+      run: brew install texinfo automake autoconf
     - name: Test
       run: ant test


=====================================
.github/workflows/native-linux.yml
=====================================
@@ -13,26 +13,28 @@ jobs:
   native:
 
     # Switch back to ubuntu-latest after that maps to 20.04
-    runs-on: ubuntu-20.04
+    runs-on: ubuntu-24.04
 
     strategy:
       matrix:
         arch:
-          - "386"
+          # https://github.com/adoptium/temurin-build/issues/986
+          # - "386"
           - amd64
           - arm
           - arm64
-          - linux-arm-v5
-          # this build does not work and ends up just rebuilding x86_64
+          - riscv64
+          # these builds do not work and end up just rebuilding x86_64
+          #- linux-arm-v5
           #- s390x
       fail-fast: false
 
     name: Linux binary ${{ matrix.arch }}
 
     steps:
-      - uses: actions/checkout at v2
+      - uses: actions/checkout at v4
       - name: cache dependencies
-        uses: actions/cache at v1
+        uses: actions/cache at v4
         with:
           path: ~/.m2
           key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
@@ -43,21 +45,31 @@ jobs:
         run: sudo apt-get update -y
       - name: Install qemu
         run: sudo apt-get install -y --no-install-recommends qemu-user-static
-      - name: Experimental Docker
-        run: sudo cp .github/experimental-docker.json /etc/docker/daemon.json
-      - name: Restart Docker
-        run: sudo systemctl restart docker.service
+      - name: Initialize environment variables
+        run: |
+          if [[ "${{ matrix.arch }}" == "riscv64" ]]; then 
+              echo "DOCKER_IMAGE_NAME=debian:trixie" >> $GITHUB_ENV
+          else
+              echo "DOCKER_IMAGE_NAME=debian:10" >> $GITHUB_ENV
+          fi
       - name: Pull docker image
-        run: docker pull --platform $(echo ${{ matrix.arch }} | sed 's|-|/|g') debian:10 || true
+        run: docker pull --platform $(echo ${{ matrix.arch }} | sed 's|-|/|g') "$DOCKER_IMAGE_NAME" || true
       - name: Build inside Docker
-        run: docker run --rm -v $GITHUB_WORKSPACE:/work debian:10 /work/.github/build-native-debian.sh
+        run: docker run --rm -v $GITHUB_WORKSPACE:/work "$DOCKER_IMAGE_NAME" /work/.github/build-native-debian.sh
+      - name: Check GLIBC dependencies
+        run: |
+          echo "### GLIBC Dependencies for ${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
+          echo '```' >> $GITHUB_STEP_SUMMARY
+          cat build/glibc_versions.txt >> $GITHUB_STEP_SUMMARY
+          echo '```' >> $GITHUB_STEP_SUMMARY
+          cat build/glibc_versions.txt
       - name: Archive built library
-        uses: actions/upload-artifact at v2
+        uses: actions/upload-artifact at v4
         with:
           name: shared-object-${{ matrix.arch }}
           path: build/jni/*.so
       - name: Archive built jar
-        uses: actions/upload-artifact at v2
+        uses: actions/upload-artifact at v4
         with:
           name: jar-${{ matrix.arch }}
           path: archive/*.jar


=====================================
.github/workflows/native-macos.yml
=====================================
@@ -1,15 +1,10 @@
 name: Build macOS Binaries
 
 on:
-#  push:
-#    branches: [ master ]
-#  pull_request:
-#    branches: [ master ]
-  # GHA does not support building Apple am64 very well, so we disable this workflow for now.
-  # See https://github.com/actions/runner/issues/805
   push:
-    branches-ignore:
-      - '**'
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
 
 jobs:
   native:
@@ -19,32 +14,34 @@ jobs:
     name: macOS binary
 
     steps:
-      - uses: actions/checkout at v2
-      - name: set up java ${{ matrix.java-version }}
-        uses: actions/setup-java at v1.4.3
+      - uses: actions/checkout at v4
+      - name: set up java
+        uses: actions/setup-java at v4
         with:
-          java-version: 8
+          distribution: 'zulu'
+          java-version: '8'
       - name: cache dependencies
-        uses: actions/cache at v1
+        uses: actions/cache at v4
         with:
           path: ~/.m2
           key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
           restore-keys: ${{ runner.os }}-m2
+      - name: Install dependencies
+        run: brew install texinfo automake autoconf
       - name: Build
         env:
           LIBRARY_PATH: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib:$LIBRARY_PATH
         run: "rm archive/* && ant jar && ant archive-platform-jar"
       - name: Dump config.log
         if: ${{ always() }}
-        run: "cat /Users/runner/work/jffi/jffi/build/jni/libffi-darwin-x86_64/config.log"
+        run: "cat /Users/runner/work/jffi/jffi/build/jni/libffi-darwin-*/config.log || true"
       - name: Archive built library
-        uses: actions/upload-artifact at v2
+        uses: actions/upload-artifact at v4
         with:
           name: shared-object
-          path: build/jni/*.so
+          path: build/jni/*.jnilib
       - name: Archive built jar
-        uses: actions/upload-artifact at v2
+        uses: actions/upload-artifact at v4
         with:
           name: jar
           path: archive/*.jar
-


=====================================
build.xml
=====================================
@@ -99,6 +99,12 @@
       </or>
     </condition>
 
+    <condition property="platform.cpu" value="riscv64">
+      <or>
+        <os arch="riscv64"/>
+      </or>
+    </condition>
+
     <condition property="platform.os" value="Windows">
       <os family="Windows"/>
     </condition>


=====================================
debian/changelog
=====================================
@@ -1,3 +1,17 @@
+jffi (1.4.0+ds-1) unstable; urgency=medium
+
+  * Team upload.
+  * New upstream version 1.4.0+ds
+  * d/control: build with headless jdk
+  * d/patches: refresh for new upstream version
+  * Rely on pre-initialized dpkg-architecture variables.
+  * Remove redundant Priority: optional from source stanza.
+  * Update standards version to 4.7.4, no changes needed.
+  * Removed Rules-Requires-Root
+  * Update watch file format version to 5.
+
+ -- Jérôme Charaoui <jerome at riseup.net>  Fri, 28 Aug 2026 08:48:00 -0400
+
 jffi (1.3.13+ds-1) unstable; urgency=medium
 
   * New upstream version 1.3.13+ds


=====================================
debian/control
=====================================
@@ -1,6 +1,5 @@
 Source: jffi
 Section: java
-Priority: optional
 Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
 Uploaders:
  Jakub Adam <jakub.adam at ktknet.cz>,
@@ -9,7 +8,7 @@ Build-Depends:
  ant,
  ant-optional,
  debhelper-compat (= 13),
- default-jdk,
+ default-jdk-headless,
  javahelper,
  junit4 <!nocheck>,
  libffi-dev,
@@ -22,11 +21,10 @@ Build-Depends-Indep:
  libmaven-assembly-plugin-java,
  libmaven-bundle-plugin-java,
  maven-repo-helper,
-Standards-Version: 4.6.2
+Standards-Version: 4.7.4
 Vcs-Git: https://salsa.debian.org/java-team/jffi.git
 Vcs-Browser: https://salsa.debian.org/java-team/jffi
 Homepage: https://github.com/jnr/jffi
-Rules-Requires-Root: no
 
 Package: libjffi-java
 Architecture: all


=====================================
debian/docs deleted
=====================================
@@ -1 +0,0 @@
-


=====================================
debian/patches/0009-optimize-build-targets.patch
=====================================
@@ -26,7 +26,7 @@ Index: jffi/build.xml
  
    <target name="build-native" depends="-init, -build-platform-jar"/>
  
-@@ -156,7 +156,7 @@
+@@ -162,7 +162,7 @@
    <target name="-pre-jar"/>
    <target name="-post-init" depends="-init-vars"/>
    <target name="-pre-compile" depends="-init"/>
@@ -35,7 +35,7 @@ Index: jffi/build.xml
    <target name="-pre-compile-test" depends="-init"/>
    <target name="-post-compile-test" depends="-build-native-testlib"/>
    <target name="-post-jar" depends="-assemble-final-jar"/>
-@@ -171,7 +171,7 @@
+@@ -177,7 +177,7 @@
    <target name="compile" depends="-init,-pre-compile,-do-compile,-post-compile">
    </target>
  
@@ -44,7 +44,7 @@ Index: jffi/build.xml
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${dist.jar}" basedir="${build.classes.dir}" compress="true"/>
    </target>
-@@ -355,7 +355,7 @@
+@@ -361,7 +361,7 @@
      -->
    </target>
  
@@ -53,7 +53,7 @@ Index: jffi/build.xml
      <mkdir dir="${build.native.dir}"/>
  
      <exec executable="cygpath" outputproperty="jni.GNUmakefile" osfamily="Windows">
-@@ -414,7 +414,7 @@
+@@ -420,7 +420,7 @@
      </exec>
    </target>
  


=====================================
debian/patches/0010-output-test-results-to-console-instead-of-file.patch
=====================================
@@ -11,7 +11,7 @@ Index: jffi/build.xml
 ===================================================================
 --- jffi.orig/build.xml
 +++ jffi/build.xml
-@@ -190,7 +190,7 @@
+@@ -196,7 +196,7 @@
        </classpath>
        <sysproperty key="java.library.path" value="${build.native.dir}"/>
  
@@ -20,7 +20,7 @@ Index: jffi/build.xml
        <batchtest todir="${build.test.dir}/results">
          <fileset dir="${src.test.dir}">
            <include name="**/*Test*.java"/>
-@@ -209,7 +209,7 @@
+@@ -215,7 +215,7 @@
          <pathelement location="/usr/share/java/hamcrest-core.jar"/>
        </classpath>
  
@@ -29,7 +29,7 @@ Index: jffi/build.xml
        <batchtest todir="${build.test.dir}/results">
          <fileset dir="${src.test.dir}">
            <include name="**/*Test*.java"/>
-@@ -229,7 +229,7 @@
+@@ -235,7 +235,7 @@
        </classpath>
        <sysproperty key="jffi.extract.name" value=""/>
  


=====================================
debian/patches/junit_path_for_tests.patch
=====================================
@@ -24,7 +24,7 @@ Index: jffi/build.xml
    </path>
  
    <target name="clean-java" depends="-init">
-@@ -178,8 +178,8 @@
+@@ -184,8 +184,8 @@
        <classpath>
          <pathelement location="${build.classes.dir}"/>
          <pathelement location="${build.test.dir}/classes"/>
@@ -35,7 +35,7 @@ Index: jffi/build.xml
        </classpath>
        <sysproperty key="java.library.path" value="${build.native.dir}"/>
  
-@@ -198,8 +198,8 @@
+@@ -204,8 +204,8 @@
          <pathelement location="${build.classes.dir}"/>
          <pathelement location="${build.test.dir}/classes"/>
          <fileset dir="archive" includes="*.jar"/>
@@ -46,7 +46,7 @@ Index: jffi/build.xml
        </classpath>
  
        <formatter type="plain" /> <!-- to file -->
-@@ -217,8 +217,8 @@
+@@ -223,8 +223,8 @@
          <pathelement location="${build.classes.dir}"/>
          <pathelement location="${build.test.dir}/classes"/>
          <fileset dir="archive" includes="*.jar"/>
@@ -57,7 +57,7 @@ Index: jffi/build.xml
        </classpath>
        <sysproperty key="jffi.extract.name" value=""/>
  
-@@ -241,8 +241,8 @@
+@@ -247,8 +247,8 @@
        <classpath>
          <pathelement location="${build.classes.dir}"/>
          <pathelement location="${build.test.dir}/classes"/>
@@ -68,7 +68,7 @@ Index: jffi/build.xml
        </classpath>
        <sysproperty key="java.library.path" value="${build.native.dir}"/>
        <formatter type="plain" usefile="false"/>
-@@ -263,8 +263,8 @@
+@@ -269,8 +269,8 @@
      <javac srcdir="${src.test.dir}" destdir="${build.test.dir}/classes" includeantruntime="false" classpathref="classpath.test">
        <classpath>
          <pathelement location="${build.classes.dir}"/>


=====================================
debian/patches/nonlinux-platforms.patch
=====================================
@@ -12,7 +12,7 @@ Index: jffi/build.xml
 ===================================================================
 --- jffi.orig/build.xml
 +++ jffi/build.xml
-@@ -102,6 +102,13 @@
+@@ -108,6 +108,13 @@
      <condition property="platform.os" value="Windows">
        <os family="Windows"/>
      </condition>


=====================================
debian/rules
=====================================
@@ -2,7 +2,7 @@
 
 include /usr/share/dpkg/pkg-info.mk
 
-DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+include /usr/share/dpkg/architecture.mk
 export JAVA_HOME=/usr/lib/jvm/default-java
 export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
 export CCACHE_DIR=$(CURDIR)/ccache


=====================================
debian/watch
=====================================
@@ -1,4 +1,6 @@
-version=4
-opts="mode=git,repacksuffix=+ds,dversionmangle=auto" \
-https://github.com/jnr/jffi.git \
-refs/tags/(?:jffi-)?v?@ANY_VERSION@
+Version: 5
+Template: GitHub
+Owner: jnr
+Project: jffi
+Repacksuffix: +ds
+Dversionmangle: auto


=====================================
jni/jffi/Foreign.c
=====================================
@@ -287,6 +287,9 @@ Java_com_kenai_jffi_Foreign_unregisterNatives(JNIEnv *env, jobject self, jclass
 #elif defined(__s390__)
 # define CPU "s390"
 
+#elif defined(__riscv) && (__riscv_xlen == 64)
+# define CPU "riscv64"
+
 #else
 # define CPU "unknown"
 #endif


=====================================
pom.xml
=====================================
@@ -1,14 +1,16 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
+
   <parent>
-    <groupId>org.sonatype.oss</groupId>
-    <artifactId>oss-parent</artifactId>
-    <version>7</version>
+    <groupId>com.github.jnr</groupId>
+    <artifactId>jnr-parent</artifactId>
+    <version>0.0.1</version>
+    <relativePath/>
   </parent>
-  <groupId>com.github.jnr</groupId>
+
   <artifactId>jffi</artifactId>
   <packaging>jar</packaging>
-  <version>1.3.13</version>
+  <version>1.4.0</version>
   <name>jffi</name>
   <description>Java Foreign Function Interface</description>
   <url>http://github.com/jnr/jffi</url>
@@ -44,7 +46,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>4.13.1</version>
+      <version>4.13.2</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
@@ -52,9 +54,6 @@
   <properties>
     <maven.test.skip>true</maven.test.skip>
     <maven.test.failure.ignore>true</maven.test.failure.ignore>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <maven.compiler.source>8</maven.compiler.source>
-    <maven.compiler.target>8</maven.compiler.target>
     <make.exe>make</make.exe>
   </properties>
 
@@ -83,66 +82,41 @@
         <make.exe>gmake</make.exe>
       </properties>
     </profile>
-    <profile>
-      <id>java9</id>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-compiler-plugin</artifactId>
-            <executions>
-              <execution>
-                <!-- Compile UnsafeMemoryIO without release flag, so it can access Unsafe -->
-                <id>default-compile</id>
-                <phase>compile</phase>
-                <configuration>
-                  <includes>
-                    <include>com/kenai/jffi/UnsafeMemoryIO.java</include>
-                  </includes>
-                </configuration>
-              </execution>
-              <execution>
-                <id>java9-compile</id>
-                <phase>compile</phase>
-                <goals><goal>compile</goal></goals>
-                <configuration>
-                  <!-- Compile the rest with release flag to ensure compatibility with 8 -->
-                  <!-- Use -release compiler option rather than source/target if 9+ -->
-                  <release>${maven.compiler.target}</release>
-                  <!-- Exclude unsafe-using class when compiling with release flag -->
-                  <includes>
-                    <include>**/*.java</include>
-                  </includes>
-                  <excludes>
-                    <exclude>com/kenai/jffi/UnsafeMemoryIO.java</exclude>
-                  </excludes>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-      <activation>
-        <jdk>[9,)</jdk>
-      </activation>
-    </profile>
   </profiles>
 
   <build>
     <plugins>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.8.1</version>
-        <configuration>
-          <debug>true</debug>
-          <showDeprecation>true</showDeprecation>
-        </configuration>
+        <!-- This is a bit gross; we can't access sun.misc without jdk.supported, but we can't add jdk.unsupported
+             while also setting release 8. For now we require a JDK 8 toolchain to compile this one class. -->
+        <executions>
+          <execution>
+            <id>default-compile</id>
+            <configuration>
+              <jdkToolchain>
+                <version>8</version>
+              </jdkToolchain>
+              <includes>
+                <include>com/kenai/jffi/UnsafeMemoryIO.java</include>
+              </includes>
+            </configuration>
+          </execution>
+          <execution>
+            <id>java9-compile</id>
+            <phase>compile</phase>
+            <goals><goal>compile</goal></goals>
+            <configuration>
+              <excludes>
+                <exclude>com/kenai/jffi/UnsafeMemoryIO.java</exclude>
+              </excludes>
+            </configuration>
+          </execution>
+        </executions>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
-        <version>3.2.0</version>
         <executions>
           <execution>
             <id>default-jar</id>
@@ -159,7 +133,6 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
-        <version>2.4.0</version>
         <extensions>false</extensions>
         <executions>
           <execution>
@@ -203,33 +176,6 @@
           </execution>
         </executions>
       </plugin>
-<!--
-      <plugin>
-        <artifactId>maven-antrun-plugin</artifactId>
-        <version>1.1</version>
-        <executions>
-          <execution>
-            <id>build-native-library</id>
-            <phase>process-classes</phase>
-            <configuration>
-              <tasks>
-                <property name="os.name" value="${os.name}" />
-                <property name="os.arch" value="${os.arch}" />
-                <property name="java.home" value="${java.home}" />
-                <property name="dist.dir" value="${project.build.directory}" />
-                <property name="build.dir" value="${project.build.directory}" />
-                <property name="build.classes.dir" value="${project.build.outputDirectory}" />
-                <ant antfile="custom-build.xml" dir="." target="-assemble-native-jar" />
-                <unjar src="${project.build.directory}/native.jar" dest="${project.build.outputDirectory}" />
-              </tasks>
-            </configuration>
-            <goals>
-              <goal>run</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
--->
         <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>build-helper-maven-plugin</artifactId>


=====================================
src/main/java/com/kenai/jffi/MemoryIO.java
=====================================
@@ -869,6 +869,9 @@ public abstract class MemoryIO {
      */
     @SuppressWarnings("unchecked")
     static boolean isUnsafeAvailable() {
+        // JDK 23 and later warn when using memory-access methods
+        if (Platform.getPlatform().getJavaMajorVersion() >= 23) return false;
+
         try {
             Class sunClass = Class.forName("sun.misc.Unsafe");
 


=====================================
src/main/java/com/kenai/jffi/Platform.java
=====================================
@@ -32,6 +32,9 @@
 
 package com.kenai.jffi;
 
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 /**
  * Convenience class to interrogate the system about various platform-specific details.
  */
@@ -286,19 +289,23 @@ public abstract class Platform {
         try {
             String versionString = System.getProperty("java.version");
             if (versionString != null) {
-                // stop at first non-decimal character
-                String v = versionString.split("[^0-9.]")[0];
-
-                // if x.y assume 1.version and take decimal part
-                int dot = v.indexOf('.');
-                if (dot != -1) {
-                    v = v.substring(dot + 1);
+                // Extract the major version number from both the
+                // old style numbering (1.major.minor) and the
+                // new style (major.minor)
+                Pattern pattern = Pattern.compile("1\\.([0-9]+).*|([0-9]+).*");
+                Matcher matcher = pattern.matcher(versionString);
+                boolean matches = matcher.matches();
+                if (matches) {
+                    String v = matcher.group(1);
+                    if (v == null) {
+                        v = matcher.group(2);
+                    }
+
+                    version = Integer.parseInt(v);
                 }
-                version = Integer.valueOf(v);
             }
         } catch (Exception ex) {
-            // Assume version 5 or above.
-            version = 8;
+            // Use default value assigned earlier.
         }
 
         javaVersionMajor = version;


=====================================
src/main/java/com/kenai/jffi/internal/Cleaner.java
=====================================
@@ -48,25 +48,37 @@ public final class Cleaner {
         }
     }
 
-    private static final Object cleanerLock = new Object();
+    private static final Object cleanerLock = registerMethod == null ? null : new Object();
     private static volatile Object cleaner;
 
-    private static Object getCleaner(Object object, Runnable cleanProc) {
-        if (cleaner == null) synchronized (cleanerLock) {
-            if (cleaner == null) {
-                try {
-                    if (registerMethod == null) cleaner = createMethod.invoke(null, object, cleanProc);
-                    else cleaner = registerMethod.invoke(createMethod.invoke(null), object, cleanProc);
-                } catch (InvocationTargetException | IllegalAccessException e) {
-                    throw new IllegalStateException(e);
+    private static Object getCleaner(Object object, Runnable cleanup) {
+        if (registerMethod == null) { // JDK 1.8
+            try {
+                return createMethod.invoke(null, object, cleanup);
+            } catch (IllegalAccessException | InvocationTargetException e) {
+                throw new IllegalStateException(e);
+            }
+        }
+        else { // JDK 9
+            if (cleaner == null) synchronized (cleanerLock) {
+                if (cleaner == null) {
+                    try {
+                        cleaner = createMethod.invoke(null);
+                    } catch (InvocationTargetException | IllegalAccessException e) {
+                        throw new IllegalStateException(e);
+                    }
                 }
             }
+            try {
+                return registerMethod.invoke(cleaner, object, cleanup);
+            } catch (IllegalAccessException | InvocationTargetException e) {
+                throw new IllegalStateException(e);
+            }
         }
-        return cleaner;
     }
 
-    public static Runnable register(Object object, Runnable cleanProc) {
-        Object cleaner = getCleaner(object, cleanProc);
+    public static Runnable register(Object object, Runnable cleanup) {
+        Object cleaner = getCleaner(object, cleanup);
         return new Runnable() {
             @Override
             public void run() {


=====================================
src/main/java/com/kenai/jffi/internal/StubLoader.java
=====================================
@@ -53,8 +53,7 @@ public class StubLoader {
     
     private static final String bootPropertyFilename = "boot.properties";
     private static final String bootLibraryPropertyName = "jffi.boot.library.path";
-    private static final String stubLibraryName
-            = String.format("jffi-%d.%d", VERSION_MAJOR, VERSION_MINOR);
+    private static final String stubLibraryName = "jffi-" + VERSION_MAJOR + '.' + VERSION_MINOR;
 
     private static final String TMPDIR_ENV =
             Platform.getPlatform().getOS() == Platform.OS.WINDOWS ?


=====================================
src/test/java/com/kenai/jffi/PlatformTest.java
=====================================
@@ -6,6 +6,10 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import static org.junit.Assert.*;
 
 /**
@@ -41,4 +45,22 @@ public class PlatformTest {
         // This should never fail
         assertTrue("isSupported failed", Platform.getPlatform().isSupported());
     }
+
+    @Test public void getMajorVersion() {
+        // This should never fail
+        String version = System.getProperty("java.version");
+        Pattern pattern = Pattern.compile("1\\.([0-9]+).*|([0-9]+).*");
+        Matcher matcher = pattern.matcher(version);
+        boolean matches = matcher.matches();
+        assertTrue("Unexpected java version string: " + version, matches);
+
+        String major = matcher.group(1);
+        if (major == null) {
+            major = matcher.group(2);
+        }
+        assertEquals(
+                Integer.parseInt(major),
+                Platform.getPlatform().getJavaMajorVersion()
+        );
+    }
 }
\ No newline at end of file



View it on GitLab: https://salsa.debian.org/java-team/jffi/-/compare/bdfaa3944ef2e28320c5d6217d22199106ba5440...a0e6207da1fe9b7e88be5be0fafffe7b8cdfd7fe

-- 
View it on GitLab: https://salsa.debian.org/java-team/jffi/-/compare/bdfaa3944ef2e28320c5d6217d22199106ba5440...a0e6207da1fe9b7e88be5be0fafffe7b8cdfd7fe
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


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


More information about the pkg-java-commits mailing list