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

JPFVM.java

00001 package gov.nasa.arc.ase.jpf.jvm;
00002 
00003 import de.fub.bytecode.*;
00004 import de.fub.bytecode.classfile.*;
00005 import gov.nasa.arc.ase.jpf.*;
00006 import gov.nasa.arc.ase.util.Debug;
00007 import java.util.*;
00008 
00009 public class JPFVM {
00010   private static JPFVM jpfvm = null;
00011   private Hashtable loadedClasses = new Hashtable();
00012   private int nLoadedClasses = 0;
00013 
00014   public JPFVM() {
00015     setJPFVM(this);
00016   }  
00017   // returns the number of classes ever loaded
00018   public int countLoadedClasses() {
00019     return nLoadedClasses;
00020   }  
00021   public ClassInfo getClass(String name) {
00022     if (isLoaded(name)) return getLoadedClass(name);
00023 
00024     JavaClass jc = loadClassData(name);
00025     ClassInfo ci = new ClassInfo(jc);
00026     nLoadedClasses++;
00027     loadedClasses.put(name, ci);
00028 
00029     return ci;
00030   }  
00031   public static JPFVM getJPFVM() {
00032     if(jpfvm == null) {
00033       Debug.println(Debug.ERROR, "No JPFVM singleton created");
00034       System.exit(1);
00035     }
00036 
00037     return jpfvm;
00038   }  
00039   // returns the class info for an already loaded class
00040   public ClassInfo getLoadedClass(String name) {
00041     return (ClassInfo)loadedClasses.get(name);
00042   }  
00043   // checks if a class has already been loaded
00044   public boolean isLoaded(String name) {
00045     return loadedClasses.containsKey(name);
00046   }  
00047   // loads the internal rapresentation of a class
00048   public JavaClass loadClassData(String name) {
00049     JavaClass jc = null;
00050     if ((jc = Repository.lookupClass(name)) == null) {
00051       Debug.println(Debug.ERROR, "Could not load class: " + name);
00052       System.exit(1);
00053     }
00054 
00055     return jc;
00056   }  
00057   private static void setJPFVM(JPFVM j) {
00058     jpfvm = j;
00059   }  
00060 }

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