author | hseigel |
Fri, 15 Dec 2017 11:23:50 -0500 | |
changeset 48463 | 474cec233fb2 |
permissions | -rw-r--r-- |
48463
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
1 |
/* |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
4 |
* |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
8 |
* |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
13 |
* accompanied this code). |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
14 |
* |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
18 |
* |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
21 |
* questions. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
22 |
* |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
23 |
*/ |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
24 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
25 |
/* |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
26 |
* @test |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
27 |
* @bug 8154587 |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
28 |
* @summary Check that calling clone() with an invokeinterface opcode throws an IAE |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
29 |
* even if there is a default method named clone() in a super interface. |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
30 |
* @compile DefaultNoCloneInC.jasm |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
31 |
* @run main DefaultNoCloneInC |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
32 |
*/ |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
33 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
34 |
// The below .jasm code implements the following java code: |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
35 |
// |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
36 |
// public class DefaultNoCloneInC { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
37 |
// |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
38 |
// interface I1 { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
39 |
// default Object clone() { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
40 |
// return "In I1's clone()"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
41 |
// } |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
42 |
// } |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
43 |
// |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
44 |
// |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
45 |
// interface I2 extends I1 { } |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
46 |
// |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
47 |
// |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
48 |
// static class C implements I2 { } |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
49 |
// |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
50 |
// |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
51 |
// static Object test(I2 i) { return i.clone(); } |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
52 |
// |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
53 |
// public static void main(String[] args) { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
54 |
// try { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
55 |
// String s = (String)test(new C()); |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
56 |
// throw new RuntimeException("Expected IAE not thrown"); |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
57 |
// } catch (java.lang.IllegalAccessError e) { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
58 |
// if (!e.toString().contains("C.clone")) { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
59 |
// throw new RuntimeException("Wrong IllegalAccessError exception thrown"); |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
60 |
// } |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
61 |
// } |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
62 |
// } |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
63 |
// } |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
64 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
65 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
66 |
interface DefaultNoCloneInC$I1 version 53:0 { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
67 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
68 |
public Method clone:"()Ljava/lang/Object;" stack 1 locals 1 { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
69 |
ldc String "In I1\'s clone()"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
70 |
areturn; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
71 |
} |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
72 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
73 |
static abstract interface InnerClass I1=class DefaultNoCloneInC$I1 of class DefaultNoCloneInC; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
74 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
75 |
} // end Class DefaultNoCloneInC$I1 |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
76 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
77 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
78 |
interface DefaultNoCloneInC$I2 implements DefaultNoCloneInC$I1 version 53:0 { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
79 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
80 |
static abstract interface InnerClass I2=class DefaultNoCloneInC$I2 of class DefaultNoCloneInC; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
81 |
static abstract interface InnerClass I1=class DefaultNoCloneInC$I1 of class DefaultNoCloneInC; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
82 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
83 |
} // end Class DefaultNoCloneInC$I2 |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
84 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
85 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
86 |
super class DefaultNoCloneInC$C implements DefaultNoCloneInC$I2 version 53:0 { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
87 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
88 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
89 |
Method "<init>":"()V" stack 1 locals 1 { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
90 |
aload_0; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
91 |
invokespecial Method java/lang/Object."<init>":"()V"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
92 |
return; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
93 |
} |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
94 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
95 |
static InnerClass C=class DefaultNoCloneInC$C of class DefaultNoCloneInC; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
96 |
static abstract interface InnerClass I2=class DefaultNoCloneInC$I2 of class DefaultNoCloneInC; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
97 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
98 |
} // end Class DefaultNoCloneInC$C |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
99 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
100 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
101 |
super public class DefaultNoCloneInC version 53:0 { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
102 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
103 |
public Method "<init>":"()V" stack 1 locals 1 { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
104 |
aload_0; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
105 |
invokespecial Method java/lang/Object."<init>":"()V"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
106 |
return; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
107 |
} |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
108 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
109 |
static Method test:"(LDefaultNoCloneInC$I2;)Ljava/lang/Object;" stack 1 locals 1 { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
110 |
aload_0; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
111 |
invokeinterface InterfaceMethod DefaultNoCloneInC$I2.clone:"()Ljava/lang/Object;", 1; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
112 |
areturn; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
113 |
} |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
114 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
115 |
public static Method main:"([Ljava/lang/String;)V" stack 3 locals 2 { |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
116 |
try t0; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
117 |
new class DefaultNoCloneInC$C; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
118 |
dup; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
119 |
invokespecial Method DefaultNoCloneInC$C."<init>":"()V"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
120 |
invokestatic Method test:"(LDefaultNoCloneInC$I2;)Ljava/lang/Object;"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
121 |
checkcast class java/lang/String; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
122 |
astore_1; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
123 |
new class java/lang/RuntimeException; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
124 |
dup; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
125 |
ldc String "Expected IAE not thrown"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
126 |
invokespecial Method java/lang/RuntimeException."<init>":"(Ljava/lang/String;)V"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
127 |
athrow; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
128 |
endtry t0; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
129 |
catch t0 java/lang/IllegalAccessError; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
130 |
stack_frame_type stack1; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
131 |
stack_map class java/lang/IllegalAccessError; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
132 |
astore_1; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
133 |
aload_1; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
134 |
invokevirtual Method java/lang/IllegalAccessError.toString:"()Ljava/lang/String;"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
135 |
ldc String "C.clone"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
136 |
invokevirtual Method java/lang/String.contains:"(Ljava/lang/CharSequence;)Z"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
137 |
ifne L47; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
138 |
new class java/lang/RuntimeException; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
139 |
dup; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
140 |
ldc String "Wrong IllegalAccessError exception thrown"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
141 |
invokespecial Method java/lang/RuntimeException."<init>":"(Ljava/lang/String;)V"; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
142 |
athrow; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
143 |
L47: stack_frame_type same; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
144 |
return; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
145 |
} |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
146 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
147 |
static InnerClass C=class DefaultNoCloneInC$C of class DefaultNoCloneInC; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
148 |
static abstract interface InnerClass I2=class DefaultNoCloneInC$I2 of class DefaultNoCloneInC; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
149 |
static abstract interface InnerClass I1=class DefaultNoCloneInC$I1 of class DefaultNoCloneInC; |
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
150 |
|
474cec233fb2
8154587: Resolution fails for default method named 'clone'
hseigel
parents:
diff
changeset
|
151 |
} // end Class DefaultNoCloneInC |