1 /*
 2  * Copyright (c) 2020, 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 
24 /**
25  * @test
26  * @bug 8237069
27  * @summary Introduce and wire-in the new top interfaces
28  * @run main/othervm TopInterfaceTest
29  */
30 
31 public class TopInterfaceTest  {
32 
33     static class C {}
34 
35     static primitive class V {
36         int x = 42;
37     }
38 
39     interface I {
40     }
41 
42     @interface A {
43     }
44 
45     public static void main(String args[]) {
46 
47         V inln_o = new V();
48         C id_o = new C();
49 
50 
51         Class<?> [] ca = inln_o.getClass().getInterfaces();
52         if (ca.length != 1 || !ca[0].getCanonicalName().equals("java.lang.PrimitiveObject"))
53             throw new AssertionError("Found wrong super interfaces");
54 
55         // Check that V's super class is Object in class file.
56         Class<?> jlo = inln_o.getClass().getSuperclass();
57         if (!jlo.getCanonicalName().equals("java.lang.Object"))
58             throw new AssertionError("Wrong super type for value type");
59         if (jlo.getInterfaces().length != 0)
60             throw new AssertionError("Wrong number of super interfaces for jlO");
61 
62         if (!(id_o instanceof IdentityObject))
63             throw new AssertionError("Expected identity Object");
64 
65 
66 
67         // Check that no super interface injection has happened for interfaces.
68         if (I.class.getInterfaces().length != 0)
69             throw new AssertionError("Found extraneous super interfaces");
70 
71         // Check that no super interface injection has happened for annotation types.
72         ca = A.class.getInterfaces();
73         if (ca.length != 1)
74             throw new AssertionError("Found extraneous super interfaces");
75         if (!ca[0].getCanonicalName().equals("java.lang.annotation.Annotation"))
76             throw new AssertionError("Found wrong super interfaces");
77     }
78 }