Tagir Valeev asked on Twitter whether System.runFinalization() and Runtime.runFinalization() should also be deprecated. The obvious answer is "yes" since we're deprecating finalization, but maybe it's not so obvious.

One view is that we're not deprecating the entire finalization mechanism, we're simply deprecating Object.finalize() and its overrides. The point of doing this is to encourage code to migrate away from these methods. Code that calls runFinalization() can't rely on it having many semantics, so such calls are harmless. (Well, mostly harmless.) Encouraging migration away from runFinalization() thus isn't necessary.

Another point is that "finalization" in a generic sense can be applied to reference processing, not just calls to the finalize() method. Offhand I'm not sure what runFinalization() does today, but perhaps in the future it could be modified to have stronger semantics regarding reference processing -- which is one of the big unresolved issues in this area.

What do you think?

s'marks

On 3/10/17 1:40 PM, Roger Riggs wrote:
Finalizers are inherently problematic and their use can lead to performance 
issues,
deadlocks, hangs, and other problematic behavior.

The problems have been accumulating for many years and the first step to
deprecate Object.finalize and the overrides in the JDK to communicate the
issues, recommend alternatives, and motivate changes where finalization is
currently used.

The behavior of finalization nor any uses of finalize are not modified by this
change.
Most of the changes are to suppress compilation warnings within the JDK.

Please review and comment.

Webrev:
http://cr.openjdk.java.net/~rriggs/webrev-finalize-deprecate-8165641/

Issue:
   https://bugs.openjdk.java.net/browse/JDK-8165641

Thanks, Roger


Reply via email to