public class ClassFileLoader extends java.lang.Object implements ClassInfoLoader
Classes may be specified by their full package name (java.lang.String), or by the name of their class file (myclasses/Test.class). The class path may contain directories or Zip or Jar files. Any classes that are written back to disk ("committed") are placed in the output directory.
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
static boolean |
USE_SYSTEM_CLASSES |
| Constructor and Description |
|---|
ClassFileLoader()
Constructor.
|
ClassFileLoader(ClassSource classSource) |
| Modifier and Type | Method and Description |
|---|---|
void |
appendClassPath(java.lang.String morePath)
Adds to the classpath (CLASSPATH = CLASSPATH + morePath).
|
void |
done()
Signifies that we are done with this
ClassFileLoader |
java.lang.String |
getClassPath()
Returns the path used to search for class files.
|
ClassInfo |
loadClass(java.lang.String name)
Loads the class with the given name.
|
ClassInfo[] |
loadClassesFromZipFile(java.util.zip.ZipFile zipFile)
Loads all of the classes that are contained in a zip (or jar) file.
|
ClassInfo |
newClass(int modifiers,
int classIndex,
int superClassIndex,
int[] interfaceIndexes,
java.util.List constants)
Creates a new class or interface.
|
java.io.File |
outputDir()
Get the directory into which commited class files should be written.
|
java.io.OutputStream |
outputStreamFor(ClassInfo info)
Returns an OutputStream to which a class file should be
written.
|
protected java.io.OutputStream |
outputStreamFor(java.lang.String name)
Returns an
OutputStream to which somed named entity is
written. |
void |
prependClassPath(java.lang.String morePath)
Adds to the classpath (CLASSPATH = morePath + CLASSPATH).
|
void |
setClassPath(java.lang.String classpath)
Sets the classpath.
|
void |
setOutputDir(java.io.File dir)
Set the directory into which commited class files should be written.
|
void |
setVerbose(boolean verbose) |
void |
writeEntry(byte[] bytes,
java.lang.String name)
Writes a bunch of
bytes to an output entry with the given
name. |
public static boolean DEBUG
public static boolean USE_SYSTEM_CLASSES
public ClassFileLoader(ClassSource classSource)
public ClassFileLoader()
public void setVerbose(boolean verbose)
public void setClassPath(java.lang.String classpath)
public void appendClassPath(java.lang.String morePath)
public void prependClassPath(java.lang.String morePath)
public java.lang.String getClassPath()
public ClassInfo[] loadClassesFromZipFile(java.util.zip.ZipFile zipFile) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionpublic ClassInfo newClass(int modifiers, int classIndex, int superClassIndex, int[] interfaceIndexes, java.util.List constants)
ClassInfoLoadernewClass in interface ClassInfoLoadermodifiers - The modifiers describing the newly-created classclassIndex - The index of the name of the newly-created class in its
constant poolsuperClassIndex - The index of the name of the newly-created class's superclass
in its constant poolinterfaceIndexes - The indexes of the names of the interfaces that the
newly-created class implementsconstants - The constant pool for the newly created class (a list of
Constants).public ClassInfo loadClass(java.lang.String name) throws java.lang.ClassNotFoundException
loadClass in interface ClassInfoLoadername - The name of the class to load, including the package name.java.lang.ClassNotFoundException - The class cannot be found in the class path.ClassInfopublic void setOutputDir(java.io.File dir)
dir - The directory.public java.io.File outputDir()
public void writeEntry(byte[] bytes,
java.lang.String name)
throws java.io.IOException
bytes to an output entry with the given
name.java.io.IOExceptionpublic java.io.OutputStream outputStreamFor(ClassInfo info) throws java.io.IOException
outputStreamFor in interface ClassInfoLoaderjava.io.IOExceptionprotected java.io.OutputStream outputStreamFor(java.lang.String name)
throws java.io.IOException
OutputStream to which somed named entity is
written. Any forward slashes in the name are replaced by
File.separatorChar.java.io.IOExceptionpublic void done()
throws java.io.IOException
ClassFileLoaderjava.io.IOException