The clone() method for array types incorrectly returns Object. But the
JLS3, 10.7 Array Members states: "The members of an array type are all
of the following: [...] The return type of the clone method of an array
type T[] is T[]."

The following Java class triggers the problem:

public class Test {
    int[] x = new int[1];
    int[] y = x.clone();
}

# gcj Test.java
Test.java:3: error: Type mismatch: cannot convert from Object to int[]
        int[] y = x.clone();
              ^
1 problem (1 error)

# gcj --version
gcj (Debian 4.3-20080202-1) 4.3.0 20080202 (experimental) [trunk revision
132072]
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


-- 
           Summary: clone() for array types has incorrect return type
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc dot ank2 at spamgourmet dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35410

Reply via email to