[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] [generics] Patch: FYI: java.lang.ref
From: |
Tom Tromey |
Subject: |
[cp-patches] [generics] Patch: FYI: java.lang.ref |
Date: |
07 Aug 2004 13:16:07 -0600 |
I'm checking this in on the generics branch.
Now java.lang.ref is genericized.
Tom
Index: ChangeLog
from Tom Tromey <address@hidden>
* 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.
Index: java/lang/ref/PhantomReference.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/ref/PhantomReference.java,v
retrieving revision 1.3
diff -u -r1.3 PhantomReference.java
--- java/lang/ref/PhantomReference.java 22 Jan 2002 22:27:00 -0000 1.3
+++ java/lang/ref/PhantomReference.java 7 Aug 2004 19:31:18 -0000
@@ -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 @@
*
* @author Jochen Hoenicke
*/
-public class PhantomReference
- extends Reference
+public class PhantomReference<T>
+ extends Reference<T>
{
/**
* Creates a new phantom reference.
@@ -56,7 +56,7 @@
* 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 @@
* @return <code>null</code>, since the refered object may be
* finalized and thus not accessible.
*/
- public Object get()
+ public T get()
{
return null;
}
Index: java/lang/ref/Reference.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/ref/Reference.java,v
retrieving revision 1.6
diff -u -r1.6 Reference.java
--- java/lang/ref/Reference.java 11 Feb 2004 18:47:18 -0000 1.6
+++ java/lang/ref/Reference.java 7 Aug 2004 19:31:18 -0000
@@ -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 @@
* @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 @@
* (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 @@
* class in a different package.
* @param referent the object we refer to.
*/
- Reference(Object ref)
+ Reference(T ref)
{
referent = ref;
}
@@ -119,7 +119,7 @@
* @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 @@
* @return the object, this reference refers to, or null if the
* reference was cleared.
*/
- public Object get()
+ public T get()
{
synchronized (lock)
{
Index: java/lang/ref/ReferenceQueue.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/ref/ReferenceQueue.java,v
retrieving revision 1.3
diff -u -r1.3 ReferenceQueue.java
--- java/lang/ref/ReferenceQueue.java 22 Jan 2002 22:27:00 -0000 1.3
+++ java/lang/ref/ReferenceQueue.java 7 Aug 2004 19:31:18 -0000
@@ -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 @@
* @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 @@
* @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 @@
* 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 @@
* 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 @@
* <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 @@
* @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);
Index: java/lang/ref/SoftReference.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/ref/SoftReference.java,v
retrieving revision 1.3
diff -u -r1.3 SoftReference.java
--- java/lang/ref/SoftReference.java 22 Jan 2002 22:27:00 -0000 1.3
+++ java/lang/ref/SoftReference.java 7 Aug 2004 19:31:18 -0000
@@ -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 @@
*
* @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 @@
* @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 @@
* @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. */
Index: java/lang/ref/WeakReference.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/ref/WeakReference.java,v
retrieving revision 1.3
diff -u -r1.3 WeakReference.java
--- java/lang/ref/WeakReference.java 22 Jan 2002 22:27:00 -0000 1.3
+++ java/lang/ref/WeakReference.java 7 Aug 2004 19:31:18 -0000
@@ -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 @@
* @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 @@
* @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);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] [generics] Patch: FYI: java.lang.ref,
Tom Tromey <=