test/runtime/lambda-features/TestInterfaceOrder.java

Wed, 20 May 2015 09:07:36 -0400

author
skovalev
date
Wed, 20 May 2015 09:07:36 -0400
changeset 7871
3820a7d64760
parent 7290
90257dfad6e3
permissions
-rw-r--r--

8078834: [TESTBUG] Tests fails on ARM64 due to unknown hardware
Reviewed-by: dholmes, adinn

acorn@7290 1 /*
acorn@7290 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
acorn@7290 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
acorn@7290 4 *
acorn@7290 5 * This code is free software; you can redistribute it and/or modify it
acorn@7290 6 * under the terms of the GNU General Public License version 2 only, as
acorn@7290 7 * published by the Free Software Foundation.
acorn@7290 8 *
acorn@7290 9 * This code is distributed in the hope that it will be useful, but WITHOUT
acorn@7290 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
acorn@7290 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
acorn@7290 12 * version 2 for more details (a copy is included in the LICENSE file that
acorn@7290 13 * accompanied this code).
acorn@7290 14 *
acorn@7290 15 * You should have received a copy of the GNU General Public License version
acorn@7290 16 * 2 along with this work; if not, write to the Free Software Foundation,
acorn@7290 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
acorn@7290 18 *
acorn@7290 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
acorn@7290 20 * or visit www.oracle.com if you need additional information or have any
acorn@7290 21 * questions.
acorn@7290 22 *
acorn@7290 23 */
acorn@7290 24
acorn@7290 25 /*
acorn@7290 26 * @test
acorn@7290 27 * @bug 8034275
acorn@7290 28 * @summary [JDK 8u40] Test interface initialization order
acorn@7290 29 * @run main TestInterfaceOrder
acorn@7290 30 */
acorn@7290 31
acorn@7290 32 import java.util.List;
acorn@7290 33 import java.util.Arrays;
acorn@7290 34 import java.util.ArrayList;
acorn@7290 35
acorn@7290 36 public class TestInterfaceOrder {
acorn@7290 37 static List<Class<?>> cInitOrder = new ArrayList<>();
acorn@7290 38
acorn@7290 39 public static void main(java.lang.String[] args) {
acorn@7290 40 //Trigger initialization
acorn@7290 41 C c = new C();
acorn@7290 42
acorn@7290 43 List<Class<?>> expectedCInitOrder = Arrays.asList(I.class, J.class, A.class, K.class, B.class, L.class, C.class);
acorn@7290 44 if (!cInitOrder.equals(expectedCInitOrder)) {
acorn@7290 45 throw new RuntimeException(String.format("Class initialization order %s not equal to expected order %s", cInitOrder, expectedCInitOrder));
acorn@7290 46 }
acorn@7290 47 }
acorn@7290 48
acorn@7290 49 interface I {
acorn@7290 50 boolean v = TestInterfaceOrder.out(I.class);
acorn@7290 51 default void i() {}
acorn@7290 52 }
acorn@7290 53
acorn@7290 54 interface J extends I {
acorn@7290 55 boolean v = TestInterfaceOrder.out(J.class);
acorn@7290 56 default void j() {}
acorn@7290 57 }
acorn@7290 58
acorn@7290 59 static class A implements J {
acorn@7290 60 static boolean v = TestInterfaceOrder.out(A.class);
acorn@7290 61 }
acorn@7290 62
acorn@7290 63 interface K extends I {
acorn@7290 64 boolean v = TestInterfaceOrder.out(K.class);
acorn@7290 65 default void k() {}
acorn@7290 66 }
acorn@7290 67
acorn@7290 68 static class B extends A implements K {
acorn@7290 69 static boolean v = TestInterfaceOrder.out(B.class);
acorn@7290 70 }
acorn@7290 71
acorn@7290 72 interface L {
acorn@7290 73 boolean v = TestInterfaceOrder.out(L.class);
acorn@7290 74 default void l() {}
acorn@7290 75 }
acorn@7290 76
acorn@7290 77 static class C extends B implements L {
acorn@7290 78 static boolean v = TestInterfaceOrder.out(C.class);
acorn@7290 79 }
acorn@7290 80
acorn@7290 81
acorn@7290 82 static boolean out(Class c) {
acorn@7290 83 System.out.println("#: initializing " + c.getName());
acorn@7290 84 cInitOrder.add(c);
acorn@7290 85 return true;
acorn@7290 86 }
acorn@7290 87
acorn@7290 88 }

mercurial