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