|
Quick Lists
|
|
Bug ID:
|
4191252
|
|
Votes
|
2
|
|
Synopsis
|
The Java language should allow covariant method return types
|
|
Category
|
java:specification
|
|
Reported Against
|
1.2rc1
|
|
Release Fixed
|
|
|
State
|
11-Closed, duplicate of 4144488,
request for enhancement
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
|
|
Submit Date
|
19-NOV-1998
|
|
Description
|
The Java virtual machine, for reasons of binary compatibility, already
allows a method to be overridden by a method of the same signature
but with a return type which is a subtype of the method it overrides.
For greater type safety, the Java language should remove the restriction
that overriding methods must have the same return type as the methods
they override.
I will submit a more detailed proposal, including changes to the JLS, in
the future.
Note that this is a 100% compatible change.
(Review ID: 42168)
======================================================================
Posted Date : 2006-07-13 02:52:11.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
Good idea. Dealt with as part of the GJ proposal.
xxxxx@xxxxx 1998-12-01
Duplicate of 4144488 which was added to Tiger (jdk5.0) under JSR-14:
http://jcp.org/en/jsr/detail?id=14
A complete description of this language feature may be found in the Java Language Specification, Third Edition. A reasonable place for a reader to being might be section 8.1.2 "Generic Classes and Type Parameters".
http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html
http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.2
Posted Date : 2006-07-13 02:52:11.0
|
|
Comments
|
Submitted On 06-JUL-1999
mslocum
Also see #4144488
Submitted On 30-JUN-2000
VerchinineK
To be logical, one should also allow to the argument
types of
the new method to be supertypes of the overridden one.
Submitted On 30-JAN-2001
schapel
It might be logical to allow contravariance of argument
types, that is, to allow argument types of overridding
methods to be supertypes of overridden methods. However,
adding such a capability would break existing Java programs.
Currently, methods with differing argument types are
overloaded methods, and such a change would cause many
overloaded methods to become overridding methods, changing
the behavior of old Java programs.
Adding covariance of return type, on the other hand,
will not change the behavior of any existing Java programs.
To vote for this feature, see bug 4144488.
Submitted On 14-DEC-2001
Zeljko
This is a duplicate of 4144488.
Submitted On 15-AUG-2002
anjiie
i do think so as well
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |