< prev index next >

src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java

Print this page

162      * @see #isCachedFile
163      */
164     public boolean isCachedMemory() {
165         return true;
166     }
167 
168     /**
169      * Closes this {@code MemoryCacheImageInputStream}, freeing
170      * the cache.  The source {@code InputStream} is not closed.
171      */
172     public void close() throws IOException {
173         super.close();
174         disposerRecord.dispose(); // this resets the MemoryCache
175         stream = null;
176         cache = null;
177     }
178 
179     /**
180      * {@inheritDoc}
181      *
182      * @deprecated The {@code finalize} method has been deprecated.
183      *     Subclasses that override {@code finalize} in order to perform cleanup
184      *     should be modified to use alternative cleanup mechanisms and
185      *     to remove the overriding {@code finalize} method.
186      *     When overriding the {@code finalize} method, its implementation must explicitly
187      *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
188      *     See the specification for {@link Object#finalize()} for further
189      *     information about migration options.
190      */
191     @Deprecated(since="9")

192     protected void finalize() throws Throwable {
193         // Empty finalizer: for performance reasons we instead use the
194         // Disposer mechanism for ensuring that the underlying
195         // MemoryCache is reset prior to garbage collection
196     }
197 
198     private static class StreamDisposerRecord implements DisposerRecord {
199         private MemoryCache cache;
200 
201         public StreamDisposerRecord(MemoryCache cache) {
202             this.cache = cache;
203         }
204 
205         public synchronized void dispose() {
206             if (cache != null) {
207                 cache.reset();
208                 cache = null;
209             }
210         }
211     }

162      * @see #isCachedFile
163      */
164     public boolean isCachedMemory() {
165         return true;
166     }
167 
168     /**
169      * Closes this {@code MemoryCacheImageInputStream}, freeing
170      * the cache.  The source {@code InputStream} is not closed.
171      */
172     public void close() throws IOException {
173         super.close();
174         disposerRecord.dispose(); // this resets the MemoryCache
175         stream = null;
176         cache = null;
177     }
178 
179     /**
180      * {@inheritDoc}
181      *
182      * @deprecated Finalization has been deprecated for removal.  See
183      * {@link java.lang.Object#finalize} for background information and details
184      * about migration options.





185      */
186     @Deprecated(since="9", forRemoval=true)
187     @SuppressWarnings("removal")
188     protected void finalize() throws Throwable {
189         // Empty finalizer: for performance reasons we instead use the
190         // Disposer mechanism for ensuring that the underlying
191         // MemoryCache is reset prior to garbage collection
192     }
193 
194     private static class StreamDisposerRecord implements DisposerRecord {
195         private MemoryCache cache;
196 
197         public StreamDisposerRecord(MemoryCache cache) {
198             this.cache = cache;
199         }
200 
201         public synchronized void dispose() {
202             if (cache != null) {
203                 cache.reset();
204                 cache = null;
205             }
206         }
207     }
< prev index next >