A DESCRIPTION OF THE REQUEST :
Please create a new interface: java.lang.ref.Ref.
Make java.lang.ref.Reference implement this interface.
public interface Ref<T> {
public T get()
/** Optional */
public void clear()
}
JUSTIFICATION :
I love the references package, and as anyone can see from bug reports, we have a request for more types of references (some examples):
6392701 - Add new class java.lang.ref.StrongReference
6493567 - Add a java.lang.ref.ExclusiveStrongReference class
Because java.lang.ref.Reference is an abstract class with package protected constructors, all these classes which developers want to create, cannot be created.
Don't make this interface strictly tied to garbage collection, thus, leave out the APIs related to GC, specifically, enqueue() and isEnqueued().
People should be able to replace all non GC uses of Reference with Ref (i.e. places where isEnqueud and enqueue are not used). I've seen plenty of code which passes around References because people like the idea of a Reference, but they are not concerned with GC. I've even see Reference extended to make a "HardReference", so people could pass that around.
CUSTOMER SUBMITTED WORKAROUND :
Currently, developers can accomplish a unified Ref architecture by creating their own Ref interface and extending all the existing java.lang.ref.References to implement their own Ref interface. Not very pretty.
IMHO, developers would prefer to use base classes / interfaces in the JDK.
Please create a new interface: java.lang.ref.Ref.
Make java.lang.ref.Reference implement this interface.
public interface Ref<T> {
public T get()
/** Optional */
public void clear()
}
JUSTIFICATION :
I love the references package, and as anyone can see from bug reports, we have a request for more types of references (some examples):
6392701 - Add new class java.lang.ref.StrongReference
6493567 - Add a java.lang.ref.ExclusiveStrongReference class
Because java.lang.ref.Reference is an abstract class with package protected constructors, all these classes which developers want to create, cannot be created.
Don't make this interface strictly tied to garbage collection, thus, leave out the APIs related to GC, specifically, enqueue() and isEnqueued().
People should be able to replace all non GC uses of Reference with Ref (i.e. places where isEnqueud and enqueue are not used). I've seen plenty of code which passes around References because people like the idea of a Reference, but they are not concerned with GC. I've even see Reference extended to make a "HardReference", so people could pass that around.
CUSTOMER SUBMITTED WORKAROUND :
Currently, developers can accomplish a unified Ref architecture by creating their own Ref interface and extending all the existing java.lang.ref.References to implement their own Ref interface. Not very pretty.
IMHO, developers would prefer to use base classes / interfaces in the JDK.