2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package gov.nasa.jpf.jvm;
21 import gov.nasa.jpf.util.test.TestJPF;
22 import gov.nasa.jpf.vm.ClassInfo;
23 import gov.nasa.jpf.vm.ClassParseException;
24 import gov.nasa.jpf.vm.FieldInfo;
25 import gov.nasa.jpf.vm.MethodInfo;
30 import org.junit.Test;
33 * unit test for ClassInfo initialization
35 public class ClassInfoTest extends TestJPF {
38 String value() default "nothing";
46 public static class MyClass implements Cloneable {
47 public static final int D = 42;
51 public MyClass(String s) {
56 public static int whatIsIt() {
75 public boolean isItTheAnswer (boolean b, @X @Y({1,2,3}) int d, String s){
78 default: return false;
82 protected void foo() throws IndexOutOfBoundsException {
85 Object[] a = new Object[2];
89 String x = (String)a[0];
91 if (o instanceof Object[]){
94 if (o instanceof String){
98 Object[][] aa = new Object[2][2];
101 char c = s.charAt(d);
102 } catch (IndexOutOfBoundsException ioobx) {
103 System.out.println("too big");
115 public void testClassFileInitialization() {
116 File file = new File("build/tests/gov/nasa/jpf/jvm/ClassInfoTest$MyClass.class");
119 ClassInfo ci = new NonResolvedClassInfo( "gov.nasa.jpf.jvm.ClassInfoTest$MyClass", file);
121 assert ci.getName().equals("gov.nasa.jpf.jvm.ClassInfoTest$MyClass");
123 System.out.println("-- declared instance fields");
124 for (FieldInfo fi : ci.getDeclaredInstanceFields()){
125 System.out.print(fi.getType());
126 System.out.print(' ');
127 System.out.println(fi.getName());
130 assert ci.getNumberOfDeclaredInstanceFields() == 1;
131 assert ci.getNumberOfStaticFields() == 1;
133 System.out.println();
134 System.out.println("-- methods");
135 for (MethodInfo mi : ci){
136 System.out.println(mi.getUniqueName());
140 } catch (ClassParseException cfx){
141 //cfx.printStackTrace();
142 fail("ClassParseException: " + cfx);