diff options
author | Tom Tromey <tromey@redhat.com> | 2004-08-07 19:32:56 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2004-08-07 19:32:56 +0000 |
commit | 72e7e16f924a8cec220229c8e7a7d81fc7318026 (patch) | |
tree | 1f9eba394fbb42d11aee59aa0f14509e0673341f | |
parent | 03d94035faf4459f521258aee5b45827466e7931 (diff) | |
download | classpath-72e7e16f924a8cec220229c8e7a7d81fc7318026.tar.gz |
* java/lang/ref/WeakReference.java: Now generic.
* java/lang/ref/SoftReference.java: Now generic.
* java/lang/ref/ReferenceQueue.java: Now generic.
* java/lang/ref/Reference.java: Now generic.
* java/lang/ref/PhantomReference.java: Now generic.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | java/lang/ref/PhantomReference.java | 10 | ||||
-rw-r--r-- | java/lang/ref/Reference.java | 16 | ||||
-rw-r--r-- | java/lang/ref/ReferenceQueue.java | 16 | ||||
-rw-r--r-- | java/lang/ref/SoftReference.java | 12 | ||||
-rw-r--r-- | java/lang/ref/WeakReference.java | 10 |
6 files changed, 38 insertions, 32 deletions
@@ -1,5 +1,11 @@ 2004-08-07 Tom Tromey <tromey@redhat.com> + * java/lang/ref/WeakReference.java: Now generic. + * java/lang/ref/SoftReference.java: Now generic. + * java/lang/ref/ReferenceQueue.java: Now generic. + * java/lang/ref/Reference.java: Now generic. + * java/lang/ref/PhantomReference.java: Now generic. + * java/lang/annotation/AnnotationFormatError.java: New file. * java/lang/annotation/IncompleteAnnotationException.java: New file. diff --git a/java/lang/ref/PhantomReference.java b/java/lang/ref/PhantomReference.java index 7b9eebaf7..ce4ef0052 100644 --- a/java/lang/ref/PhantomReference.java +++ b/java/lang/ref/PhantomReference.java @@ -1,5 +1,5 @@ /* java.lang.ref.PhantomReference - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,8 +46,8 @@ package java.lang.ref; * * @author Jochen Hoenicke */ -public class PhantomReference - extends Reference +public class PhantomReference<T> + extends Reference<T> { /** * Creates a new phantom reference. @@ -56,7 +56,7 @@ public class PhantomReference * finalized. This mustn't be <code>null</code>. * @exception NullPointerException if q is null. */ - public PhantomReference(Object referent, ReferenceQueue q) + public PhantomReference(T referent, ReferenceQueue<? super T> q) { super(referent, q); } @@ -66,7 +66,7 @@ public class PhantomReference * @return <code>null</code>, since the refered object may be * finalized and thus not accessible. */ - public Object get() + public T get() { return null; } diff --git a/java/lang/ref/Reference.java b/java/lang/ref/Reference.java index 5bac7e846..5c734833d 100644 --- a/java/lang/ref/Reference.java +++ b/java/lang/ref/Reference.java @@ -1,5 +1,5 @@ /* java.lang.ref.Reference - Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -70,19 +70,19 @@ package java.lang.ref; * @author Jochen Hoenicke * @see java.util.WeakHashtable */ -public abstract class Reference +public abstract class Reference<T> { /** * The underlying object. This field is handled in a special way by * the garbage collector. */ - Object referent; + T referent; /** * The queue this reference is registered on. This is null, if this * wasn't registered to any queue or reference was already enqueued. */ - ReferenceQueue queue; + ReferenceQueue<? super T> queue; /** * Link to the next entry on the queue. If this is null, this @@ -91,7 +91,7 @@ public abstract class Reference * (not to null, that value is used to mark a not enqueued * reference). */ - Reference nextOnQueue; + Reference<T> nextOnQueue; /** * This lock should be taken by the garbage collector, before @@ -106,7 +106,7 @@ public abstract class Reference * class in a different package. * @param referent the object we refer to. */ - Reference(Object ref) + Reference(T ref) { referent = ref; } @@ -119,7 +119,7 @@ public abstract class Reference * @param q the reference queue to register on. * @exception NullPointerException if q is null. */ - Reference(Object ref, ReferenceQueue q) + Reference(T ref, ReferenceQueue<? super T> q) { if (q == null) throw new NullPointerException(); @@ -132,7 +132,7 @@ public abstract class Reference * @return the object, this reference refers to, or null if the * reference was cleared. */ - public Object get() + public T get() { synchronized (lock) { diff --git a/java/lang/ref/ReferenceQueue.java b/java/lang/ref/ReferenceQueue.java index d876ee58c..ded979563 100644 --- a/java/lang/ref/ReferenceQueue.java +++ b/java/lang/ref/ReferenceQueue.java @@ -1,5 +1,5 @@ /* java.lang.ref.ReferenceQueue - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -50,7 +50,7 @@ package java.lang.ref; * @author Jochen Hoenicke * @see Reference#enqueue() */ -public class ReferenceQueue +public class ReferenceQueue<T> { /** * This is a linked list of references. If this is null, the list is @@ -76,7 +76,7 @@ public class ReferenceQueue * @return a reference on the queue, if there is one, * <code>null</code> otherwise. */ - public synchronized Reference poll() + public synchronized Reference<? extends T> poll() { return dequeue(); } @@ -85,7 +85,7 @@ public class ReferenceQueue * This is called by reference to enqueue itself on this queue. * @param ref the reference that should be enqueued. */ - synchronized void enqueue(Reference ref) + synchronized void enqueue(Reference<? extends T> ref) { /* last reference will point to itself */ ref.nextOnQueue = first == null ? ref : first; @@ -98,12 +98,12 @@ public class ReferenceQueue * Remove a reference from the queue, if there is one. * @return the first element of the queue, or null if there isn't any. */ - private Reference dequeue() + private Reference<? extends T> dequeue() { if (first == null) return null; - Reference result = first; + Reference<? extends T> result = first; first = (first == first.nextOnQueue) ? null : first.nextOnQueue; result.nextOnQueue = null; return result; @@ -118,7 +118,7 @@ public class ReferenceQueue * <code>null</code> if timeout period expired. * @exception InterruptedException if the wait was interrupted. */ - public synchronized Reference remove(long timeout) + public synchronized Reference<? extends T> remove(long timeout) throws InterruptedException { if (first == null) @@ -137,7 +137,7 @@ public class ReferenceQueue * @return the reference removed from the queue. * @exception InterruptedException if the wait was interrupted. */ - public Reference remove() + public Reference<? extends T> remove() throws InterruptedException { return remove(0L); diff --git a/java/lang/ref/SoftReference.java b/java/lang/ref/SoftReference.java index 059c6d3c0..ac66672fb 100644 --- a/java/lang/ref/SoftReference.java +++ b/java/lang/ref/SoftReference.java @@ -1,5 +1,5 @@ /* java.lang.ref.SoftReference - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,14 +47,14 @@ package java.lang.ref; * * @author Jochen Hoenicke */ -public class SoftReference - extends Reference +public class SoftReference<T> + extends Reference<T> { /** * Create a new soft reference, that is not registered to any queue. * @param referent the object we refer to. */ - public SoftReference(Object referent) + public SoftReference(T referent) { super(referent); } @@ -65,7 +65,7 @@ public class SoftReference * @param q the reference queue to register on. * @exception NullPointerException if q is null. */ - public SoftReference(Object referent, ReferenceQueue q) + public SoftReference(T referent, ReferenceQueue<? super T> q) { super(referent, q); } @@ -75,7 +75,7 @@ public class SoftReference * @return the object, this reference refers to, or null if the * reference was cleared. */ - public Object get() + public T get() { /* Why is this overloaded??? * Maybe for a kind of LRU strategy. */ diff --git a/java/lang/ref/WeakReference.java b/java/lang/ref/WeakReference.java index 2724c4ecf..618aa3338 100644 --- a/java/lang/ref/WeakReference.java +++ b/java/lang/ref/WeakReference.java @@ -1,5 +1,5 @@ /* java.lang.ref.WeakReference - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -54,14 +54,14 @@ package java.lang.ref; * @author Jochen Hoenicke * @see java.util.WeakHashtable */ -public class WeakReference - extends Reference +public class WeakReference<T> + extends Reference<T> { /** * Create a new weak reference, that is not registered to any queue. * @param referent the object we refer to. */ - public WeakReference(Object referent) + public WeakReference(T referent) { super(referent); } @@ -72,7 +72,7 @@ public class WeakReference * @param q the reference queue to register on. * @exception NullPointerException if q is null. */ - public WeakReference(Object referent, ReferenceQueue q) + public WeakReference(T referent, ReferenceQueue<? super T> q) { super(referent, q); } |