Skip to content

Commit 3f7abb5

Browse files
authored
Merge pull request #20760 from JasonFengJ9/jdk24ref
JDK24 removes CleanerImpl.phantomCleanableList
2 parents c714a1e + 108d958 commit 3f7abb5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

jcl/src/java.base/share/classes/jdk/internal/ref/CleanerShutdown.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
*/
2323
package jdk.internal.ref;
2424

25-
import jdk.internal.ref.CleanerFactory;
26-
2725
import java.lang.ref.Cleaner;
2826
import java.lang.ref.Cleaner.Cleanable;
27+
/*[IF JAVA_SPEC_VERSION < 24]*/
2928
import java.lang.reflect.InvocationTargetException;
3029
import java.lang.reflect.Method;
3130
import java.security.AccessController;
3231
import java.security.PrivilegedAction;
32+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
3333

3434
@SuppressWarnings("javadoc")
3535
public class CleanerShutdown {
@@ -47,14 +47,15 @@ public static void shutdownCleaner() {
4747
}
4848
}
4949

50+
/*[IF JAVA_SPEC_VERSION < 24]*/
5051
try {
51-
Method phantomRemove = PhantomCleanable.class.getDeclaredMethod("remove", (Class<?>[]) null); //$NON-NLS-1$
52+
Method phantomRemove = PhantomCleanable.class.getDeclaredMethod("remove"); //$NON-NLS-1$
5253
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
5354
phantomRemove.setAccessible(true);
5455
return null;
5556
});
56-
while(!commonCleanerImpl.phantomCleanableList.isListEmpty()) {
57-
phantomRemove.invoke(commonCleanerImpl.phantomCleanableList, (Object[]) null);
57+
while (!commonCleanerImpl.phantomCleanableList.isListEmpty()) {
58+
phantomRemove.invoke(commonCleanerImpl.phantomCleanableList);
5859
}
5960
} catch (NoSuchMethodException
6061
| SecurityException
@@ -65,5 +66,6 @@ public static void shutdownCleaner() {
6566
/* should not fail */
6667
e.printStackTrace();
6768
}
69+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
6870
}
6971
}

0 commit comments

Comments
 (0)