United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4856545 : add variance to the generic type system

Details
Type:
Enhancement
Submit Date:
2003-04-30
Status:
Closed
Updated Date:
2003-08-01
Project Name:
JDK
Resolved Date:
2003-08-01
Component:
tools
OS:
windows_2000
Sub-Component:
javac
CPU:
x86
Priority:
P4
Resolution:
Duplicate
Affected Versions:
1.4.2
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description
We propose to add covariant and contravariant type parameters to the
generics type system, as described and implemented in the JSR14 prototype 2.0

http://developer.java.sun.com/developer/earlyAccess/adding_generics/index.html

and as described on the Variance Generic Java home page

http://www.daimi.au.dk/~plesner/variance/

This closes the last known remaining hole in the generic type system and
adds significantly to the expressive power of generics.

###@###.### 2003-05-28

                                    

Comments
PUBLIC COMMENTS

.
                                     
2004-06-10
EVALUATION

An implementation and informal specification is out in the JSR14 prototype
for user feedback.

###@###.### 2003-04-30

Based on feedback within Sun, we are unlikely to do this for Tiger.

For arrays, we are likely to disallow arrays of (non-raw) generic
types to close the worst of the holes in the type system.

For generic classes, we are considering an alternative that has some
of the expressive power of the variance notation.  Under the "wildcard"
notation, Collection.addAll would have the signature

	void addAll(Collection<? extends E> c);
instead of
	<T extends E> void addAll(Collection<T> c);

Collection.removeAll would have the signature

	void removeAll<Collection<?> c);
instead of
	<T> void removeAll(Collection<T> c);

Collections.min would have the signature

	<T extends Object & Comparable<? super T>> T min(Collection<T> c);
instead of
	<U extends Object & Comparable<U>, T extends U> T min(Collection<T> c);

This still maintains the possibility of having Class be generic,
in which the type of
	A.class
is
	Class<A>

###@###.### 2003-06-16

There are really two requests combined into one in this RFE.
The request for variant/typesafe arrays has been split off as 4888066.
From now on this RFE refers only to covariant/contravariant support
for generic classes.

###@###.### 2003-07-09

Functionality equivalent to variant generic type arguments is available
as part of the basic generic type system when wildcards are used.
Wildcards are available in the early access JSR14 prototype at

  http://developer.java.sun.com/developer/earlyAccess/adding_generics/

Also included is a copy of the generics spec that includes mention of
wildcards.

###@###.### 2003-07-24
                                     
2003-07-24



Hardware and Software, Engineered to Work Together