Description
It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock. While this problem could be prevented if the class whose objects are being finalized were coded to "defend against" this call, most programmers do not defend against it. They assume that an object is dead at the time that its finalizer is called.
Further, the call is not "thread-safe" in the sense that it sets a VM-global flag. This forces every class with a finalizer to defend against the finalization of live objects!
[1] https://docs.oracle.com/javase/9/docs/api/java/lang/doc-files/threadPrimitiveDeprecation.html
Attachments
Issue Links
- blocks
-
JDK-8177680 Umbrella: JDK 11 terminal deprecations
- Resolved
- csr for
-
JDK-8198250 Remove deprecated Runtime::runFinalizersOnExit and System::runFinalizersOnExit
- Closed
- relates to
-
JDK-8198639 Examine Windows AWT dependency on runFinalizersOnExit
- Open
-
JDK-8288984 Simplification in java.lang.Runtime::exit
- Resolved
-
JDK-8193035 remove terminally deprecated APIs from java.lang
- Closed
-
JDK-4240589 (ref) runFinalizersOnExit(true) causes VM crash for user native libraries
- Resolved
-
JDK-8197812 (ref) Data race in Finalizer
- Closed
-
JDK-8287132 Retire Runtime.runFinalizersOnExit so that it always throws UOE
- Resolved
-
JDK-8287133 Retire Runtime.runFinalizersOnExit so that it always throws UOE
- Closed