From 5dbb021412436a9609e8ae9a899933ac7374a4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20Zim=C3=A1nyi?= Date: Fri, 2 Oct 2026 10:08:04 +0200 Subject: [PATCH] Build MobilityFlink without a warning MeosSetSetJoin, in the binding and the benchmark modules, frees the index pairs MEOS returns through com.kenai.jffi.MemoryIO.freeMemory, which calls the system free MEOS allocates with. jffi is the native layer jnr-ffi runs on, so it shares the classloader of every MEOS call inside the engine, and MobilityFlink calls no internal JDK API. benchmark/pom.xml declares junit-jupiter-api once, at junit.jupiter.version, the 5.8.2 Maven resolves already; the second declaration, at 5.7.0, is gone. The Maven workflow refuses a build that prints a warning: a [WARNING] line from Maven or a WARNING: line from JUnit or the JVM during the tests. Measured. Against MobilityDB 85ad3e2891, the catalog of MEOS-API 1c50d3611a and the generator and jar of JMEOS main 52432a1d, whose Flink runtimes free their values through jffi, mvn clean test under Maven 3.9.16 prints no warning line and the 18 and 12 tests pass. Main prints twenty: twelve sun.misc.Unsafe in the two MeosSetSetJoin and the eight lines Maven prints for the duplicate junit-jupiter-api in the benchmark model. --- .github/workflows/maven.yml | 10 ++++++++++ benchmark/pom.xml | 6 ------ .../org/mobilitydb/meos/MeosSetSetJoin.java | 20 +++++-------------- .../org/mobilitydb/meos/MeosSetSetJoin.java | 20 +++++-------------- 4 files changed, 20 insertions(+), 36 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 15744c3..759e97c 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -99,6 +99,16 @@ jobs: set -o pipefail mvn -B -Dmeos.lib.dir=/usr/local/lib clean test | tee "$RUNNER_TEMP/build.log" + # The build prints no warning: Maven's [WARNING] lines and the WARNING: + # lines JUnit and the JVM print during the tests. One of either fails + # the step and is listed. + - name: Refuse a build warning + run: | + if grep -E '^\[WARNING\]|^WARNING:' "$RUNNER_TEMP/build.log"; then + echo "::error::the build prints $(grep -cE '^\[WARNING\]|^WARNING:' "$RUNNER_TEMP/build.log") warning line(s)" + exit 1 + fi + # The build's own summary states two things this job's conclusion does # not: a test reported SKIPPED asserts nothing while the job still reads # success, and a test the run never collects appears in no count at all, diff --git a/benchmark/pom.xml b/benchmark/pom.xml index 6124fd1..bf4a42d 100644 --- a/benchmark/pom.xml +++ b/benchmark/pom.xml @@ -93,12 +93,6 @@ - - org.junit.jupiter - junit-jupiter-api - 5.7.0 - test - diff --git a/benchmark/src/main/java/org/mobilitydb/meos/MeosSetSetJoin.java b/benchmark/src/main/java/org/mobilitydb/meos/MeosSetSetJoin.java index 759b07f..08ea2cb 100644 --- a/benchmark/src/main/java/org/mobilitydb/meos/MeosSetSetJoin.java +++ b/benchmark/src/main/java/org/mobilitydb/meos/MeosSetSetJoin.java @@ -1,12 +1,11 @@ package org.mobilitydb.meos; +import com.kenai.jffi.MemoryIO; import functions.GeneratedFunctions; import java.lang.ref.Reference; -import java.lang.reflect.Field; import jnr.ffi.Memory; import jnr.ffi.Pointer; import jnr.ffi.Runtime; -import sun.misc.Unsafe; /** * NxN cross-stream set-set join operator over two arrays of temporal geometries. @@ -23,10 +22,11 @@ * *

The backing C functions take {@code (Temporal **arr1, int n1, Temporal **arr2, int n2, * [double dist,] int *count [, SpanSet ***periods])} and return a flat {@code int *} of - * {@code 2*count} indices (caller frees). Native result buffers are freed via {@code Unsafe}. + * {@code 2*count} indices (caller frees). Native result buffers are freed through jffi's {@code MemoryIO}, which calls the system + * free MEOS allocates with. */ public final class MeosSetSetJoin { - private static final Unsafe UNSAFE; + private static final MemoryIO IO = MemoryIO.getInstance(); private MeosSetSetJoin() { } @@ -113,17 +113,7 @@ private static int[][] readPairsAndFree(Pointer res, int cnt) { private static void free(Pointer p) { if (p != null) { - UNSAFE.freeMemory(p.address()); - } - } - - static { - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - UNSAFE = (Unsafe) f.get(null); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); + IO.freeMemory(p.address()); } } diff --git a/binding/src/main/java/org/mobilitydb/meos/MeosSetSetJoin.java b/binding/src/main/java/org/mobilitydb/meos/MeosSetSetJoin.java index 759b07f..08ea2cb 100644 --- a/binding/src/main/java/org/mobilitydb/meos/MeosSetSetJoin.java +++ b/binding/src/main/java/org/mobilitydb/meos/MeosSetSetJoin.java @@ -1,12 +1,11 @@ package org.mobilitydb.meos; +import com.kenai.jffi.MemoryIO; import functions.GeneratedFunctions; import java.lang.ref.Reference; -import java.lang.reflect.Field; import jnr.ffi.Memory; import jnr.ffi.Pointer; import jnr.ffi.Runtime; -import sun.misc.Unsafe; /** * NxN cross-stream set-set join operator over two arrays of temporal geometries. @@ -23,10 +22,11 @@ * *

The backing C functions take {@code (Temporal **arr1, int n1, Temporal **arr2, int n2, * [double dist,] int *count [, SpanSet ***periods])} and return a flat {@code int *} of - * {@code 2*count} indices (caller frees). Native result buffers are freed via {@code Unsafe}. + * {@code 2*count} indices (caller frees). Native result buffers are freed through jffi's {@code MemoryIO}, which calls the system + * free MEOS allocates with. */ public final class MeosSetSetJoin { - private static final Unsafe UNSAFE; + private static final MemoryIO IO = MemoryIO.getInstance(); private MeosSetSetJoin() { } @@ -113,17 +113,7 @@ private static int[][] readPairsAndFree(Pointer res, int cnt) { private static void free(Pointer p) { if (p != null) { - UNSAFE.freeMemory(p.address()); - } - } - - static { - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - UNSAFE = (Unsafe) f.get(null); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); + IO.freeMemory(p.address()); } }