hotspot/test/runtime/8026394/InterfaceObjectTest.java
author twisti
Fri, 06 Dec 2013 16:43:56 -0800
changeset 22224 f51ba6b5d472
parent 21078 5ae47e26f207
permissions -rw-r--r--
8029366: ShouldNotReachHere error when creating an array with component type of void Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21078
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
     1
/*
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
     4
 *
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
     8
 *
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    13
 * accompanied this code).
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    14
 *
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    18
 *
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    21
 * questions.
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    22
 */
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    23
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    24
/*
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    25
 * @test
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    26
 * @bug 8026394
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    27
 * @summary clone() and finalize() interface resolution should not receive IAE
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    28
 * @run main InterfaceObjectTest
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    29
 */
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    30
interface IClone extends Cloneable {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    31
    void finalize() throws Throwable;
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    32
    Object clone();
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    33
}
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    34
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    35
interface ICloneExtend extends IClone { }
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    36
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    37
public class InterfaceObjectTest implements ICloneExtend {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    38
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    39
    public Object clone() {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    40
        System.out.println("In InterfaceObjectTest's clone() method\n");
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    41
        return null;
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    42
    }
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    43
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    44
    public void finalize() throws Throwable {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    45
        try {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    46
            System.out.println("In InterfaceObjectTest's finalize() method\n");
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    47
        } catch (Throwable t) {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    48
            throw new AssertionError(t);
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    49
        }
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    50
    }
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    51
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    52
    public static void tryIt(ICloneExtend o1) {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    53
        try {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    54
            Object o2 = o1.clone();
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    55
            o1.finalize();
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    56
        } catch (Throwable t) {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    57
            if (t instanceof IllegalAccessError) {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    58
                System.out.println("TEST FAILS - IAE resulted\n");
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    59
                System.exit(1);
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    60
            }
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    61
        }
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    62
    }
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    63
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    64
    public static void main(String[] args) {
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    65
        InterfaceObjectTest o1 = new InterfaceObjectTest();
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    66
        tryIt(o1);
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    67
        System.out.println("TEST PASSES - no IAE resulted\n");
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    68
    }
5ae47e26f207 8026394: Eclipse fails with JDK8 build 111
hseigel
parents:
diff changeset
    69
}