Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package dot.junit.opcodes.invoke_super_range; |
| 18 | |
| 19 | import dot.junit.DxTestCase; |
| 20 | import dot.junit.DxUtil; |
| 21 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_1; |
| 22 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_10; |
| 23 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_14; |
| 24 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_15; |
| 25 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_17; |
| 26 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_18; |
| 27 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_19; |
| 28 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_2; |
| 29 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_20; |
Jeff Hao | 5d7cb16 | 2013-08-02 16:59:44 -0700 | [diff] [blame] | 30 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_24; |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 31 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_4; |
| 32 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_5; |
| 33 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_6; |
| 34 | import dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_7; |
| 35 | |
| 36 | public 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 Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 85 | //@uses dot.junit.opcodes.invoke_super_range.d.TSuper |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 86 | loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_2", |
| 87 | NullPointerException.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | /** |
| 91 | * @title Native method can't be linked |
| 92 | */ |
| 93 | public void testE2() { |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 94 | //@uses dot.junit.opcodes.invoke_super_range.d.TSuper |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 95 | loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_4", |
| 96 | UnsatisfiedLinkError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | /** |
| 100 | * @title Attempt to invoke abstract method |
| 101 | */ |
| 102 | public void testE4() { |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 103 | //@uses dot.junit.opcodes.invoke_super_range.ATest |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 104 | loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_6", |
| 105 | AbstractMethodError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @constraint A14 |
| 110 | * @title invalid constant pool index |
| 111 | */ |
| 112 | public void testVFE1() { |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 113 | load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_8", VerifyError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | /** |
| 117 | * @constraint A15 |
| 118 | * @title <clinit> may not be called using invoke-super |
| 119 | */ |
| 120 | public void testVFE3() { |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 121 | load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_10", VerifyError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | /** |
| 125 | * @constraint B1 |
| 126 | * @title number of arguments passed to method |
| 127 | */ |
| 128 | public void testVFE4() { |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 129 | load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_11", VerifyError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | /** |
| 133 | * @constraint B9 |
| 134 | * @title types of arguments passed to method. |
| 135 | */ |
| 136 | public void testVFE5() { |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 137 | //@uses dot.junit.opcodes.invoke_super_range.d.TSuper |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 138 | load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_12", VerifyError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | /** |
| 142 | * @constraint A15 |
| 143 | * @title <init> may not be called using invoke_super_range |
| 144 | */ |
| 145 | public void testVFE6() { |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 146 | load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_16", VerifyError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /** |
| 150 | * @constraint B10 |
| 151 | * @title assignment incompatible references when accessing |
| 152 | * protected method |
| 153 | */ |
| 154 | public void testVFE8() { |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 155 | //@uses dot.junit.opcodes.invoke_super_range.d.TSuper |
| 156 | //@uses dot.junit.opcodes.invoke_super_range.d.TPlain |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 157 | load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_22", VerifyError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | /** |
| 161 | * @constraint B10 |
| 162 | * @title assignment incompatible references when accessing |
| 163 | * public method |
| 164 | */ |
| 165 | public void testVFE9() { |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 166 | //@uses dot.junit.opcodes.invoke_super_range.d.TSuper |
| 167 | //@uses dot.junit.opcodes.invoke_super_range.d.TSuper2 |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 168 | load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_23", VerifyError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | /** |
| 172 | * @constraint n/a |
| 173 | * @title Attempt to call static method. |
| 174 | */ |
| 175 | public void testVFE10() { |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 176 | //@uses dot.junit.opcodes.invoke_super_range.d.TSuper |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 177 | loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_5", |
| 178 | IncompatibleClassChangeError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | |
| 182 | /** |
| 183 | * @constraint n/a |
| 184 | * @title Attempt to invoke non-existing method. |
| 185 | */ |
| 186 | public void testVFE12() { |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 187 | loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_15", |
| 188 | NoSuchMethodError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | /** |
| 192 | * @constraint n/a |
| 193 | * @title Attempt to invoke private method of other class. |
| 194 | */ |
| 195 | public void testVFE13() { |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 196 | //@uses dot.junit.opcodes.invoke_super_range.TestStubs |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 197 | loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_18", |
| 198 | IllegalAccessError.class, new TestStubs()); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | /** |
| 202 | * @constraint B12 |
| 203 | * @title Attempt to invoke protected method of unrelated class. |
| 204 | */ |
| 205 | public void testVFE14() { |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 206 | //@uses dot.junit.opcodes.invoke_super_range.TestStubs |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 207 | loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_20", |
| 208 | IllegalAccessError.class, new TestStubs()); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | /** |
| 212 | * @constraint n/a |
| 213 | * @title Method has different signature. |
| 214 | */ |
| 215 | public void testVFE15() { |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 216 | //@uses dot.junit.opcodes.invoke_super_range.d.TSuper |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 217 | loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_19", |
| 218 | NoSuchMethodError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 219 | } |
| 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 Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 228 | load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_13", VerifyError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | /** |
| 232 | * @constraint A23 |
| 233 | * @title number of registers |
| 234 | */ |
| 235 | public void testVFE17() { |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 236 | load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_9", VerifyError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | /** |
| 240 | * @constraint A14 |
| 241 | * @title attempt to invoke interface method |
| 242 | */ |
| 243 | public void testVFE18() { |
Jeff Hao | 5d7cb16 | 2013-08-02 16:59:44 -0700 | [diff] [blame] | 244 | //@uses dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_24 |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 245 | loadAndRun("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_24", |
| 246 | IncompatibleClassChangeError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | /** |
| 250 | * @constraint B6 |
| 251 | * @title instance methods may only be invoked on already initialized instances. |
| 252 | */ |
| 253 | public void testVFE19() { |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 254 | //@uses dot.junit.opcodes.invoke_super_range.d.TSuper |
Andreas Gampe | 1d1a3a9 | 2014-08-23 00:11:27 -0700 | [diff] [blame] | 255 | load("dot.junit.opcodes.invoke_super_range.d.T_invoke_super_range_25", VerifyError.class); |
Tsu Chiang Chuang | 9a223d7 | 2011-04-27 17:19:46 -0700 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | } |