Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

JavaLangSystemReflection.java

00001 package gov.nasa.arc.ase.jpf.jvm.reflection;
00002 
00003 import gov.nasa.arc.ase.jpf.jvm.ClassInfo;
00004 import gov.nasa.arc.ase.jpf.jvm.ThreadInfo;
00005 import gov.nasa.arc.ase.jpf.jvm.MethodInfo;
00006 import gov.nasa.arc.ase.jpf.jvm.bytecode.Instruction;
00007 //#ifdef JDK11
00008 
00009 
00010 //#else JDK11
00011 import java.util.List;
00012 import java.util.Iterator;
00013 //#endif JDK11
00014 
00015 public class JavaLangSystemReflection extends Reflection {
00016   public Instruction executeStaticMethod(MethodInfo mi) {
00017     String name = mi.getFullName();
00018 
00019     if(name.equals("<clinit>()V")) {
00020       // this is the class initialization code for the System class
00021       // it should create the in, out, and err stream.
00022       int objref = ks.da.newObject(
00023         ClassInfo.getClassInfo("java.io.PrintStream"), 
00024         th);
00025       setReferenceStaticField("out", objref);
00026       setReferenceStaticField("err", objref);
00027 
00028       return exit();
00029     }
00030 
00031     if(name.equals("arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V")) {
00032       Reflection src = getObjectArgument(0);
00033       int src_position = getIntArgument(1);
00034       Reflection dst = getObjectArgument(2);
00035       int dst_position = getIntArgument(3);
00036       int length = getIntArgument(4);
00037 
00038       if(src.getArrayTypeSize() == 1)
00039     for(int i = 0; i < length; i++)
00040       dst.setIntArrayElement(dst_position++,
00041           src.getIntArrayElement(src_position++));
00042       else
00043     for(int i = 0; i < length; i++)
00044       dst.setLongArrayElement(dst_position++,
00045           src.getLongArrayElement(src_position++));
00046 
00047       return exit();
00048     }
00049 
00050     if(name.equals("exit(I)V")) {
00051       int length = ks.tl.length();
00052 
00053       for(int i = 0; i < length; i++) {
00054     ThreadInfo ti = ks.tl.get(i);
00055 
00056     while(th.countStackFrames() != 0)
00057       ti.popFrame();
00058       }
00059     }
00060 
00061     if(name.equals("currentTimeMillis()J")) {
00062       return exit(0L);
00063     }
00064 
00065     if(name.equals("getCallerClass()Ljava/lang/Class;")) {
00066       // throws a runtime exception for now
00067       throw new NativeMethodException("getCallerClass()Ljava/lang/Class;");
00068     }
00069 
00070     if(name.equals("identityHashCode(Ljava/lang/Object;)I")) {
00071       int objref = th.getLocalVariable(0);
00072       return exit(objref ^ 0xABCD);
00073     }
00074 
00075     if(name.equals("initProperties(Ljava/util/Properties;)Ljava/util/Properties;")) {
00076       // throws a runtime exception for now
00077       throw new NativeMethodException("initProperties(Ljava/util/Properties;)Ljava/util/Properties;");
00078     }
00079 
00080     if(name.equals("mapLibraryName(Ljava/lang/String;)Ljava/lang/String;")) {
00081       // throws a runtime exception for now
00082       throw new NativeMethodException("mapLibraryName(Ljava/lang/String;)Ljava/lang/String;");
00083     }
00084 
00085     if(name.equals("registerNatives()V"))
00086       return exit();
00087 
00088     if(name.equals("setErr0(Ljava/io/PrintStream;)V")) {
00089       // throws a runtime exception for now
00090       throw new NativeMethodException("setErr0(Ljava/io/PrintStream;)V");
00091     }
00092 
00093     if(name.equals("setIn0(Ljava/io/InputStream;)V")) {
00094       // throws a runtime exception for now
00095       throw new NativeMethodException("setIn0(Ljava/io/InputStream;)V");
00096     }
00097 
00098     if(name.equals("setOut0(Ljava/io/PrintStream;)V")) {
00099       // throws a runtime exception for now
00100       throw new NativeMethodException("setOut0(Ljava/io/PrintStream;)V");
00101     }
00102 
00103     return super.executeStaticMethod(mi);
00104   }  
00105   public boolean isStaticMethodDeterministic(MethodInfo mi) {
00106     String name = mi.getFullName();
00107 
00108     if(name.equals("getCallerClass()Ljava/lang/Class;")) {
00109       // throws a runtime exception for now
00110       throw new NativeMethodException("getCallerClass()Ljava/lang/Class;");
00111     }
00112 
00113     if(name.equals("initProperties(Ljava/util/Properties;)Ljava/util/Properties;")) {
00114       // throws a runtime exception for now
00115       throw new NativeMethodException("initProperties(Ljava/util/Properties;)Ljava/util/Properties;");
00116     }
00117 
00118     if(name.equals("mapLibraryName(Ljava/lang/String;)Ljava/lang/String;")) {
00119       // throws a runtime exception for now
00120       throw new NativeMethodException("mapLibraryName(Ljava/lang/String;)Ljava/lang/String;");
00121     }
00122 
00123     if(name.equals("registerNatives()V")) {
00124       return true;
00125     }
00126 
00127     if(name.equals("setErr0(Ljava/io/PrintStream;)V")) {
00128       // throws a runtime exception for now
00129       throw new NativeMethodException("setErr0(Ljava/io/PrintStream;)V");
00130     }
00131 
00132     if(name.equals("setIn0(Ljava/io/InputStream;)V")) {
00133       // throws a runtime exception for now
00134       throw new NativeMethodException("setIn0(Ljava/io/InputStream;)V");
00135     }
00136 
00137     if(name.equals("setOut0(Ljava/io/PrintStream;)V")) {
00138       // throws a runtime exception for now
00139       throw new NativeMethodException("setOut0(Ljava/io/PrintStream;)V");
00140     }
00141 
00142     return super.isStaticMethodDeterministic(mi);
00143   }  
00144   public boolean isStaticMethodExecutable(MethodInfo mi) {
00145     String name = mi.getFullName();
00146 
00147     if(name.equals("getCallerClass()Ljava/lang/Class;")) {
00148       // throws a runtime exception for now
00149       throw new NativeMethodException("getCallerClass()Ljava/lang/Class;");
00150     }
00151 
00152     if(name.equals("initProperties(Ljava/util/Properties;)Ljava/util/Properties;")) {
00153       // throws a runtime exception for now
00154       throw new NativeMethodException("initProperties(Ljava/util/Properties;)Ljava/util/Properties;");
00155     }
00156 
00157     if(name.equals("mapLibraryName(Ljava/lang/String;)Ljava/lang/String;")) {
00158       // throws a runtime exception for now
00159       throw new NativeMethodException("mapLibraryName(Ljava/lang/String;)Ljava/lang/String;");
00160     }
00161 
00162     if(name.equals("registerNatives()V")) {
00163       return true;
00164     }
00165 
00166     if(name.equals("setErr0(Ljava/io/PrintStream;)V")) {
00167       // throws a runtime exception for now
00168       throw new NativeMethodException("setErr0(Ljava/io/PrintStream;)V");
00169     }
00170 
00171     if(name.equals("setIn0(Ljava/io/InputStream;)V")) {
00172       // throws a runtime exception for now
00173       throw new NativeMethodException("setIn0(Ljava/io/InputStream;)V");
00174     }
00175 
00176     if(name.equals("setOut0(Ljava/io/PrintStream;)V")) {
00177       // throws a runtime exception for now
00178       throw new NativeMethodException("setOut0(Ljava/io/PrintStream;)V");
00179     }
00180 
00181     return super.isStaticMethodExecutable(mi);
00182   }  
00183 }

Generated at Thu Feb 7 06:48:19 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001