From 108d95899c42ab9a3aaa8834590db2e1e458c990 Mon Sep 17 00:00:00 2001 From: Jason Feng Date: Thu, 5 Dec 2024 10:23:14 -0500 Subject: [PATCH] JDK24 removes CleanerImpl.phantomCleanableList Signed-off-by: Jason Feng --- .../classes/jdk/internal/ref/CleanerShutdown.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jcl/src/java.base/share/classes/jdk/internal/ref/CleanerShutdown.java b/jcl/src/java.base/share/classes/jdk/internal/ref/CleanerShutdown.java index 383a1e5fa0e..8523d2f3150 100644 --- a/jcl/src/java.base/share/classes/jdk/internal/ref/CleanerShutdown.java +++ b/jcl/src/java.base/share/classes/jdk/internal/ref/CleanerShutdown.java @@ -22,14 +22,14 @@ */ package jdk.internal.ref; -import jdk.internal.ref.CleanerFactory; - import java.lang.ref.Cleaner; import java.lang.ref.Cleaner.Cleanable; +/*[IF JAVA_SPEC_VERSION < 24]*/ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; +/*[ENDIF] JAVA_SPEC_VERSION < 24 */ @SuppressWarnings("javadoc") public class CleanerShutdown { @@ -47,14 +47,15 @@ public static void shutdownCleaner() { } } + /*[IF JAVA_SPEC_VERSION < 24]*/ try { - Method phantomRemove = PhantomCleanable.class.getDeclaredMethod("remove", (Class[]) null); //$NON-NLS-1$ + Method phantomRemove = PhantomCleanable.class.getDeclaredMethod("remove"); //$NON-NLS-1$ AccessController.doPrivileged((PrivilegedAction) () -> { phantomRemove.setAccessible(true); return null; }); - while(!commonCleanerImpl.phantomCleanableList.isListEmpty()) { - phantomRemove.invoke(commonCleanerImpl.phantomCleanableList, (Object[]) null); + while (!commonCleanerImpl.phantomCleanableList.isListEmpty()) { + phantomRemove.invoke(commonCleanerImpl.phantomCleanableList); } } catch (NoSuchMethodException | SecurityException @@ -65,5 +66,6 @@ public static void shutdownCleaner() { /* should not fail */ e.printStackTrace(); } + /*[ENDIF] JAVA_SPEC_VERSION < 24 */ } }