hotspot/test/compiler/intrinsics/object/TestClone.java
author hseigel
Wed, 01 Mar 2017 08:00:02 -0500
changeset 46194 5596e6f63072
parent 41705 332239c052cc
permissions -rw-r--r--
8172307: Remove ununsed JVM API JVM_GetModuleByPackageName() Summary: Remove get_module_by_package_name() etc., and unneeded test. Reviewed-by: sspitsyn, gtriantafill
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
     4
 *
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
     8
 *
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    13
 * accompanied this code).
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    14
 *
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    18
 *
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    21
 * questions.
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    22
 */
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    23
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    24
/*
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    25
 * @test
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    26
 * @bug 8033626
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    27
 * @summary assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 30604
diff changeset
    28
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    29
 * @library /test/lib
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    30
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    31
 * @run main/othervm -XX:-TieredCompilation -Xbatch
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    32
 *      -XX:CompileCommand=compileonly,compiler.intrinsics.object.TestClone::f
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    33
 *      compiler.intrinsics.object.TestClone
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    34
 */
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    35
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    36
package compiler.intrinsics.object;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    37
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 24945
diff changeset
    38
import jdk.test.lib.Asserts;
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    39
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    40
public class TestClone implements Cloneable {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    41
    static class A extends TestClone {}
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    42
    static class B extends TestClone {
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    43
        public B clone() {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    44
            return (B)TestClone.b;
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    45
        }
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    46
    }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    47
    static class C extends TestClone {
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    48
        public C clone() {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    49
            return (C)TestClone.c;
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    50
        }
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    51
    }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    52
    static class D extends TestClone {
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    53
        public D clone() {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    54
            return (D)TestClone.d;
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    55
        }
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    56
    }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    57
    static TestClone a = new A(), b = new B(), c = new C(), d = new D();
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    58
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    59
    public static Object f(TestClone o) throws CloneNotSupportedException {
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    60
        // Polymorphic call site: >90% Object::clone / <10% other methods
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    61
        return o.clone();
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    62
    }
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    63
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    64
    public static void main(String[] args) throws Exception {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    65
        TestClone[] params1 = {a, a, a, a, a, a, a, a, a, a, a,
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    66
                               a, a, a, a, a, a, a, a, a, a, a,
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    67
                               a, a, a, a, a, a, a, a, a, a, a,
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    68
                               b, c, d};
24945
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    69
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    70
        for (int i = 0; i < 15000; i++) {
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    71
            f(params1[i % params1.length]);
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    72
        }
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    73
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    74
        Asserts.assertTrue(f(a) != a);
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    75
        Asserts.assertTrue(f(b) == b);
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    76
        Asserts.assertTrue(f(c) == c);
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    77
        Asserts.assertTrue(f(d) == d);
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    78
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    79
        try {
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    80
            f(null);
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    81
            throw new AssertionError("");
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    82
        } catch (NullPointerException e) { /* expected */ }
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    83
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    84
        System.out.println("TEST PASSED");
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    85
    }
6df48e563632 8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
diff changeset
    86
}