• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_9;
24 
25 public class Test_iget_boolean extends DxTestCase {
26 
27     /**
28      * @title get boolean from field
29      */
testN1()30     public void testN1() {
31         T_iget_boolean_1 t = new T_iget_boolean_1();
32         assertEquals(true, t.run());
33     }
34 
35 
36     /**
37      * @title access protected field from subclass
38      */
testN3()39     public void testN3() {
40         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_1
41         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_11
42         T_iget_boolean_11 t = new T_iget_boolean_11();
43         assertEquals(true, t.run());
44     }
45 
46     /**
47      * @title expected NullPointerException
48      */
testE2()49     public void testE2() {
50         T_iget_boolean_9 t = new T_iget_boolean_9();
51         try {
52             t.run();
53             fail("expected NullPointerException");
54         } catch (NullPointerException e) {
55             // expected
56         }
57     }
58 
59 
60 
61     /**
62      * @constraint A11
63      * @title constant pool index
64      */
testVFE1()65     public void testVFE1() {
66         try {
67             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_4");
68             fail("expected a verification exception");
69         } catch (Throwable t) {
70             DxUtil.checkVerifyException(t);
71         }
72     }
73 
74     /**
75      * @constraint A23
76      * @title number of registers
77      */
testVFE2()78     public void testVFE2() {
79         try {
80             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_3");
81             fail("expected a verification exception");
82         } catch (Throwable t) {
83             DxUtil.checkVerifyException(t);
84         }
85     }
86 
87     /**
88      * @constraint B13
89      * @title read boolean from long field - only field with same name but
90      * different type exists
91      */
testVFE3()92     public void testVFE3() {
93         try {
94             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_13");
95             fail("expected a verification exception");
96         } catch (Throwable t) {
97             DxUtil.checkVerifyException(t);
98         }
99     }
100 
101     /**
102      * @constraint n/a
103      * @title Attempt to read inaccessible field. Java throws IllegalAccessError
104      * on first access but Dalvik throws VerifyError on class loading.
105      */
testVFE4()106     public void testVFE4() {
107         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_6
108         //@uses dot.junit.opcodes.iget_boolean.TestStubs
109         try {
110             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_6");
111             fail("expected a verification exception");
112         } catch (Throwable t) {
113             DxUtil.checkVerifyException(t);
114         }
115     }
116 
117     /**
118      * @constraint n/a
119      * @title Attempt to read field of undefined class. Java throws NoClassDefFoundError
120      * on first access but Dalvik throws VerifyError on class loading.
121      */
testVFE5()122     public void testVFE5() {
123         try {
124             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_7");
125             fail("expected a verification exception");
126         } catch (Throwable t) {
127             DxUtil.checkVerifyException(t);
128         }
129     }
130 
131     /**
132      * @constraint n/a
133      * @title Attempt to read undefined field. Java throws NoSuchFieldError
134      * on first access but Dalvik throws VerifyError on class loading.
135      */
testVFE6()136     public void testVFE6() {
137         try {
138             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_8");
139             fail("expected a verification exception");
140         } catch (Throwable t) {
141             DxUtil.checkVerifyException(t);
142         }
143     }
144 
145     /**
146      * @constraint n/a
147      * @title Attempt to read superclass' private field from subclass. Java
148      * throws IllegalAccessError on first access but Dalvik throws VerifyError on class loading.
149      */
testVFE7()150     public void testVFE7() {
151         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_12
152         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_1
153         try {
154             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_12");
155             fail("expected a verification exception");
156         } catch (Throwable t) {
157             DxUtil.checkVerifyException(t);
158         }
159     }
160 
161     /**
162      * @constraint B1
163      * @title iget_boolean shall not work for reference fields
164      */
testVFE8()165     public void testVFE8() {
166         try {
167             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_14");
168             fail("expected a verification exception");
169         } catch (Throwable t) {
170             DxUtil.checkVerifyException(t);
171         }
172     }
173 
174     /**
175      *
176      * @constraint B1
177      * @title iget_boolean shall not work for short fields
178      */
testVFE9()179     public void testVFE9() {
180         try {
181             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_15");
182             fail("expected a verification exception");
183         } catch (Throwable t) {
184             DxUtil.checkVerifyException(t);
185         }
186     }
187 
188     /**
189      * @constraint B1
190      * @title iget_boolean shall not work for int fields
191      */
testVFE10()192     public void testVFE10() {
193         try {
194             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_16");
195             fail("expected a verification exception");
196         } catch (Throwable t) {
197             DxUtil.checkVerifyException(t);
198         }
199     }
200 
201     /**
202      * @constraint B1
203      * @title iget_boolean shall not work for char fields
204      */
testVFE11()205     public void testVFE11() {
206         try {
207             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_17");
208             fail("expected a verification exception");
209         } catch (Throwable t) {
210             DxUtil.checkVerifyException(t);
211         }
212     }
213 
214     /**
215      * @constraint B1
216      * @title iget_boolean shall not work for byte fields
217      */
testVFE12()218     public void testVFE12() {
219         try {
220             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_18");
221             fail("expected a verification exception");
222         } catch (Throwable t) {
223             DxUtil.checkVerifyException(t);
224         }
225     }
226 
227     /**
228      * @constraint B1
229      * @title iget_boolean shall not work for double fields
230      */
testVFE13()231     public void testVFE13() {
232         try {
233             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_19");
234             fail("expected a verification exception");
235         } catch (Throwable t) {
236             DxUtil.checkVerifyException(t);
237         }
238     }
239 
240     /**
241      * @constraint B1
242      * @title iget_boolean shall not work for long fields
243      */
testVFE14()244     public void testVFE14() {
245         try {
246             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_20");
247             fail("expected a verification exception");
248         } catch (Throwable t) {
249             DxUtil.checkVerifyException(t);
250         }
251     }
252 
253     /**
254      * @constraint B12
255      * @title Attempt to read inaccessible protected field. Java throws IllegalAccessError
256      * on first access but Dalvik throws VerifyError on class loading.
257      */
testVFE15()258     public void testVFE15() {
259         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_21
260         //@uses dot.junit.opcodes.iget_boolean.TestStubs
261         try {
262             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_21");
263             fail("expected a verification exception");
264         } catch (Throwable t) {
265             DxUtil.checkVerifyException(t);
266         }
267     }
268 
269 
270     /**
271      * @constraint A11
272      * @title Attempt to read static field. Java throws IncompatibleClassChangeError
273      * on first access but Dalvik throws VerifyError on class loading.
274      */
testVFE16()275     public void testVFE16() {
276         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_5
277         //@uses dot.junit.opcodes.iget_boolean.TestStubs
278 
279         try {
280             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_5");
281             fail("expected a verification exception");
282         } catch (Throwable t) {
283             DxUtil.checkVerifyException(t);
284         }
285     }
286 
287     /**
288      * @constraint B6
289      * @title instance fields may only be accessed on already initialized instances.
290      */
testVFE30()291     public void testVFE30() {
292         try {
293             Class.forName("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_30");
294             fail("expected a verification exception");
295         } catch (Throwable t) {
296             DxUtil.checkVerifyException(t);
297         }
298     }
299 }
300 
301