test/runtime/lambda-features/TestInterfaceOrder.java

Mon, 06 Nov 2017 16:51:47 +0800

author
aoqi
date
Mon, 06 Nov 2017 16:51:47 +0800
changeset 7997
6cbff0651f1a
parent 7290
90257dfad6e3
permissions
-rw-r--r--

[Code Reorganization] remove trailing whitespace to pass jcheck test

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

mercurial