|
1 /* |
|
2 * Copyright (c) 2017, 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 /* |
|
26 * @test |
|
27 * @bug 8154587 |
|
28 * @summary Check that invokeinterface of clone() works properly where clone() is |
|
29 * an abstract method in a superinterface and not overridden locally. |
|
30 * @compile AbstractNoClones.jasm |
|
31 * @run main AbstractNoClones |
|
32 */ |
|
33 |
|
34 // The below .jasm code implements the following java code: |
|
35 // |
|
36 // public class AbstractNoClones { |
|
37 // |
|
38 // interface I1 { |
|
39 // Object clone(); |
|
40 // } |
|
41 // |
|
42 // interface I2 extends I1 { } |
|
43 // |
|
44 // static class C implements I2 { } |
|
45 // |
|
46 // static Object test(I2 i) { return i.clone(); } |
|
47 // |
|
48 // public static void main(String[] args) { |
|
49 // try { |
|
50 // String s = (String)test(new C()); |
|
51 // throw new RuntimeException("Expected IAE not thrown"); |
|
52 // } catch (java.lang.IllegalAccessError e) { |
|
53 // if (!e.toString().contains("C.clone")) { |
|
54 // throw new RuntimeException("Wrong IllegalAccessError exception thrown"); |
|
55 // } |
|
56 // } |
|
57 // } |
|
58 // } |
|
59 |
|
60 |
|
61 interface AbstractNoClones$I1 version 53:0 { |
|
62 |
|
63 public abstract Method clone:"()Ljava/lang/Object;"; |
|
64 |
|
65 static abstract interface InnerClass I1=class AbstractNoClones$I1 of class AbstractNoClones; |
|
66 |
|
67 } // end Class AbstractNoClones$I1 |
|
68 |
|
69 |
|
70 interface AbstractNoClones$I2 implements AbstractNoClones$I1 version 53:0 { |
|
71 |
|
72 static abstract interface InnerClass I2=class AbstractNoClones$I2 of class AbstractNoClones; |
|
73 static abstract interface InnerClass I1=class AbstractNoClones$I1 of class AbstractNoClones; |
|
74 |
|
75 } // end Class AbstractNoClones$I2 |
|
76 |
|
77 |
|
78 super class AbstractNoClones$C implements AbstractNoClones$I2 version 53:0 { |
|
79 |
|
80 Method "<init>":"()V" stack 1 locals 1 { |
|
81 aload_0; |
|
82 invokespecial Method java/lang/Object."<init>":"()V"; |
|
83 return; |
|
84 } |
|
85 |
|
86 static InnerClass C=class AbstractNoClones$C of class AbstractNoClones; |
|
87 static abstract interface InnerClass I2=class AbstractNoClones$I2 of class AbstractNoClones; |
|
88 |
|
89 } // end Class AbstractNoClones$C |
|
90 |
|
91 |
|
92 super public class AbstractNoClones version 53:0 { |
|
93 |
|
94 public Method "<init>":"()V" stack 1 locals 1 { |
|
95 aload_0; |
|
96 invokespecial Method java/lang/Object."<init>":"()V"; |
|
97 return; |
|
98 } |
|
99 |
|
100 static Method test:"(LAbstractNoClones$I2;)Ljava/lang/Object;" stack 1 locals 1 { |
|
101 aload_0; |
|
102 invokeinterface InterfaceMethod AbstractNoClones$I2.clone:"()Ljava/lang/Object;", 1; |
|
103 areturn; |
|
104 } |
|
105 |
|
106 public static Method main:"([Ljava/lang/String;)V" stack 3 locals 2 { |
|
107 try t0; |
|
108 new class AbstractNoClones$C; |
|
109 dup; |
|
110 invokespecial Method AbstractNoClones$C."<init>":"()V"; |
|
111 invokestatic Method test:"(LAbstractNoClones$I2;)Ljava/lang/Object;"; |
|
112 checkcast class java/lang/String; |
|
113 astore_1; |
|
114 new class java/lang/RuntimeException; |
|
115 dup; |
|
116 ldc String "Expected IAE not thrown"; |
|
117 invokespecial Method java/lang/RuntimeException."<init>":"(Ljava/lang/String;)V"; |
|
118 athrow; |
|
119 endtry t0; |
|
120 catch t0 java/lang/IllegalAccessError; |
|
121 stack_frame_type stack1; |
|
122 stack_map class java/lang/IllegalAccessError; |
|
123 astore_1; |
|
124 aload_1; |
|
125 invokevirtual Method java/lang/IllegalAccessError.toString:"()Ljava/lang/String;"; |
|
126 ldc String "C.clone"; |
|
127 invokevirtual Method java/lang/String.contains:"(Ljava/lang/CharSequence;)Z"; |
|
128 ifne L47; |
|
129 new class java/lang/RuntimeException; |
|
130 dup; |
|
131 ldc String "Wrong IllegalAccessError exception thrown"; |
|
132 invokespecial Method java/lang/RuntimeException."<init>":"(Ljava/lang/String;)V"; |
|
133 athrow; |
|
134 L47: stack_frame_type same; |
|
135 return; |
|
136 } |
|
137 |
|
138 static InnerClass C=class AbstractNoClones$C of class AbstractNoClones; |
|
139 static abstract interface InnerClass I2=class AbstractNoClones$I2 of class AbstractNoClones; |
|
140 static abstract interface InnerClass I1=class AbstractNoClones$I1 of class AbstractNoClones; |
|
141 |
|
142 } // end Class AbstractNoClones |