jaroslav@601: /* jaroslav@601: * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. jaroslav@601: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@601: * jaroslav@601: * This code is free software; you can redistribute it and/or modify it jaroslav@601: * under the terms of the GNU General Public License version 2 only, as jaroslav@601: * published by the Free Software Foundation. Oracle designates this jaroslav@601: * particular file as subject to the "Classpath" exception as provided jaroslav@601: * by Oracle in the LICENSE file that accompanied this code. jaroslav@601: * jaroslav@601: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@601: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@601: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@601: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@601: * accompanied this code). jaroslav@601: * jaroslav@601: * You should have received a copy of the GNU General Public License version jaroslav@601: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@601: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@601: * jaroslav@601: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@601: * or visit www.oracle.com if you need additional information or have any jaroslav@601: * questions. jaroslav@601: */ jaroslav@601: jaroslav@601: package java.lang.ref; jaroslav@601: jaroslav@601: jaroslav@601: /** jaroslav@601: * Weak reference objects, which do not prevent their referents from being jaroslav@601: * made finalizable, finalized, and then reclaimed. Weak references are most jaroslav@601: * often used to implement canonicalizing mappings. jaroslav@601: * jaroslav@601: *

Suppose that the garbage collector determines at a certain point in time jaroslav@601: * that an object is weakly jaroslav@601: * reachable. At that time it will atomically clear all weak references to jaroslav@601: * that object and all weak references to any other weakly-reachable objects jaroslav@601: * from which that object is reachable through a chain of strong and soft jaroslav@601: * references. At the same time it will declare all of the formerly jaroslav@601: * weakly-reachable objects to be finalizable. At the same time or at some jaroslav@601: * later time it will enqueue those newly-cleared weak references that are jaroslav@601: * registered with reference queues. jaroslav@601: * jaroslav@601: * @author Mark Reinhold jaroslav@601: * @since 1.2 jaroslav@601: */ jaroslav@601: jaroslav@601: public class WeakReference extends Reference { jaroslav@601: jaroslav@601: /** jaroslav@601: * Creates a new weak reference that refers to the given object. The new jaroslav@601: * reference is not registered with any queue. jaroslav@601: * jaroslav@601: * @param referent object the new weak reference will refer to jaroslav@601: */ jaroslav@601: public WeakReference(T referent) { jaroslav@601: super(referent); jaroslav@601: } jaroslav@601: jaroslav@601: /** jaroslav@601: * Creates a new weak reference that refers to the given object and is jaroslav@601: * registered with the given queue. jaroslav@601: * jaroslav@601: * @param referent object the new weak reference will refer to jaroslav@601: * @param q the queue with which the reference is to be registered, jaroslav@601: * or null if registration is not required jaroslav@601: */ jaroslav@601: public WeakReference(T referent, ReferenceQueue q) { jaroslav@601: super(referent, q); jaroslav@601: } jaroslav@601: jaroslav@601: }