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_byte; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.iget_byte.d.T_iget_byte_1; 22 import dot.junit.opcodes.iget_byte.d.T_iget_byte_11; 23 import dot.junit.opcodes.iget_byte.d.T_iget_byte_12; 24 import dot.junit.opcodes.iget_byte.d.T_iget_byte_13; 25 import dot.junit.opcodes.iget_byte.d.T_iget_byte_21; 26 import dot.junit.opcodes.iget_byte.d.T_iget_byte_5; 27 import dot.junit.opcodes.iget_byte.d.T_iget_byte_6; 28 import dot.junit.opcodes.iget_byte.d.T_iget_byte_7; 29 import dot.junit.opcodes.iget_byte.d.T_iget_byte_8; 30 import dot.junit.opcodes.iget_byte.d.T_iget_byte_9; 31 32 public class Test_iget_byte extends DxTestCase { 33 34 /** 35 * @title get byte from field 36 */ testN1()37 public void testN1() { 38 T_iget_byte_1 t = new T_iget_byte_1(); 39 assertEquals(77, t.run()); 40 } 41 42 43 /** 44 * @title access protected field from subclass 45 */ testN3()46 public void testN3() { 47 //@uses dot.junit.opcodes.iget_byte.d.T_iget_byte_1 48 //@uses dot.junit.opcodes.iget_byte.d.T_iget_byte_11 49 T_iget_byte_11 t = new T_iget_byte_11(); 50 assertEquals(77, t.run()); 51 } 52 53 /** 54 * @title expected NullPointerException 55 */ testE2()56 public void testE2() { 57 loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_9", 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_byte.d.T_iget_byte_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_byte.d.T_iget_byte_3", VerifyError.class); 74 } 75 76 /** 77 * @constraint B13 78 * @title read byte 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_byte.d.T_iget_byte_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_byte.TestStubs 91 loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_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_byte.d.T_iget_byte_7", NoClassDefFoundError.class); 100 } 101 102 /** 103 * @constraint n/a 104 * @title Attempt to read undefined field. 105 */ testVFE6()106 public void testVFE6() { 107 loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_8", NoSuchFieldError.class); 108 } 109 110 /** 111 * @constraint n/a 112 * @title Attempt to read superclass' private field from subclass. 113 */ testVFE7()114 public void testVFE7() { 115 //@uses dot.junit.opcodes.iget_byte.d.T_iget_byte_1 116 loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_12", IllegalAccessError.class); 117 } 118 119 /** 120 * @constraint B1 121 * @title iget_byte shall not work for reference fields 122 */ testVFE8()123 public void testVFE8() { 124 load("dot.junit.opcodes.iget_byte.d.T_iget_byte_14", VerifyError.class); 125 } 126 127 /** 128 * @constraint B1 129 * @title iget_byte shall not work for short fields 130 */ testVFE9()131 public void testVFE9() { 132 load("dot.junit.opcodes.iget_byte.d.T_iget_byte_15", VerifyError.class); 133 } 134 135 /** 136 * @constraint B1 137 * @title iget_byte shall not work for int fields 138 */ testVFE10()139 public void testVFE10() { 140 load("dot.junit.opcodes.iget_byte.d.T_iget_byte_16", VerifyError.class); 141 } 142 143 /** 144 * @constraint B1 145 * @title iget_byte shall not work for char fields 146 */ testVFE11()147 public void testVFE11() { 148 load("dot.junit.opcodes.iget_byte.d.T_iget_byte_17", VerifyError.class); 149 } 150 151 /** 152 * @constraint B1 153 * @title iget_byte shall not work for boolean fields 154 */ testVFE12()155 public void testVFE12() { 156 load("dot.junit.opcodes.iget_byte.d.T_iget_byte_18", VerifyError.class); 157 } 158 159 /** 160 * @constraint B1 161 * @title iget_byte shall not work for double fields 162 */ testVFE13()163 public void testVFE13() { 164 load("dot.junit.opcodes.iget_byte.d.T_iget_byte_19", VerifyError.class); 165 } 166 167 /** 168 * @constraint B1 169 * @title iget_byte shall not work for long fields 170 */ testVFE14()171 public void testVFE14() { 172 load("dot.junit.opcodes.iget_byte.d.T_iget_byte_20", VerifyError.class); 173 } 174 175 /** 176 * @constraint B12 177 * @title Attempt to read inaccessible protected field. 178 */ testVFE15()179 public void testVFE15() { 180 //@uses dot.junit.opcodes.iget_byte.TestStubs 181 loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_21", IllegalAccessError.class); 182 } 183 184 185 /** 186 * @constraint A11 187 * @title Attempt to read static field. 188 */ testVFE16()189 public void testVFE16() { 190 //@uses dot.junit.opcodes.iget_byte.TestStubs 191 loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_5", 192 IncompatibleClassChangeError.class); 193 } 194 195 /** 196 * @constraint B6 197 * @title instance fields may only be accessed on already initialized instances. 198 */ testVFE30()199 public void testVFE30() { 200 load("dot.junit.opcodes.iget_byte.d.T_iget_byte_30", VerifyError.class); 201 } 202 203 /** 204 * @constraint N/A 205 * @title instance fields may only be accessed on reference values. 206 */ testVFE31()207 public void testVFE31() { 208 load("dot.junit.opcodes.iget_byte.d.T_iget_byte_31", VerifyError.class); 209 } 210 } 211