blob: 9007ef4cb2573611d2f80a2562ad2319f9376abc [file] [log] [blame]
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package dot.junit.opcodes.invoke_super_range;
18
19import dot.junit.DxTestCase;
20import dot.junit.DxUtil;
21import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_1;
22import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_10;
23import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_14;
24import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_15;
25import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_17;
26import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_18;
27import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_19;
28import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_2;
29import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_20;
Jeff Hao5d7cb162013-08-02 16:59:44 -070030import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_24;
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -070031import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_4;
32import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_5;
33import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_6;
34import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_7;
35
36public class Test_invoke_super_range extends DxTestCase {
37
38 /**
39 * @title invoke method of superclass
40 */
41 public void testN1() {
42 //@uses dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_1
43 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
44 T_invoke_super_range_1 t = new T_invoke_super_range_1();
45 assertEquals(5, t.run());
46 }
47
48
49 /**
50 * @title Invoke protected method of superclass
51 */
52 public void testN3() {
53 //@uses dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_7
54 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
55 T_invoke_super_range_7 t = new T_invoke_super_range_7();
56 assertEquals(5, t.run());
57 }
58
59 /**
60 * @title Check that new frame is created by invoke_super_range and
61 * arguments are passed to method
62 */
63 public void testN5() {
64 //@uses dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_14
65 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
66 T_invoke_super_range_14 t = new T_invoke_super_range_14();
67 assertTrue(t.run());
68 }
69
70 /**
71 * @title Recursion of method lookup procedure
72 */
73 public void testN6() {
74 //@uses dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_17
75 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
76 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper2
77 T_invoke_super_range_17 t = new T_invoke_super_range_17();
78 assertEquals(5, t.run());
79 }
80
81 /**
82 * @title obj ref is null
83 */
84 public void testE1() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -070085 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
Andreas Gampe1d1a3a92014-08-23 00:11:27 -070086 loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_2",
87 NullPointerException.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -070088 }
89
90 /**
91 * @title Native method can't be linked
92 */
93 public void testE2() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -070094 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
Andreas Gampe1d1a3a92014-08-23 00:11:27 -070095 loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_4",
96 UnsatisfiedLinkError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -070097 }
98
99 /**
100 * @title Attempt to invoke abstract method
101 */
102 public void testE4() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700103 //@uses dot.junit.opcodes.invoke_super_range.ATest
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700104 loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_6",
105 AbstractMethodError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700106 }
107
108 /**
109 * @constraint A14
110 * @title invalid constant pool index
111 */
112 public void testVFE1() {
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700113 load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_8", VerifyError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700114 }
115
116 /**
117 * @constraint A15
118 * @title <clinit> may not be called using invoke-super
119 */
120 public void testVFE3() {
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700121 load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_10", VerifyError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700122 }
123
124 /**
125 * @constraint B1
126 * @title number of arguments passed to method
127 */
128 public void testVFE4() {
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700129 load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_11", VerifyError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700130 }
131
132 /**
133 * @constraint B9
134 * @title types of arguments passed to method.
135 */
136 public void testVFE5() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700137 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700138 load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_12", VerifyError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700139 }
140
141 /**
142 * @constraint A15
143 * @title <init> may not be called using invoke_super_range
144 */
145 public void testVFE6() {
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700146 load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_16", VerifyError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700147 }
148
149 /**
150 * @constraint B10
151 * @title assignment incompatible references when accessing
152 * protected method
153 */
154 public void testVFE8() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700155 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
156 //@uses dot.junit.opcodes.invoke_super_range.d.TPlain
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700157 load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_22", VerifyError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700158 }
159
160 /**
161 * @constraint B10
162 * @title assignment incompatible references when accessing
163 * public method
164 */
165 public void testVFE9() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700166 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
167 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper2
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700168 load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_23", VerifyError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700169 }
170
171 /**
172 * @constraint n/a
173 * @title Attempt to call static method.
174 */
175 public void testVFE10() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700176 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700177 loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_5",
178 IncompatibleClassChangeError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700179 }
180
181
182 /**
183 * @constraint n/a
184 * @title Attempt to invoke non-existing method.
185 */
186 public void testVFE12() {
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700187 loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_15",
188 NoSuchMethodError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700189 }
190
191 /**
192 * @constraint n/a
193 * @title Attempt to invoke private method of other class.
194 */
195 public void testVFE13() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700196 //@uses dot.junit.opcodes.invoke_super_range.TestStubs
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700197 loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_18",
198 IllegalAccessError.class, new TestStubs());
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700199 }
200
201 /**
202 * @constraint B12
203 * @title Attempt to invoke protected method of unrelated class.
204 */
205 public void testVFE14() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700206 //@uses dot.junit.opcodes.invoke_super_range.TestStubs
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700207 loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_20",
208 IllegalAccessError.class, new TestStubs());
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700209 }
210
211 /**
212 * @constraint n/a
213 * @title Method has different signature.
214 */
215 public void testVFE15() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700216 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700217 loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_19",
218 NoSuchMethodError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700219 }
220
221 /**
222 * @constraint n/a
223 * @title invoke-super/range shall be used to invoke private methods
224 */
225 public void testVFE16() {
226 //@uses dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_13
227 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700228 load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_13", VerifyError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700229 }
230
231 /**
232 * @constraint A23
233 * @title number of registers
234 */
235 public void testVFE17() {
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700236 load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_9", VerifyError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700237 }
238
239 /**
240 * @constraint A14
241 * @title attempt to invoke interface method
242 */
243 public void testVFE18() {
Jeff Hao5d7cb162013-08-02 16:59:44 -0700244 //@uses dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_24
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700245 loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_24",
246 IncompatibleClassChangeError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700247 }
248
249 /**
250 * @constraint B6
251 * @title instance methods may only be invoked on already initialized instances.
252 */
253 public void testVFE19() {
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700254 //@uses dot.junit.opcodes.invoke_super_range.d.TSuper
Andreas Gampe1d1a3a92014-08-23 00:11:27 -0700255 load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_25", VerifyError.class);
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700256 }
257
258}