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