src/java.base/share/classes/java/io/FileOutputStream.java
changeset 49900 770679787db5
parent 48941 4f11514fe783
child 52149 0edbbc64393c
--- a/src/java.base/share/classes/java/io/FileOutputStream.java	Thu Apr 26 09:04:09 2018 -0400
+++ b/src/java.base/share/classes/java/io/FileOutputStream.java	Thu Apr 26 17:14:04 2018 +0200
@@ -95,7 +95,7 @@
 
     private volatile boolean closed;
 
-    private final AltFinalizer altFinalizer;
+    private final Object altFinalizer;
 
     /**
      * Creates a file output stream to write to the file with the
@@ -235,7 +235,7 @@
         this.path = name;
 
         open(name, append);
-        altFinalizer = AltFinalizer.get(this);
+        altFinalizer = getFinalizer(this);
         if (altFinalizer == null) {
             FileCleanable.register(fd);   // open sets the fd, register the cleanup
         }
@@ -496,6 +496,24 @@
         initIDs();
     }
 
+    /*
+     * Returns a finalizer object if the FOS needs a finalizer; otherwise null.
+     * If the FOS has a close method; it needs an AltFinalizer.
+     */
+    private static Object getFinalizer(FileOutputStream fos) {
+        Class<?> clazz = fos.getClass();
+        while (clazz != FileOutputStream.class) {
+            try {
+                clazz.getDeclaredMethod("close");
+                return new AltFinalizer(fos);
+            } catch (NoSuchMethodException nsme) {
+                // ignore
+            }
+            clazz = clazz.getSuperclass();
+        }
+        return null;
+    }
+
     /**
      * Class to call {@code FileOutputStream.close} when finalized.
      * If finalization of the stream is needed, an instance is created
@@ -506,25 +524,7 @@
     static class AltFinalizer {
         private final FileOutputStream fos;
 
-        /*
-         * Returns a finalizer object if the FOS needs a finalizer; otherwise null.
-         * If the FOS has a close method; it needs an AltFinalizer.
-         */
-        static AltFinalizer get(FileOutputStream fos) {
-            Class<?> clazz = fos.getClass();
-            while (clazz != FileOutputStream.class) {
-                try {
-                    clazz.getDeclaredMethod("close");
-                    return new AltFinalizer(fos);
-                } catch (NoSuchMethodException nsme) {
-                    // ignore
-                }
-                clazz = clazz.getSuperclass();
-            }
-            return null;
-        }
-
-        private AltFinalizer(FileOutputStream fos) {
+        AltFinalizer(FileOutputStream fos) {
             this.fos = fos;
         }