< prev index next >

src/java.base/share/classes/java/lang/ref/Finalizer.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 30,44 **** import sun.misc.JavaLangAccess; import sun.misc.ManagedLocalsThread; import sun.misc.SharedSecrets; import sun.misc.VM; ! final class Finalizer extends FinalReference<Object> { /* Package-private; must be in ! same package as the Reference ! class */ ! private static ReferenceQueue<Object> queue = new ReferenceQueue<>(); private static Finalizer unfinalized = null; private static final Object lock = new Object(); private Finalizer next = null, --- 30,44 ---- import sun.misc.JavaLangAccess; import sun.misc.ManagedLocalsThread; import sun.misc.SharedSecrets; import sun.misc.VM; ! final class Finalizer extends FinalReference<Object> /* Package-private; must be in */ ! implements Finalizable { /* same package as the Reference */ ! /* class */ ! static ReferenceQueue<Object> queue = new ReferenceQueue<>(); private static Finalizer unfinalized = null; private static final Object lock = new Object(); private Finalizer next = null,
*** 104,113 **** --- 104,119 ---- } } catch (Throwable x) { } super.clear(); } + /** Finalizable implementation */ + @Override + public void runFinalizable() { + runFinalizer(SharedSecrets.getJavaLangAccess()); + } + /* Create a privileged secondary finalizer thread in the system thread group for the given Runnable, and wait for it to complete. This method is used by both runFinalization and runFinalizersOnExit. The former method invokes all pending finalizers, while the latter
*** 148,163 **** private volatile boolean running; public void run() { // in case of recursive call to run() if (running) return; - final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { ! Finalizer f = (Finalizer)queue.poll(); if (f == null) break; ! f.runFinalizer(jla); } } }); } --- 154,168 ---- private volatile boolean running; public void run() { // in case of recursive call to run() if (running) return; running = true; for (;;) { ! Finalizable f = (Finalizable)queue.poll(); if (f == null) break; ! f.runFinalizable(); } } }); }
*** 204,219 **** VM.awaitBooted(); } catch (InterruptedException x) { // ignore and continue } } - final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { try { ! Finalizer f = (Finalizer)queue.remove(); ! f.runFinalizer(jla); } catch (InterruptedException x) { // ignore and continue } } } --- 209,223 ---- VM.awaitBooted(); } catch (InterruptedException x) { // ignore and continue } } running = true; for (;;) { try { ! Finalizable f = (Finalizable)queue.remove(); ! f.runFinalizable(); } catch (InterruptedException x) { // ignore and continue } } }
< prev index next >