Package org.mozilla.javascript.optimizer
Class ClassCompiler
- java.lang.Object
- 
- org.mozilla.javascript.optimizer.ClassCompiler
 
- 
 public class ClassCompiler extends java.lang.ObjectGenerates class files from script sources.since 1.5 Release 5 
- 
- 
Constructor SummaryConstructors Constructor Description ClassCompiler(CompilerEnvirons compilerEnv)Construct ClassCompiler that uses the specified compiler environment when generating classes.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object[]compileToClassFiles(java.lang.String source, java.lang.String sourceLocation, int lineno, java.lang.String mainClassName)Compile JavaScript source into one or more Java class files.CompilerEnvironsgetCompilerEnv()Get the compiler environment the compiler uses.java.lang.StringgetMainMethodClass()Get the name of the class for main method implementation.java.lang.Class<?>getTargetExtends()Get the class that the generated target will extend.java.lang.Class<?>[]getTargetImplements()Get the interfaces that the generated target will implement.protected java.lang.StringmakeAuxiliaryClassName(java.lang.String mainClassName, java.lang.String auxMarker)Build class name for a auxiliary class generated by compiler.voidsetMainMethodClass(java.lang.String className)Set the class name to use for main method implementation.voidsetTargetExtends(java.lang.Class<?> extendsClass)Set the class that the generated target will extend.voidsetTargetImplements(java.lang.Class<?>[] implementsClasses)Set the interfaces that the generated target will implement.
 
- 
- 
- 
Constructor Detail- 
ClassCompilerpublic ClassCompiler(CompilerEnvirons compilerEnv) Construct ClassCompiler that uses the specified compiler environment when generating classes.
 
- 
 - 
Method Detail- 
setMainMethodClasspublic void setMainMethodClass(java.lang.String className) Set the class name to use for main method implementation. The class must have a method matchingpublic static void main(Script sc, String[] args), it will be called whenmain(String[] args)is called in the generated class. The class name should be fully qulified name and include the package name like inorg.foo.Bar.
 - 
getMainMethodClasspublic java.lang.String getMainMethodClass() Get the name of the class for main method implementation.- See Also:
- setMainMethodClass(String)
 
 - 
getCompilerEnvpublic CompilerEnvirons getCompilerEnv() Get the compiler environment the compiler uses.
 - 
getTargetExtendspublic java.lang.Class<?> getTargetExtends() Get the class that the generated target will extend.
 - 
setTargetExtendspublic void setTargetExtends(java.lang.Class<?> extendsClass) Set the class that the generated target will extend.- Parameters:
- extendsClass- the class it extends
 
 - 
getTargetImplementspublic java.lang.Class<?>[] getTargetImplements() Get the interfaces that the generated target will implement.
 - 
setTargetImplementspublic void setTargetImplements(java.lang.Class<?>[] implementsClasses) Set the interfaces that the generated target will implement.- Parameters:
- implementsClasses- an array of Class objects, one for each interface the target will extend
 
 - 
makeAuxiliaryClassNameprotected java.lang.String makeAuxiliaryClassName(java.lang.String mainClassName, java.lang.String auxMarker)Build class name for a auxiliary class generated by compiler. If the compiler needs to generate extra classes beyond the main class, it will call this function to build the auxiliary class name. The default implementation simply appends auxMarker to mainClassName but this can be overridden.
 - 
compileToClassFilespublic java.lang.Object[] compileToClassFiles(java.lang.String source, java.lang.String sourceLocation, int lineno, java.lang.String mainClassName)Compile JavaScript source into one or more Java class files. The first compiled class will have name mainClassName. If the results ofgetTargetExtends()orgetTargetImplements()are not null, then the first compiled class will extend the specified super class and implement specified interfaces.- Returns:
- array where elements with even indexes specifies class name and the following odd index gives class file body as byte[] array. The initial element of the array always holds mainClassName and array[1] holds its byte code.
 
 
- 
 
-