JDK-4881419 : The type of X[].clone() should be X[]
Type:Enhancement
Component:core-libs
Sub-Component:java.lang
Affected Version:5.0
Priority:P5
Status:Closed
Resolution:Fixed
OS:solaris_8
CPU:generic
Submitted:2003-06-19
Updated:2010-09-25
Resolved:2011-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
SUGGESTED FIX
# HG changeset patch
# User darcy
# Date 1283551210 25200
# Node ID a6c142240837370c71e6822815c2d11c7edba81c
# Parent e17654f00d93ca74556ff75efe3e9e06e3afd4d6
4881419: The type of X[].clone() should be X[]
Reviewed-by: martin
--- a/src/share/classes/java/lang/Object.java Fri Sep 03 21:03:45 2010 +0100
+++ b/src/share/classes/java/lang/Object.java Fri Sep 03 15:00:10 2010 -0700
@@ -189,7 +189,9 @@ public class Object {
* specific cloning operation. First, if the class of this object does
* not implement the interface {@code Cloneable}, then a
* {@code CloneNotSupportedException} is thrown. Note that all arrays
- * are considered to implement the interface {@code Cloneable}.
+ * are considered to implement the interface {@code Cloneable} and that
+ * the return type of the {@code clone} method of an array type {@code T[]}
+ * is {@code T[]} where T is any reference or primitive type.
* Otherwise, this method creates a new instance of the class of this
* object and initializes all its fields with exactly the contents of
* the corresponding fields of this object, as if by assignment; the
03-09-2010
PUBLIC COMMENTS
See core-libs thread
http://mail.openjdk.java.net/pipermail/core-libs-dev/2010-September/004807.html
Changeset:
http://hg.openjdk.java.net/jdk7/tl/jdk/rev/a6c142240837
03-09-2010
EVALUATION
JLS3 6.4.5 and 10.7 state that "The return type of the clone method of an array type T[] is T[]." The javadoc for Object#clone could note this.