Mercurial > hg > graal-jvmci-8
annotate test/compiler/types/TestMeetIncompatibleInterfaceArrays.java @ 24066:9050d85e2960 jdk8u102-b33
Added tag jdk8u102-b32 for changeset c8988d2e4212
author | asaha |
---|---|
date | Tue, 02 Aug 2016 08:02:27 -0700 |
parents | 09687c445ce1 |
children |
rev | line source |
---|---|
23849
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
1 /* |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
2 * Copyright 2015 SAP AG. All Rights Reserved. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
4 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
8 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
13 * accompanied this code). |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
14 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
18 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
21 * questions. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
22 */ |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
23 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
24 /* |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
25 * @test |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
26 * @bug 8141551 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
27 * @summary C2 can not handle returns with inccompatible interface arrays |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
28 * @library /testlibrary /testlibrary/whitebox/ |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
29 * @build sun.hotspot.WhiteBox |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
31 * sun.hotspot.WhiteBox$WhiteBoxPermission |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
32 * @run main/othervm |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
33 * -Xbootclasspath/a:. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
34 * -XX:+UnlockDiagnosticVMOptions |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
35 * -XX:+WhiteBoxAPI |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
36 * -Xbatch |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
37 * -XX:CompileThreshold=1 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
38 * -XX:-TieredCompilation |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
39 * -XX:CICompilerCount=1 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
40 * -XX:+PrintCompilation |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
41 * -XX:+PrintInlining |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
42 * -XX:CompileCommand=compileonly,MeetIncompatibleInterfaceArrays*.run |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
43 * -XX:CompileCommand=dontinline,TestMeetIncompatibleInterfaceArrays$Helper.createI2* |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
44 * -XX:CompileCommand=quiet |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
45 * TestMeetIncompatibleInterfaceArrays 0 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
46 * @run main/othervm |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
47 * -Xbootclasspath/a:. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
48 * -XX:+UnlockDiagnosticVMOptions |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
49 * -XX:+WhiteBoxAPI |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
50 * -Xbatch |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
51 * -XX:CompileThreshold=1 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
52 * -XX:-TieredCompilation |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
53 * -XX:CICompilerCount=1 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
54 * -XX:+PrintCompilation |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
55 * -XX:+PrintInlining |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
56 * -XX:CompileCommand=compileonly,MeetIncompatibleInterfaceArrays*.run |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
57 * -XX:CompileCommand=inline,TestMeetIncompatibleInterfaceArrays$Helper.createI2* |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
58 * -XX:CompileCommand=quiet |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
59 * TestMeetIncompatibleInterfaceArrays 1 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
60 * @run main/othervm |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
61 * -Xbootclasspath/a:. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
62 * -XX:+UnlockDiagnosticVMOptions |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
63 * -XX:+WhiteBoxAPI |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
64 * -Xbatch |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
65 * -XX:CompileThreshold=1 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
66 * -XX:Tier0InvokeNotifyFreqLog=0 -XX:Tier2InvokeNotifyFreqLog=0 -XX:Tier3InvokeNotifyFreqLog=0 -XX:Tier23InlineeNotifyFreqLog=0 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
67 * -XX:Tier3InvocationThreshold=2 -XX:Tier3MinInvocationThreshold=2 -XX:Tier3CompileThreshold=2 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
68 * -XX:Tier4InvocationThreshold=1 -XX:Tier4MinInvocationThreshold=1 -XX:Tier4CompileThreshold=1 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
69 * -XX:+TieredCompilation |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
70 * -XX:CICompilerCount=2 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
71 * -XX:+PrintCompilation |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
72 * -XX:+PrintInlining |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
73 * -XX:CompileCommand=compileonly,MeetIncompatibleInterfaceArrays*.run |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
74 * -XX:CompileCommand=compileonly,TestMeetIncompatibleInterfaceArrays$Helper.createI2* |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
75 * -XX:CompileCommand=inline,TestMeetIncompatibleInterfaceArrays$Helper.createI2* |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
76 * -XX:CompileCommand=quiet |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
77 * TestMeetIncompatibleInterfaceArrays 2 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
78 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
79 * @author volker.simonis@gmail.com |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
80 */ |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
81 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
82 import java.io.FileOutputStream; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
83 import java.lang.reflect.InvocationTargetException; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
84 import java.lang.reflect.Method; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
85 import jdk.internal.org.objectweb.asm.ClassWriter; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
86 import jdk.internal.org.objectweb.asm.MethodVisitor; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
87 import static jdk.internal.org.objectweb.asm.Opcodes.*; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
88 import sun.hotspot.WhiteBox; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
89 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
90 public class TestMeetIncompatibleInterfaceArrays extends ClassLoader { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
91 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
92 private static final WhiteBox WB = WhiteBox.getWhiteBox(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
93 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
94 public static interface I1 { public String getName(); } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
95 public static interface I2 { public String getName(); } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
96 public static class I2C implements I2 { public String getName() { return "I2";} } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
97 public static class I21C implements I2, I1 { public String getName() { return "I2 and I1";} } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
98 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
99 public static class Helper { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
100 public static I2 createI2Array0() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
101 return new I2C(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
102 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
103 public static I2[] createI2Array1() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
104 return new I2C[] { new I2C() }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
105 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
106 public static I2[][] createI2Array2() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
107 return new I2C[][] { new I2C[] { new I2C() } }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
108 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
109 public static I2[][][] createI2Array3() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
110 return new I2C[][][] { new I2C[][] { new I2C[] { new I2C() } } }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
111 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
112 public static I2[][][][] createI2Array4() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
113 return new I2C[][][][] { new I2C[][][] { new I2C[][] { new I2C[] { new I2C() } } } }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
114 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
115 public static I2[][][][][] createI2Array5() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
116 return new I2C[][][][][] { new I2C[][][][] { new I2C[][][] { new I2C[][] { new I2C[] { new I2C() } } } } }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
117 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
118 public static I2 createI21Array0() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
119 return new I21C(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
120 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
121 public static I2[] createI21Array1() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
122 return new I21C[] { new I21C() }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
123 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
124 public static I2[][] createI21Array2() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
125 return new I21C[][] { new I21C[] { new I21C() } }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
126 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
127 public static I2[][][] createI21Array3() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
128 return new I21C[][][] { new I21C[][] { new I21C[] { new I21C() } } }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
129 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
130 public static I2[][][][] createI21Array4() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
131 return new I21C[][][][] { new I21C[][][] { new I21C[][] { new I21C[] { new I21C() } } } }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
132 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
133 public static I2[][][][][] createI21Array5() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
134 return new I21C[][][][][] { new I21C[][][][] { new I21C[][][] { new I21C[][] { new I21C[] { new I21C() } } } } }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
135 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
136 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
137 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
138 // Location for the generated class files |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
139 public static final String PATH = System.getProperty("test.classes", ".") + java.io.File.separator; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
140 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
141 /* |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
142 * With 'good == false' this helper method creates the following classes |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
143 * (using the nested 'Helper' class and the nested interfaces 'I1' and 'I2'). |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
144 * For brevity I omit the enclosing class 'TestMeetIncompatibleInterfaceArrays' in the |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
145 * following examples: |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
146 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
147 * public class MeetIncompatibleInterfaceArrays0ASM { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
148 * public static I1 run() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
149 * return Helper.createI2Array0(); // returns I2 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
150 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
151 * public static void test() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
152 * I1 i1 = run(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
153 * System.out.println(i1.getName()); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
154 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
155 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
156 * public class MeetIncompatibleInterfaceArrays1ASM { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
157 * public static I1[] run() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
158 * return Helper.createI2Array1(); // returns I2[] |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
159 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
160 * public static void test() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
161 * I1[] i1 = run(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
162 * System.out.println(i1[0].getName()); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
163 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
164 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
165 * ... |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
166 * // MeetIncompatibleInterfaceArrays4ASM is special because it creates |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
167 * // an illegal class which will be rejected by the verifier. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
168 * public class MeetIncompatibleInterfaceArrays4ASM { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
169 * public static I1[][][][] run() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
170 * return Helper.createI2Array3(); // returns I1[][][] which gives a verifier error because return expects I1[][][][] |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
171 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
172 * public static void test() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
173 * I1[][][][][] i1 = run(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
174 * System.out.println(i1[0][0][0][0][0].getName()); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
175 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
176 * ... |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
177 * public class MeetIncompatibleInterfaceArrays5ASM { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
178 * public static I1[][][][][] run() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
179 * return Helper.createI2Array5(); // returns I2[][][][][] |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
180 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
181 * public static void test() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
182 * I1[][][][][] i1 = run(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
183 * System.out.println(i1[0][0][0][0][0].getName()); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
184 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
185 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
186 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
187 * Notice that this is not legal Java code. We would have to use a cast in "run()" to make it legal: |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
188 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
189 * public static I1[] run() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
190 * return (I1[])Helper.createI2Array1(); // returns I2[] |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
191 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
192 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
193 * But in pure bytecode, the "run()" methods are perfectly legal: |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
194 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
195 * public static I1[] run(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
196 * Code: |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
197 * 0: invokestatic #16 // Method Helper.createI2Array1:()[LI2; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
198 * 3: areturn |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
199 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
200 * The "test()" method calls the "getName()" function from I1 on the objects returned by "run()". |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
201 * This will epectedly fail with an "IncompatibleClassChangeError" because the objects returned |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
202 * by "run()" (and by createI2Array()) are actually of type "I2C" and only implement "I2" but not "I1". |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
203 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
204 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
205 * With 'good == true' this helper method will create the following classes: |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
206 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
207 * public class MeetIncompatibleInterfaceArraysGood0ASM { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
208 * public static I1 run() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
209 * return Helper.createI21Array0(); // returns I2 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
210 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
211 * public static void test() { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
212 * I1 i1 = run(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
213 * System.out.println(i1.getName()); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
214 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
215 * } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
216 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
217 * Calling "test()" on these objects will succeed and output "I2 and I1" because now the "run()" |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
218 * method calls "createI21Array()" which actually return an object (or an array of objects) of |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
219 * type "I21C" which implements both "I2" and "I1". |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
220 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
221 * Notice that at the bytecode level, the code for the "run()" and "test()" methods in |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
222 * "MeetIncompatibleInterfaceArraysASM" and "MeetIncompatibleInterfaceArraysGoodASM" look exactly |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
223 * the same. I.e. the verifier has no chance to verify if the I2 object returned by "createI1Array()" |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
224 * or "createI21Array()" implements "I1" or not. That's actually the reason why both versions of |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
225 * generated classes are legal from a verifier point of view. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
226 * |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
227 */ |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
228 static void generateTestClass(int dim, boolean good) throws Exception { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
229 String baseClassName = "MeetIncompatibleInterfaceArrays"; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
230 if (good) |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
231 baseClassName += "Good"; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
232 String createName = "createI2" + (good ? "1" : "") + "Array"; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
233 String a = ""; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
234 for (int i = 0; i < dim; i++) |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
235 a += "["; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
236 ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
237 cw.visit(V1_8, ACC_PUBLIC, baseClassName + dim + "ASM", null, "java/lang/Object", null); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
238 MethodVisitor constr = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
239 constr.visitCode(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
240 constr.visitVarInsn(ALOAD, 0); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
241 constr.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
242 constr.visitInsn(RETURN); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
243 constr.visitMaxs(0, 0); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
244 constr.visitEnd(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
245 MethodVisitor run = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "run", |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
246 "()" + a + "LTestMeetIncompatibleInterfaceArrays$I1;", null, null); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
247 run.visitCode(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
248 if (dim == 4) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
249 run.visitMethodInsn(INVOKESTATIC, "TestMeetIncompatibleInterfaceArrays$Helper", createName + 3, |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
250 "()" + "[[[" + "LTestMeetIncompatibleInterfaceArrays$I2;", false); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
251 } else { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
252 run.visitMethodInsn(INVOKESTATIC, "TestMeetIncompatibleInterfaceArrays$Helper", createName + dim, |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
253 "()" + a + "LTestMeetIncompatibleInterfaceArrays$I2;", false); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
254 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
255 run.visitInsn(ARETURN); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
256 run.visitMaxs(0, 0); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
257 run.visitEnd(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
258 MethodVisitor test = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "test", "()V", null, null); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
259 test.visitCode(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
260 test.visitMethodInsn(INVOKESTATIC, baseClassName + dim + "ASM", "run", |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
261 "()" + a + "LTestMeetIncompatibleInterfaceArrays$I1;", false); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
262 test.visitVarInsn(ASTORE, 0); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
263 if (dim > 0) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
264 test.visitVarInsn(ALOAD, 0); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
265 for (int i = 1; i <= dim; i++) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
266 test.visitInsn(ICONST_0); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
267 test.visitInsn(AALOAD); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
268 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
269 test.visitVarInsn(ASTORE, 1); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
270 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
271 test.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
272 test.visitVarInsn(ALOAD, dim > 0 ? 1 : 0); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
273 test.visitMethodInsn(INVOKEINTERFACE, "TestMeetIncompatibleInterfaceArrays$I1", "getName", |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
274 "()Ljava/lang/String;", true); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
275 test.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/Object;)V", false); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
276 test.visitInsn(RETURN); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
277 test.visitMaxs(0, 0); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
278 test.visitEnd(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
279 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
280 // Get the bytes of the class.. |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
281 byte[] b = cw.toByteArray(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
282 // ..and write them into a class file (for debugging) |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
283 FileOutputStream fos = new FileOutputStream(PATH + baseClassName + dim + "ASM.class"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
284 fos.write(b); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
285 fos.close(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
286 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
287 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
288 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
289 public static String[][] tier = { { "interpreted", "C2 (tier 4) without inlining", "C2 (tier4) without inlining" }, |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
290 { "interpreted", "C2 (tier 4) with inlining", "C2 (tier4) with inlining" }, |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
291 { "interpreted", "C1 (tier 3) with inlining", "C2 (tier4) with inlining" } }; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
292 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
293 public static void main(String[] args) throws Exception { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
294 final int pass = Integer.parseInt(args.length > 0 ? args[0] : "0"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
295 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
296 // Load and initialize some classes required for compilation |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
297 Class.forName("TestMeetIncompatibleInterfaceArrays$I1"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
298 Class.forName("TestMeetIncompatibleInterfaceArrays$I2"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
299 Class.forName("TestMeetIncompatibleInterfaceArrays$Helper"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
300 |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
301 for (int g = 0; g < 2; g++) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
302 String baseClassName = "MeetIncompatibleInterfaceArrays"; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
303 boolean good = (g == 0) ? false : true; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
304 if (good) |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
305 baseClassName += "Good"; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
306 for (int i = 0; i < 6; i++) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
307 System.out.println(); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
308 System.out.println("Creating " + baseClassName + i + "ASM.class"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
309 System.out.println("========================================" + "=" + "========="); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
310 // Create the "MeetIncompatibleInterfaceArrays<i>ASM" class |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
311 generateTestClass(i, good); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
312 Class<?> c = null; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
313 try { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
314 c = Class.forName(baseClassName + i + "ASM"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
315 } catch (VerifyError ve) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
316 if (i == 4) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
317 System.out.println("OK - must be (" + ve.getMessage() + ")."); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
318 } else { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
319 throw ve; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
320 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
321 continue; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
322 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
323 // Call MeetIncompatibleInterfaceArrays<i>ASM.test() |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
324 Method m = c.getMethod("test"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
325 Method r = c.getMethod("run"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
326 for (int j = 0; j < 3; j++) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
327 System.out.println((j + 1) + ". invokation of " + baseClassName + i + "ASM.test() [should be " |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
328 + tier[pass][j] + "]"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
329 try { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
330 m.invoke(null); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
331 } catch (InvocationTargetException ite) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
332 if (good) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
333 throw ite; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
334 } else { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
335 if (ite.getCause() instanceof IncompatibleClassChangeError) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
336 System.out.println(" OK - catched InvocationTargetException(" |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
337 + ite.getCause().getMessage() + ")."); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
338 } else { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
339 throw ite; |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
340 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
341 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
342 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
343 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
344 System.out.println("Method " + r + (WB.isMethodCompiled(r) ? " has" : " has not") + " been compiled."); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
345 if (!WB.isMethodCompiled(r)) { |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
346 throw new Exception("Method " + r + " must be compiled!"); |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
347 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
348 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
349 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
350 } |
09687c445ce1
8141551: C2 can not handle returns with inccompatible interface arrays
shshahma
parents:
diff
changeset
|
351 } |