This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git


The following commit(s) were added to refs/heads/master by this push:
     new 3b79e0e3 Drop the unused BufferHelper and its jdk.internal.misc opens
3b79e0e3 is described below

commit 3b79e0e3a9379f84bf5e64bf65290a95d6519d4c
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Fri Nov 6 22:18:42 2026 +0100

    Drop the unused BufferHelper and its jdk.internal.misc opens
---
 .../org/mvndaemon/mvnd/client/DefaultClient.java   |  1 -
 common/pom.xml                                     |  7 --
 .../org/mvndaemon/mvnd/common/BufferHelper.java    | 82 ----------------------
 daemon/pom.xml                                     |  1 -
 4 files changed, 91 deletions(-)

diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java 
b/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java
index 880e8223..4aa09339 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java
@@ -247,7 +247,6 @@ public class DefaultClient implements Client {
                 "--add-opens java.base/java.io=ALL-UNNAMED "
                         + "--add-opens java.base/java.lang=ALL-UNNAMED "
                         + "--add-opens java.base/java.util=ALL-UNNAMED "
-                        + "--add-opens java.base/jdk.internal.misc=ALL-UNNAMED 
"
                         + "--add-opens 
java.base/sun.net.www.protocol.jar=ALL-UNNAMED "
                         + "--add-opens java.base/sun.nio.fs=ALL-UNNAMED",
                 true);
diff --git a/common/pom.xml b/common/pom.xml
index 35167c60..ef8e83d1 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -89,13 +89,6 @@
           </compilerArgs>
         </configuration>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <argLine>--add-opens 
java.base/jdk.internal.misc=ALL-UNNAMED</argLine>
-        </configuration>
-      </plugin>
     </plugins>
   </build>
 
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/BufferHelper.java 
b/common/src/main/java/org/mvndaemon/mvnd/common/BufferHelper.java
deleted file mode 100644
index e9d7aecd..00000000
--- a/common/src/main/java/org/mvndaemon/mvnd/common/BufferHelper.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.mvndaemon.mvnd.common;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.nio.ByteBuffer;
-import java.util.function.Consumer;
-
-/**
- * Utility class to clean up direct {@link ByteBuffer} instances by explicitly 
invoking their cleaner.
- */
-public class BufferHelper {
-
-    private static final Object unsafe;
-    private static final java.lang.reflect.Method invokeCleanerMethod;
-
-    static {
-        Object tmpUnsafe = null;
-        Method tmpInvokeCleaner = null;
-        try {
-            Class<?> unsafeClass = Class.forName("jdk.internal.misc.Unsafe");
-            Field theUnsafeField = unsafeClass.getDeclaredField("theUnsafe");
-            theUnsafeField.setAccessible(true);
-            tmpUnsafe = theUnsafeField.get(null);
-            tmpInvokeCleaner = unsafeClass.getMethod("invokeCleaner", 
ByteBuffer.class);
-        } catch (ReflectiveOperationException e) {
-            throw new RuntimeException("Unable to access 
jdk.internal.misc.Unsafe#invokeCleaner", e);
-        }
-        unsafe = tmpUnsafe;
-        invokeCleanerMethod = tmpInvokeCleaner;
-    }
-
-    /**
-     * Attempts to clean a direct {@link ByteBuffer}, releasing its underlying 
memory.
-     *
-     * @param byteBuffer The direct ByteBuffer to clean.
-     * @return {@code true} if the cleaner was successfully invoked, {@code 
false} otherwise.
-     */
-    public static boolean closeDirectByteBuffer(ByteBuffer byteBuffer) {
-        return closeDirectByteBuffer(byteBuffer, null);
-    }
-
-    /**
-     * Attempts to clean a direct {@link ByteBuffer}, releasing its underlying 
memory.
-     * Logs any errors via the provided logger.
-     *
-     * @param byteBuffer The direct ByteBuffer to clean.
-     * @param log        A consumer to log any potential errors, may be {@code 
null}.
-     * @return {@code true} if the cleaner was successfully invoked, {@code 
false} otherwise.
-     */
-    public static boolean closeDirectByteBuffer(ByteBuffer byteBuffer, 
Consumer<String> log) {
-        if (byteBuffer != null && byteBuffer.isDirect()) {
-            try {
-                invokeCleanerMethod.invoke(unsafe, byteBuffer);
-                return true;
-            } catch (Exception e) {
-                if (log != null) {
-                    log.accept("Failed to clean ByteBuffer: " + e);
-                }
-                return false;
-            }
-        }
-        return false;
-    }
-}
diff --git a/daemon/pom.xml b/daemon/pom.xml
index f30d610d..465020ef 100644
--- a/daemon/pom.xml
+++ b/daemon/pom.xml
@@ -175,7 +175,6 @@
           <argLine>--add-opens java.base/java.io=ALL-UNNAMED
                         --add-opens java.base/java.lang=ALL-UNNAMED
                         --add-opens java.base/java.util=ALL-UNNAMED
-                        --add-opens java.base/jdk.internal.misc=ALL-UNNAMED
                         --add-opens java.base/sun.nio.fs=ALL-UNNAMED</argLine>
         </configuration>
       </plugin>

Reply via email to