# HG changeset patch
# User dl
# Date 1518283073 28800
# Node ID a5a2e4770524c96022506dd242305ec1c14daef0
# Parent 0937e5f799df90bdce003b121b665825d86a6018
8190324: ThreadPoolExecutor should not specify a dependency on finalization
Reviewed-by: martin, psandoz, alanb, rriggs, dholmes
diff -r 0937e5f799df -r a5a2e4770524 src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java
--- a/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Sat Feb 10 07:06:16 2018 -0500
+++ b/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Sat Feb 10 09:17:53 2018 -0800
@@ -35,9 +35,6 @@
package java.util.concurrent;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
@@ -268,8 +265,8 @@
*
*
A pool that is no longer referenced in a program AND
* has no remaining threads may be reclaimed (garbage collected)
- * without being explicity shutdown. You can configure a pool to allow
- * all unused threads to eventually die by setting appropriate
+ * without being explicitly shutdown. You can configure a pool to
+ * allow all unused threads to eventually die by setting appropriate
* keep-alive times, using a lower bound of zero core threads and/or
* setting {@link #allowCoreThreadTimeOut(boolean)}.
*
@@ -1462,6 +1459,18 @@
}
}
+ // Override without "throws Throwable" for compatibility with subclasses
+ // whose finalize method invokes super.finalize() (as is recommended).
+ // Before JDK 11, finalize() had a non-empty method body.
+
+ /**
+ * @implNote Previous versions of this class had a finalize method
+ * that shut down this executor, but in this version, finalize
+ * does nothing.
+ */
+ @Deprecated(since="9")
+ protected void finalize() {}
+
/**
* Sets the thread factory used to create new threads.
*
diff -r 0937e5f799df -r a5a2e4770524 test/jdk/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java
--- a/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java Sat Feb 10 07:06:16 2018 -0500
+++ b/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java Sat Feb 10 09:17:53 2018 -0800
@@ -1994,4 +1994,19 @@
}
}
+ public void testFinalizeMethodCallsSuperFinalize() {
+ new CustomTPE(1, 1,
+ LONG_DELAY_MS, MILLISECONDS,
+ new LinkedBlockingQueue()) {
+
+ /**
+ * A finalize method without "throws Throwable", that
+ * calls super.finalize().
+ */
+ protected void finalize() {
+ super.finalize();
+ }
+ }.shutdown();
+ }
+
}