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.iget_object; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.iget_object.d.T_iget_object_1; 22 import dot.junit.opcodes.iget_object.d.T_iget_object_11; 23 import dot.junit.opcodes.iget_object.d.T_iget_object_12; 24 import dot.junit.opcodes.iget_object.d.T_iget_object_13; 25 import dot.junit.opcodes.iget_object.d.T_iget_object_21; 26 import dot.junit.opcodes.iget_object.d.T_iget_object_22; 27 import dot.junit.opcodes.iget_object.d.T_iget_object_35; 28 import dot.junit.opcodes.iget_object.d.T_iget_object_5; 29 import dot.junit.opcodes.iget_object.d.T_iget_object_6; 30 import dot.junit.opcodes.iget_object.d.T_iget_object_7; 31 import dot.junit.opcodes.iget_object.d.T_iget_object_8; 32 import dot.junit.opcodes.iget_object.d.T_iget_object_9; 33 34 public class Test_iget_object extends DxTestCase { 35 36 /** 37 * @title get reference from field 38 */ testN1()39 public void testN1() { 40 T_iget_object_1 t = new T_iget_object_1(); 41 assertEquals(null, t.run()); 42 } 43 44 45 /** 46 * @title access protected field from subclass 47 */ testN3()48 public void testN3() { 49 //@uses dot.junit.opcodes.iget_object.d.T_iget_object_1 50 //@uses dot.junit.opcodes.iget_object.d.T_iget_object_11 51 T_iget_object_11 t = new T_iget_object_11(); 52 assertEquals(null, t.run()); 53 } 54 55 /** 56 * @title expected NullPointerException 57 */ testE2()58 public void testE2() { 59 loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_9", NullPointerException.class); 60 } 61 62 /** 63 * @constraint A11 64 * @title constant pool index 65 */ testVFE1()66 public void testVFE1() { 67 load("dot.junit.opcodes.iget_object.d.T_iget_object_4", VerifyError.class); 68 } 69 70 /** 71 * @constraint A23 72 * @title number of registers 73 */ testVFE2()74 public void testVFE2() { 75 load("dot.junit.opcodes.iget_object.d.T_iget_object_3", VerifyError.class); 76 } 77 78 /** 79 * @constraint B13 80 * @title (read object from long field - only field with same name but 81 * different type exists) 82 */ testVFE3()83 public void testVFE3() { 84 loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_13", NoSuchFieldError.class); 85 } 86 87 /** 88 * @constraint n/a 89 * @title Attempt to read inaccessible field. 90 */ testVFE4()91 public void testVFE4() { 92 //@uses dot.junit.opcodes.iget_object.TestStubs 93 loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_6", IllegalAccessError.class); 94 } 95 96 /** 97 * @constraint n/a 98 * @title Attempt to read field of undefined class. 99 */ testVFE5()100 public void testVFE5() { 101 loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_7", NoClassDefFoundError.class); 102 } 103 104 /** 105 * @constraint n/a 106 * @title Attempt to read undefined field. 107 */ testVFE6()108 public void testVFE6() { 109 loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_8", NoSuchFieldError.class); 110 } 111 112 /** 113 * @constraint n/a 114 * @title Attempt to read superclass' private field from subclass. 115 */ testVFE7()116 public void testVFE7() { 117 //@uses dot.junit.opcodes.iget_object.d.T_iget_object_1 118 loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_12", IllegalAccessError.class); 119 } 120 121 /** 122 * @constraint B1 123 * @title iget_object shall not work for short fields 124 */ testVFE8()125 public void testVFE8() { 126 load("dot.junit.opcodes.iget_object.d.T_iget_object_14", VerifyError.class); 127 } 128 129 /** 130 * @constraint B1 131 * @title iget_object shall not work for char fields 132 */ testVFE9()133 public void testVFE9() { 134 load("dot.junit.opcodes.iget_object.d.T_iget_object_15", VerifyError.class); 135 } 136 137 /** 138 * @constraint B1 139 * @title iget_object shall not work for int fields 140 */ testVFE10()141 public void testVFE10() { 142 load("dot.junit.opcodes.iget_object.d.T_iget_object_16", VerifyError.class); 143 } 144 145 /** 146 * @constraint B1 147 * @title iget_object shall not work for byte fields 148 */ testVFE11()149 public void testVFE11() { 150 load("dot.junit.opcodes.iget_object.d.T_iget_object_17", VerifyError.class); 151 } 152 153 /** 154 * @constraint B1 155 * @title iget_object shall not work for boolean fields 156 */ testVFE12()157 public void testVFE12() { 158 load("dot.junit.opcodes.iget_object.d.T_iget_object_18", VerifyError.class); 159 } 160 161 /** 162 * @constraint B1 163 * @title iget_object shall not work for double fields 164 */ testVFE13()165 public void testVFE13() { 166 load("dot.junit.opcodes.iget_object.d.T_iget_object_19", VerifyError.class); 167 } 168 169 /** 170 * @constraint B1 171 * @title iget_object shall not work for long fields 172 */ testVFE14()173 public void testVFE14() { 174 load("dot.junit.opcodes.iget_object.d.T_iget_object_20", VerifyError.class); 175 } 176 177 /** 178 * @constraint B13 179 * @title only field of different type exists 180 */ testVFE15()181 public void testVFE15() { 182 loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_21", NoSuchFieldError.class); 183 } 184 185 /** 186 * @constraint B12 187 * @title Attempt to read inaccessible protected field. 188 */ testVFE16()189 public void testVFE16() { 190 //@uses dot.junit.opcodes.iget_object.TestStubs 191 loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_22", IllegalAccessError.class); 192 } 193 194 /** 195 * @constraint A11 196 * @title Attempt to read static field. 197 */ testVFE17()198 public void testVFE17() { 199 loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_5", 200 IncompatibleClassChangeError.class); 201 } 202 203 /** 204 * @constraint B6 205 * @title instance fields may only be accessed on already initialized instances. 206 */ testVFE30()207 public void testVFE30() { 208 load("dot.junit.opcodes.iget_object.d.T_iget_object_30", VerifyError.class); 209 } 210 211 /** 212 * @constraint N/A 213 * @title instance fields may only be accessed on already initialized instances. 214 */ testVFE31()215 public void testVFE31() { 216 load("dot.junit.opcodes.iget_object.d.T_iget_object_31", VerifyError.class); 217 } 218 219 /** 220 * @constraint N/A 221 * @title Attempt to read inaccessible protected field on uninitialized reference. 222 */ testVFE35()223 public void testVFE35() { 224 //@uses dot.junit.opcodes.iget_object.TestStubs 225 load("dot.junit.opcodes.iget_object.d.T_iget_object_35", VerifyError.class); 226 } 227 } 228