jml2b.structure.java
Class JmlLoader

java.lang.Object
  extended byjml2b.util.Profiler
      extended byjml2b.structure.java.JmlLoader

public class JmlLoader
extends Profiler

class used to load classes.

Author:
A. Requet

Field Summary
static java.lang.String[] defaultClasses
           
static int fileSearchMisses
          Number of times a file is searched and not found.
static java.util.Stack unlinkedFiles
          files that don't have linked statements
 
Constructor Summary
JmlLoader()
           
 
Method Summary
static boolean checkDirectory(IJml2bConfiguration config, java.lang.String dir_name)
          Checks that the given directory exists within the search path.
static boolean classExists(java.lang.String fqn, java.lang.String[] path)
          Return true iff the given class exists in the given search path.
static void clearAll()
          Remove any unlinked file from the unlinkedFiles stack.
static void linkStatements(IJml2bConfiguration config)
          Links statements for all the remaining files.
static AClass loadClass(IJml2bConfiguration config, Package p, java.lang.String name)
          Returns the class name from package p.
static AClass loadClass(IJml2bConfiguration config, java.lang.String fqn)
          Load the given class, creating the package as needed.
static void loadDefaultClasses(IJml2bConfiguration config)
          Loads the default classes (ensures that they are loaded)
static boolean loadSerializedImage(java.lang.String image_file)
          Loads classes from the given serialized image.
static JmlFileEntry searchCandidateFile(IJml2bConfiguration config, Package p, java.lang.String name)
          Search a candidate file for the class name located in the package relative path pkg_path.
 
Methods inherited from class jml2b.util.Profiler
runGC
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileSearchMisses

public static int fileSearchMisses
Number of times a file is searched and not found.


unlinkedFiles

public static java.util.Stack unlinkedFiles
files that don't have linked statements


defaultClasses

public static final java.lang.String[] defaultClasses
Constructor Detail

JmlLoader

public JmlLoader()
Method Detail

loadClass

public static AClass loadClass(IJml2bConfiguration config,
                               Package p,
                               java.lang.String name)
                        throws Jml2bException
Returns the class name from package p. Loads the class if it is necessary. The class is loaded as an "external" class. Returns null if the class could not be found. throws a ClassLoadException if a candidate file was found, but could not be parsed.

Throws:
Jml2bException

searchCandidateFile

public static JmlFileEntry searchCandidateFile(IJml2bConfiguration config,
                                               Package p,
                                               java.lang.String name)
Search a candidate file for the class name located in the package relative path pkg_path.


checkDirectory

public static boolean checkDirectory(IJml2bConfiguration config,
                                     java.lang.String dir_name)
Checks that the given directory exists within the search path. It is used to check that added packages exists.


linkStatements

public static void linkStatements(IJml2bConfiguration config)
                           throws Jml2bException
Links statements for all the remaining files. Note that linking statements for a file can trigger the loading of new files that will be added to the stack of unlinked files.

Throws:
Jml2bException

loadClass

public static AClass loadClass(IJml2bConfiguration config,
                               java.lang.String fqn)
                        throws Jml2bException
Load the given class, creating the package as needed. fqn has to be a fully qualified name.

Parameters:
config - the configuration that should be used for loading new classes.
fqn - the fully qualified name of the class.
Throws:
Jml2bException

loadDefaultClasses

public static void loadDefaultClasses(IJml2bConfiguration config)
Loads the default classes (ensures that they are loaded)

Parameters:
config - the configuration that should be used for loading classes.

classExists

public static boolean classExists(java.lang.String fqn,
                                  java.lang.String[] path)
Return true iff the given class exists in the given search path. The class is suposed to exist if a file with extension .java or a jml recognised extension is found in a subdirectory of the search path corresponding to the package name of the class.

Parameters:
fqn - the fully qualified name of the class
Returns:
true iff the class can be found in the search path.

loadSerializedImage

public static boolean loadSerializedImage(java.lang.String image_file)
Loads classes from the given serialized image.

Returns:
false in case of error. true otherwise.

clearAll

public static void clearAll()
Remove any unlinked file from the unlinkedFiles stack.