From d239c00ff723f191c1a4596f249230a5effb43f9 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Mon, 1 Dec 2025 14:18:20 -0500 Subject: [PATCH] SuppressWarning on use of System.runFinalization (in Browser test) Finalization is deprecated for removal in Java, as of now there is no actual removal date planned so simply suppressing the warning seems most suitable. Follow-up to remove warnings in SWT workspace with update to Java 21 in https://github.com/eclipse-platform/eclipse.platform.swt/pull/2824 --- .../junit/Test_org_eclipse_swt_browser_Browser.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java index 5d9baff9aa5..2f32890ae2f 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java @@ -2842,7 +2842,7 @@ private static Boolean checkInternet(String url) { private static void printMemoryUse() { System.gc(); - System.runFinalization(); + runFinalization(); long max = Runtime.getRuntime().maxMemory(); long total = Runtime.getRuntime().totalMemory(); long free = Runtime.getRuntime().freeMemory(); @@ -2855,6 +2855,15 @@ private static void printMemoryUse() { System.out.println("\n#################################################\n"); } +/** + * Finalization is deprecated for removal in Java, as of now there is no actual + * removal date planned. The method exists to narrowly suppress warnings. + */ +@SuppressWarnings("removal") +private static void runFinalization() { + System.runFinalization(); +} + private static void printThreadsInfo() { System.out.println("\n########### Thread usage reported by JVM ########");