8276447: Deprecate finalization-related methods for removal

Reviewed-by: rriggs, alanb, lancea, darcy, mchung, serb, smarks, prr
This commit is contained in:
Brent Christian 2021-12-08 00:23:15 +00:00
parent 3c2951f738
commit ec7cb6d5d3
62 changed files with 156 additions and 140 deletions

View File

@ -275,8 +275,13 @@ public abstract class Enum<E extends Enum<E>>
/**
* enum classes cannot have finalize methods.
*
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*/
@SuppressWarnings("deprecation")
@Deprecated(since="18", forRemoval=true)
@SuppressWarnings("removal")
protected final void finalize() { }
/**

View File

@ -478,6 +478,12 @@ public class Object {
* A subclass overrides the {@code finalize} method to dispose of
* system resources or to perform other cleanup.
* <p>
* <b>When running in a Java virtual machine in which finalization has been
* disabled or removed, the garbage collector will never call
* {@code finalize()}. In a Java virtual machine in which finalization is
* enabled, the garbage collector might call {@code finalize} only after an
* indefinite delay.</b>
* <p>
* The general contract of {@code finalize} is that it is invoked
* if and when the Java virtual
* machine has determined that there is no longer any
@ -543,27 +549,29 @@ public class Object {
* }
* }</pre>
*
* @deprecated The finalization mechanism is inherently problematic.
* Finalization can lead to performance issues, deadlocks, and hangs.
* Errors in finalizers can lead to resource leaks; there is no way to cancel
* finalization if it is no longer necessary; and no ordering is specified
* among calls to {@code finalize} methods of different objects.
* Furthermore, there are no guarantees regarding the timing of finalization.
* The {@code finalize} method might be called on a finalizable object
* only after an indefinite delay, if at all.
*
* Classes whose instances hold non-heap resources should provide a method
* to enable explicit release of those resources, and they should also
* implement {@link AutoCloseable} if appropriate.
* The {@link java.lang.ref.Cleaner} and {@link java.lang.ref.PhantomReference}
* provide more flexible and efficient ways to release resources when an object
* becomes unreachable.
* @deprecated Finalization is deprecated and subject to removal in a future
* release. The use of finalization can lead to problems with security,
* performance, and reliability.
* See <a href="https://openjdk.java.net/jeps/421">JEP 421</a> for
* discussion and alternatives.
* <p>
* Subclasses that override {@code finalize} to perform cleanup should use
* alternative cleanup mechanisms and remove the {@code finalize} method.
* Use {@link java.lang.ref.Cleaner} and
* {@link java.lang.ref.PhantomReference} as safer ways to release resources
* when an object becomes unreachable. Alternatively, add a {@code close}
* method to explicitly release resources, and implement
* {@code AutoCloseable} to enable use of the {@code try}-with-resources
* statement.
* <p>
* This method will remain in place until finalizers have been removed from
* most existing code.
*
* @throws Throwable the {@code Exception} raised by this method
* @see java.lang.ref.WeakReference
* @see java.lang.ref.PhantomReference
* @jls 12.6 Finalization of Class Instances
*/
@Deprecated(since="9")
@Deprecated(since="9", forRemoval=true)
protected void finalize() throws Throwable { }
}

View File

@ -707,8 +707,17 @@ public class Runtime {
* The method {@link System#runFinalization()} is the conventional
* and convenient means of invoking this method.
*
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
* <p>
* When running in a JVM in which finalization has been disabled or removed,
* no objects will be pending finalization, so this method does nothing.
*
* @see java.lang.Object#finalize()
* @jls 12.6 Finalization of Class Instances
*/
@Deprecated(since="18", forRemoval=true)
public void runFinalization() {
SharedSecrets.getJavaLangRefAccess().runFinalization();
}

View File

@ -1922,8 +1922,18 @@ public final class System {
* Runtime.getRuntime().runFinalization()
* </pre></blockquote>
*
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
* <p>
* When running in a JVM in which finalization has been disabled or removed,
* no objects will be pending finalization, so this method does nothing.
*
* @see java.lang.Runtime#runFinalization()
* @jls 12.6 Finalization of Class Instances
*/
@Deprecated(since="18", forRemoval=true)
@SuppressWarnings("removal")
public static void runFinalization() {
Runtime.getRuntime().runFinalization();
}
@ -2321,7 +2331,7 @@ public final class System {
public Thread newThreadWithAcc(Runnable target, @SuppressWarnings("removal") AccessControlContext acc) {
return new Thread(target, acc);
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
public void invokeFinalize(Object o) throws Throwable {
o.finalize();
}

View File

@ -791,7 +791,7 @@ public class Executors {
FinalizableDelegatedExecutorService(ExecutorService executor) {
super(executor);
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() {
super.shutdown();
}

View File

@ -1477,8 +1477,13 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
* @implNote Previous versions of this class had a finalize method
* that shut down this executor, but in this version, finalize
* does nothing.
*
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*/
@Deprecated(since="9")
@Deprecated(since="9", forRemoval=true)
@SuppressWarnings("removal")
protected void finalize() {}
/**

View File

@ -242,7 +242,7 @@ public class MeteredStream extends FilterInputStream {
return readLock.isHeldByCurrentThread();
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
try {
close();

View File

@ -270,7 +270,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* the penalty of prematurly killing SSL sessions.
*/
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected final void finalize() throws Throwable {
try {
close();

View File

@ -114,7 +114,7 @@ public final class JRSUIControl {
changes.putAll(other.changes);
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected synchronized void finalize() throws Throwable {
if (cfDictionaryPtr == 0) return;
disposeCFDictionary(cfDictionaryPtr);

View File

@ -144,7 +144,7 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
}
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
try {
super.finalize();

View File

@ -247,7 +247,7 @@ public final class CFont extends PhysicalFont implements FontSubstitution {
return compFont;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected synchronized void finalize() {
if (nativeFontPtr != 0) {
disposeNativeFont(nativeFontPtr);

View File

@ -125,7 +125,7 @@ public final class CStrike extends PhysicalStrike {
return nativeStrikePtr;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected synchronized void finalize() throws Throwable {
if (nativeStrikePtr != 0) {
disposeNativeStrikePtr(nativeStrikePtr);

View File

@ -163,7 +163,7 @@ public class CFRetainedResource {
}
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected final void finalize() throws Throwable {
dispose();
}

View File

@ -598,7 +598,7 @@ public final class CPrinterJob extends RasterPrinterJob {
// The following methods are CPrinterJob specific.
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() {
synchronized (fNSPrintInfoLock) {
if (fNSPrintInfo != -1) {

View File

@ -72,7 +72,7 @@ public final class SubImageInputStream extends ImageInputStreamImpl {
streamPos = pos;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
// Empty finalizer (for improved performance; no need to call
// super.finalize() in this case)

View File

@ -147,7 +147,7 @@ final class ChunkStream extends ImageOutputStreamImpl {
}
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
// Empty finalizer (for improved performance; no need to call
// super.finalize() in this case)
@ -284,7 +284,7 @@ final class IDATOutputStream extends ImageOutputStreamImpl {
}
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
// Empty finalizer (for improved performance; no need to call
// super.finalize() in this case)

View File

@ -435,7 +435,7 @@ public abstract class TIFFBaseJPEGCompressor extends TIFFCompressor {
return compDataLength;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
super.finalize();
if(JPEGWriter != null) {

View File

@ -139,7 +139,7 @@ public class TIFFJPEGDecompressor extends TIFFDecompressor {
JPEGReader.read(0, JPEGParam);
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
super.finalize();
JPEGReader.dispose();

View File

@ -610,7 +610,7 @@ public class TIFFOldJPEGDecompressor extends TIFFJPEGDecompressor {
JPEGReader.read(0, JPEGParam);
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
super.finalize();
JPEGReader.dispose();

View File

@ -60,7 +60,7 @@ public class StreamFinalizer {
this.stream = stream;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
try {
stream.close();

View File

@ -425,7 +425,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
* close this device if discarded by the garbage collector.
*/
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected final void finalize() {
close();
}

View File

@ -283,6 +283,7 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
@Override
@SuppressWarnings("removal")
protected void finalize() {
if (clip != null) {

View File

@ -1162,17 +1162,14 @@ public abstract class Graphics {
/**
* Disposes of this graphics context once it is no longer referenced.
*
* @deprecated The {@code finalize} method has been deprecated.
* Subclasses that override {@code finalize} in order to perform cleanup
* should be modified to use alternative cleanup mechanisms and
* to remove the overriding {@code finalize} method.
* When overriding the {@code finalize} method, its implementation must explicitly
* ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
* See the specification for {@link Object#finalize()} for further
* information about migration options.
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*
* @see #dispose
*/
@Deprecated(since="9")
@Deprecated(since="9", forRemoval=true)
@SuppressWarnings("removal")
public void finalize() {
dispose();
}

View File

@ -85,17 +85,14 @@ public abstract class PrintJob {
/**
* Ends this print job once it is no longer referenced.
*
* @deprecated The {@code finalize} method has been deprecated.
* Subclasses that override {@code finalize} in order to perform cleanup
* should be modified to use alternative cleanup mechanisms and
* to remove the overriding {@code finalize} method.
* When overriding the {@code finalize} method, its implementation must explicitly
* ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
* See the specification for {@link Object#finalize()} for further
* information about migration options.
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*
* @see #end
*/
@Deprecated(since="9")
@Deprecated(since="9", forRemoval=true)
@SuppressWarnings("removal")
public void finalize() {
end();
}

View File

@ -680,16 +680,12 @@ public class ServiceRegistry {
* @exception Throwable if an error occurs during superclass
* finalization.
*
* @deprecated The {@code finalize} method has been deprecated.
* Subclasses that override {@code finalize} in order to perform cleanup
* should be modified to use alternative cleanup mechanisms and
* to remove the overriding {@code finalize} method.
* When overriding the {@code finalize} method, its implementation must explicitly
* ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
* See the specification for {@link Object#finalize()} for further
* information about migration options.
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*/
@Deprecated(since="9")
@Deprecated(since="9", forRemoval=true)
@SuppressWarnings("removal")
public void finalize() throws Throwable {
deregisterAll();
super.finalize();
@ -842,7 +838,7 @@ class SubRegistry {
accMap.clear();
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
public synchronized void finalize() {
clear();
}

View File

@ -261,16 +261,12 @@ public class FileCacheImageInputStream extends ImageInputStreamImpl {
/**
* {@inheritDoc}
*
* @deprecated The {@code finalize} method has been deprecated.
* Subclasses that override {@code finalize} in order to perform cleanup
* should be modified to use alternative cleanup mechanisms and
* to remove the overriding {@code finalize} method.
* When overriding the {@code finalize} method, its implementation must explicitly
* ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
* See the specification for {@link Object#finalize()} for further
* information about migration options.
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*/
@Deprecated(since="9")
@Deprecated(since="9", forRemoval=true)
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
// Empty finalizer: for performance reasons we instead use the
// Disposer mechanism for ensuring that the underlying

View File

@ -156,16 +156,12 @@ public class FileImageInputStream extends ImageInputStreamImpl {
/**
* {@inheritDoc}
*
* @deprecated The {@code finalize} method has been deprecated.
* Subclasses that override {@code finalize} in order to perform cleanup
* should be modified to use alternative cleanup mechanisms and
* to remove the overriding {@code finalize} method.
* When overriding the {@code finalize} method, its implementation must explicitly
* ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
* See the specification for {@link Object#finalize()} for further
* information about migration options.
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*/
@Deprecated(since="9")
@Deprecated(since="9", forRemoval=true)
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
// Empty finalizer: for performance reasons we instead use the
// Disposer mechanism for ensuring that the underlying

View File

@ -164,16 +164,12 @@ public class FileImageOutputStream extends ImageOutputStreamImpl {
/**
* {@inheritDoc}
*
* @deprecated The {@code finalize} method has been deprecated.
* Subclasses that override {@code finalize} in order to perform cleanup
* should be modified to use alternative cleanup mechanisms and
* to remove the overriding {@code finalize} method.
* When overriding the {@code finalize} method, its implementation must explicitly
* ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
* See the specification for {@link Object#finalize()} for further
* information about migration options.
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*/
@Deprecated(since="9")
@Deprecated(since="9", forRemoval=true)
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
// Empty finalizer: for performance reasons we instead use the
// Disposer mechanism for ensuring that the underlying

View File

@ -868,16 +868,12 @@ public abstract class ImageInputStreamImpl implements ImageInputStream {
* @exception Throwable if an error occurs during superclass
* finalization.
*
* @deprecated The {@code finalize} method has been deprecated.
* Subclasses that override {@code finalize} in order to perform cleanup
* should be modified to use alternative cleanup mechanisms and
* to remove the overriding {@code finalize} method.
* When overriding the {@code finalize} method, its implementation must explicitly
* ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
* See the specification for {@link Object#finalize()} for further
* information about migration options.
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*/
@Deprecated(since="9")
@Deprecated(since="9", forRemoval=true)
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
if (!isClosed) {
try {

View File

@ -179,16 +179,12 @@ public class MemoryCacheImageInputStream extends ImageInputStreamImpl {
/**
* {@inheritDoc}
*
* @deprecated The {@code finalize} method has been deprecated.
* Subclasses that override {@code finalize} in order to perform cleanup
* should be modified to use alternative cleanup mechanisms and
* to remove the overriding {@code finalize} method.
* When overriding the {@code finalize} method, its implementation must explicitly
* ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
* See the specification for {@link Object#finalize()} for further
* information about migration options.
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*/
@Deprecated(since="9")
@Deprecated(since="9", forRemoval=true)
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
// Empty finalizer: for performance reasons we instead use the
// Disposer mechanism for ensuring that the underlying

View File

@ -350,7 +350,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab
return rec.offset;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
// schedule the record to be removed later
// on another thread.

View File

@ -3656,7 +3656,7 @@ public final class SunGraphics2D
* enough to know that if our override is empty then it should not
* mark us as finalizeable.
*/
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
public void finalize() {
// DO NOT REMOVE THIS METHOD
}

View File

@ -1336,7 +1336,7 @@ public class PeekGraphics extends Graphics2D
/**
* Empty finalizer as no clean up needed here.
*/
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
public void finalize() {
}

View File

@ -940,7 +940,7 @@ public class PrintJob2D extends PrintJob implements Printable, Runnable {
* Ends this print job once it is no longer referenced.
* @see #end
*/
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
public void finalize() {
end();
}

View File

@ -1099,7 +1099,7 @@ public class ProxyGraphics extends Graphics {
/**
* Empty finalizer as no clean up needed here.
*/
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
public void finalize() {
}

View File

@ -1264,7 +1264,7 @@ public class ProxyGraphics2D extends Graphics2D implements PrinterGraphics {
/**
* Empty finalizer as no clean up needed here.
*/
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
public void finalize() {
}

View File

@ -172,7 +172,7 @@ public abstract class X11InputMethodBase extends InputMethodAdapter {
}
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
dispose();
super.finalize();

View File

@ -133,7 +133,7 @@ final class WInputMethod extends InputMethodAdapter
}
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable
{
// Release the resources used by the native input context.

View File

@ -207,9 +207,15 @@ public interface MemoryMXBean extends PlatformManagedObject {
* Returns the approximate number of objects for which
* finalization is pending.
*
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for details.
*
* @return the approximate number objects for which finalization
* is pending.
* is pending. If this MemoryMXBean contains information about a JVM in
* which finalization has been disabled or removed, this method always
* returns zero.
*/
@Deprecated(since="18")
public int getObjectPendingFinalizationCount();
/**

View File

@ -58,6 +58,7 @@ class MemoryImpl extends NotificationEmitterSupport
this.jvm = vm;
}
@SuppressWarnings("deprecation")
public int getObjectPendingFinalizationCount() {
return jdk.internal.misc.VM.getFinalRefCount();
}

View File

@ -383,7 +383,7 @@ abstract class AbstractLdapNamingEnumeration<T extends NameClassPair>
listArg = ne.listArg;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected final void finalize() {
cleanup();
}

View File

@ -477,7 +477,7 @@ public final class LdapClient implements PooledConnection {
}
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() {
if (debug > 0) System.err.println("LdapClient: finalize " + this);
forceClose(pooled);

View File

@ -2639,7 +2639,7 @@ public final class LdapCtx extends ComponentDirContext
// ----------------- Connection ---------------------
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() {
try {
close();

View File

@ -131,7 +131,7 @@ final class DefaultCallbackHandler implements CallbackHandler {
}
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
clearPassword();
}

View File

@ -128,7 +128,7 @@ class LogInputStream extends InputStream {
/**
* Closes the stream when garbage is collected.
*/
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws IOException {
close();
}

View File

@ -132,7 +132,7 @@ public class GSSCredElement implements GSSCredentialSpi {
return "N/A";
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
dispose();
}

View File

@ -290,7 +290,7 @@ public class GSSNameElement implements GSSNameSpi {
}
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
dispose();
}

View File

@ -639,7 +639,7 @@ class NativeGSSContext implements GSSContextSpi {
return isInitiator;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
dispose();
}

View File

@ -136,7 +136,7 @@ abstract class CramMD5Base {
}
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() {
clearPassword();
}

View File

@ -195,7 +195,7 @@ final class PlainClient implements SaslClient {
}
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() {
clearPassword();
}

View File

@ -276,7 +276,7 @@ final class CardImpl extends Card {
+ ", protocol " + getProtocol() + ", state " + state;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
try {
if (state == State.OK) {

View File

@ -243,7 +243,7 @@ final class P11KeyStore extends KeyStoreSpi {
pc.setPassword(password); // this clones the password if not null
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
if (password != null) {
Arrays.fill(password, ' ');

View File

@ -1615,7 +1615,7 @@ public class PKCS11 {
*
* @exception Throwable If finalization fails.
*/
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
disconnect();
}

View File

@ -55,7 +55,7 @@ abstract class CKey implements Key, Length {
this.hCryptKey = hCryptKey;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
try {
synchronized(this) {

View File

@ -113,6 +113,7 @@ class SummaryTab extends Tab {
StringBuilder buf;
@SuppressWarnings("deprecation")
synchronized Result formatSummary() {
Result result = new Result();
ProxyClient proxyClient = vmPanel.getProxyClient();

View File

@ -112,7 +112,7 @@ final class ChunkInputStream extends InputStream {
}
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
super.finalize();
close();

View File

@ -137,7 +137,7 @@ final class ChunksChannel implements ReadableByteChannel {
}
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
super.finalize();
close();

View File

@ -134,7 +134,7 @@ final class RepositoryChunk {
}
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() {
boolean destroy = false;
synchronized (this) {

View File

@ -148,7 +148,7 @@ public class DnsClient {
}
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() {
close();
}

View File

@ -120,7 +120,7 @@ public class RegistryContext implements Context, Referenceable {
reference = ctx.reference;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() {
close();
}
@ -596,7 +596,7 @@ class BindingEnumeration implements NamingEnumeration<Binding> {
nextName = 0;
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() {
ctx.close();
}

View File

@ -162,7 +162,7 @@ abstract class GssKrb5Base extends AbstractSaslImpl {
}
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
dispose();
}

View File

@ -1219,7 +1219,7 @@ class ZipFileSystem extends FileSystem {
return zc.toString(name);
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected void finalize() throws IOException {
close();
}