Coverage Summary for Class: FinalizablePhantomReference (com.google.common.base)

Class Class, % Method, % Line, %
FinalizablePhantomReference 0% (0/1) 0% (0/1) 0% (0/2)


1 /* 2  * Copyright (C) 2007 The Guava Authors 3  * 4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5  * in compliance with the License. You may obtain a copy of the License at 6  * 7  * http://www.apache.org/licenses/LICENSE-2.0 8  * 9  * Unless required by applicable law or agreed to in writing, software distributed under the License 10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11  * or implied. See the License for the specific language governing permissions and limitations under 12  * the License. 13  */ 14  15 package com.google.common.base; 16  17 import com.google.common.annotations.GwtIncompatible; 18 import java.lang.ref.PhantomReference; 19 import java.lang.ref.ReferenceQueue; 20 import javax.annotation.CheckForNull; 21  22 /** 23  * Phantom reference with a {@code finalizeReferent()} method which a background thread invokes 24  * after the garbage collector reclaims the referent. This is a simpler alternative to using a 25  * {@link ReferenceQueue}. 26  * 27  * <p>Unlike a normal phantom reference, this reference will be cleared automatically. 28  * 29  * @author Bob Lee 30  * @since 2.0 31  */ 32 @GwtIncompatible 33 @ElementTypesAreNonnullByDefault 34 public abstract class FinalizablePhantomReference<T> extends PhantomReference<T> 35  implements FinalizableReference { 36  /** 37  * Constructs a new finalizable phantom reference. 38  * 39  * @param referent to phantom reference 40  * @param queue that should finalize the referent 41  */ 42  protected FinalizablePhantomReference(@CheckForNull T referent, FinalizableReferenceQueue queue) { 43  super(referent, queue.queue); 44  queue.cleanUp(); 45  } 46 }