Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

java.lang.ref.ReferenceQueue parameterisation

843793Oct 31 2002 — edited Nov 1 2002
I want a ReferenceQueue into which I place only WeakReference<MyClass> objects, and from which I can poll WeakReference<MyClass> objects without casts or warnings.

I haven't been able to find any documentation on the genericised version of ReferenceQueue, and am going solely on error messages from the compiler. However, it appears that this class has public signature

public class ReferenceQueue<T>
{
Reference<T> poll();
� Reference<T> remove();
� Reference<T> remove(long�timeout);
}

Why? This doesn't seem very logical to me, and is forcing me to put in casts. Is there any good reason why it is not as follows?

public class ReferenceQueue<R extends Reference>
{
R poll();
R remove();
R remove(long timeout);
}

If not, is there any possibility that it would be altered thus before 1.5?

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 29 2002
Added on Oct 31 2002
2 comments
92 views