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