[Git][java-team/jffi][upstream] 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 upstream 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
- - - - -
13 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
- 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>
=====================================
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/-/commit/90b8e32bdb5b563d3f5bb3b98cd86a2969958231
--
View it on GitLab: https://salsa.debian.org/java-team/jffi/-/commit/90b8e32bdb5b563d3f5bb3b98cd86a2969958231
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/a517e2fb/attachment.htm>
More information about the pkg-java-commits
mailing list