JAVA: Fix clone() on arrays

Bryce McKinlay bryce@albatross.co.nz
Sun Feb 18 00:35:00 GMT 2001


This patch fixes a recent regression with calling clone() on array
instances:

 http://gcc.gnu.org/ml/java/2001-02/msg00262.html

Although clone() is a protected method in object, array classes
implicitly "override" it with a public method that throws no checked
exceptions (10.7). This is actually implemented as a special case by
java compilers and runtimes, as a call to Object.clone() that is not
subject to the ordinary access and exception checks:

public class A2
{
  void a()
 {
    int[] copy = (int[]) new int[1].clone();
  }
}

$ jcf-dump A2.class
[...]
Constant pool (count: 20):
#2: Methodref class: 5=java.lang.Object name_and_type: 14=<clone
()java.lang.Object>
[...]

Now we're down to (on branch):

                === libjava Summary ===

# of expected passes            1597
# of unexpected failures        2
# of unexpected successes       17
# of expected failures          108

ok to commit?

regards

  [ bryce ]




More information about the Java-patches mailing list