Skip to content

Commit

Permalink
Merge pull request #21044 from JasonFengJ9/cleanershutdown
Browse files Browse the repository at this point in the history
JDK24 CleanerShutdown invokes CleanerImpl.CleanableList.reset()
  • Loading branch information
pshipton authored Jan 31, 2025
2 parents 82081e2 + 5ef42eb commit ad482ed
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

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;
/*[IF JAVA_SPEC_VERSION < 24]*/
import java.security.AccessController;
import java.security.PrivilegedAction;
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
Expand All @@ -47,8 +47,12 @@ public static void shutdownCleaner() {
}
}

/*[IF JAVA_SPEC_VERSION < 24]*/
try {
/*[IF JAVA_SPEC_VERSION >= 24]*/
Method cleanableListReset = CleanerImpl.CleanableList.class.getDeclaredMethod("reset"); //$NON-NLS-1$
cleanableListReset.setAccessible(true);
cleanableListReset.invoke(commonCleanerImpl.activeList);
/*[ELSE] JAVA_SPEC_VERSION >= 24 */
Method phantomRemove = PhantomCleanable.class.getDeclaredMethod("remove"); //$NON-NLS-1$
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
phantomRemove.setAccessible(true);
Expand All @@ -57,15 +61,17 @@ public static void shutdownCleaner() {
while (!commonCleanerImpl.phantomCleanableList.isListEmpty()) {
phantomRemove.invoke(commonCleanerImpl.phantomCleanableList);
}
/*[ENDIF] JAVA_SPEC_VERSION >= 24 */
} catch (NoSuchMethodException
/*[IF JAVA_SPEC_VERSION < 24]*/
| SecurityException
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
| IllegalAccessException
| IllegalArgumentException
| InvocationTargetException e)
{
/* should not fail */
e.printStackTrace();
}
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
}
}
6 changes: 0 additions & 6 deletions test/functional/Java8andUp/playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1847,12 +1847,6 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
</test>
<test>
<testCaseName>VmArgumentTests</testCaseName>
<disables>
<disable>
<comment>https://github.com/eclipse-openj9/openj9/issues/20810</comment>
<version>24+</version>
</disable>
</disables>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
-cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)GeneralTest.jar$(Q) \
-Dcom.ibm.tools.attach.enable=yes \
Expand Down
6 changes: 0 additions & 6 deletions test/functional/NativeTest/playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,6 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
</test>
<test>
<testCaseName>thrstatetest</testCaseName>
<disables>
<disable>
<comment>https://github.com/eclipse-openj9/openj9/issues/20835</comment>
<version>24+</version>
</disable>
</disables>
<variations>
<variation>Mode110</variation>
<variation>Mode610</variation>
Expand Down

0 comments on commit ad482ed

Please sign in to comment.