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.sget_byte; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.sget_byte.d.T_sget_byte_1; 22 import dot.junit.opcodes.sget_byte.d.T_sget_byte_11; 23 import dot.junit.opcodes.sget_byte.d.T_sget_byte_12; 24 import dot.junit.opcodes.sget_byte.d.T_sget_byte_13; 25 import dot.junit.opcodes.sget_byte.d.T_sget_byte_5; 26 import dot.junit.opcodes.sget_byte.d.T_sget_byte_6; 27 import dot.junit.opcodes.sget_byte.d.T_sget_byte_7; 28 import dot.junit.opcodes.sget_byte.d.T_sget_byte_8; 29 import dot.junit.opcodes.sget_byte.d.T_sget_byte_9; 30 31 public class Test_sget_byte extends DxTestCase { 32 33 /** 34 * @title get byte from static field 35 */ testN1()36 public void testN1() { 37 T_sget_byte_1 t = new T_sget_byte_1(); 38 assertEquals(77, t.run()); 39 } 40 41 42 /** 43 * @title access protected field from subclass 44 */ testN3()45 public void testN3() { 46 //@uses dot.junit.opcodes.sget_byte.d.T_sget_byte_1 47 //@uses dot.junit.opcodes.sget_byte.d.T_sget_byte_11 48 T_sget_byte_11 t = new T_sget_byte_11(); 49 assertEquals(77, t.run()); 50 } 51 52 /** 53 * @constraint A12 54 * @title attempt to access non-static field 55 */ testE1()56 public void testE1() { 57 loadAndRun("dot.junit.opcodes.sget_byte.d.T_sget_byte_5", 58 IncompatibleClassChangeError.class); 59 } 60 61 /** 62 * @title initialization of referenced class throws exception 63 */ testE6()64 public void testE6() { 65 loadAndRun("dot.junit.opcodes.sget_byte.d.T_sget_byte_9", 66 ExceptionInInitializerError.class); 67 } 68 69 70 71 /** 72 * @constraint A12 73 * @title constant pool index 74 */ testVFE1()75 public void testVFE1() { 76 load("dot.junit.opcodes.sget_byte.d.T_sget_byte_4", VerifyError.class); 77 } 78 79 /** 80 * 81 * @constraint A23 82 * @title number of registers 83 */ testVFE2()84 public void testVFE2() { 85 load("dot.junit.opcodes.sget_byte.d.T_sget_byte_3", VerifyError.class); 86 } 87 88 /** 89 * 90 * @constraint B13 91 * @title read byte from long field - only field with same name but 92 * different type exists 93 */ testVFE3()94 public void testVFE3() { 95 loadAndRun("dot.junit.opcodes.sget_byte.d.T_sget_byte_13", NoSuchFieldError.class); 96 } 97 98 /** 99 * @constraint n/a 100 * @title Attempt to read inaccessible field. 101 */ testVFE4()102 public void testVFE4() { 103 //@uses dot.junit.opcodes.sget_byte.TestStubs 104 loadAndRun("dot.junit.opcodes.sget_byte.d.T_sget_byte_6", IllegalAccessError.class); 105 } 106 107 /** 108 * @constraint n/a 109 * @title Attempt to read field of undefined class. 110 */ testVFE5()111 public void testVFE5() { 112 loadAndRun("dot.junit.opcodes.sget_byte.d.T_sget_byte_7", NoClassDefFoundError.class); 113 } 114 115 /** 116 * @constraint n/a 117 * @title Attempt to read undefined field. 118 */ testVFE6()119 public void testVFE6() { 120 loadAndRun("dot.junit.opcodes.sget_byte.d.T_sget_byte_8", NoSuchFieldError.class); 121 } 122 123 /** 124 * @constraint n/a 125 * @title Attempt to read superclass' private field from subclass. 126 */ testVFE7()127 public void testVFE7() { 128 //@uses dot.junit.opcodes.sget_byte.d.T_sget_byte_1 129 loadAndRun("dot.junit.opcodes.sget_byte.d.T_sget_byte_12", IllegalAccessError.class); 130 } 131 132 /** 133 * @constraint B1 134 * @title sget_byte shall not work for reference fields 135 */ testVFE8()136 public void testVFE8() { 137 load("dot.junit.opcodes.sget_byte.d.T_sget_byte_14", VerifyError.class); 138 } 139 140 /** 141 * 142 * @constraint B1 143 * @title sget_byte shall not work for short fields 144 */ testVFE9()145 public void testVFE9() { 146 load("dot.junit.opcodes.sget_byte.d.T_sget_byte_15", VerifyError.class); 147 } 148 149 /** 150 * 151 * @constraint B1 152 * @title sget_byte shall not work for int fields 153 */ testVFE10()154 public void testVFE10() { 155 load("dot.junit.opcodes.sget_byte.d.T_sget_byte_16", VerifyError.class); 156 } 157 158 /** 159 * 160 * @constraint B1 161 * @title sget_byte shall not work for char fields 162 */ testVFE11()163 public void testVFE11() { 164 load("dot.junit.opcodes.sget_byte.d.T_sget_byte_17", VerifyError.class); 165 } 166 167 /** 168 * 169 * @constraint B1 170 * @title sget_byte shall not work for boolean fields 171 */ testVFE12()172 public void testVFE12() { 173 load("dot.junit.opcodes.sget_byte.d.T_sget_byte_18", VerifyError.class); 174 } 175 176 /** 177 * 178 * @constraint B1 179 * @title sget_byte shall not work for double fields 180 */ testVFE13()181 public void testVFE13() { 182 load("dot.junit.opcodes.sget_byte.d.T_sget_byte_19", VerifyError.class); 183 } 184 185 /** 186 * 187 * @constraint B1 188 * @title sget_byte shall not work for long fields 189 */ testVFE14()190 public void testVFE14() { 191 load("dot.junit.opcodes.sget_byte.d.T_sget_byte_20", VerifyError.class); 192 } 193 } 194