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