public class ClassCompiler extends Object
since 1.5 Release 5
| Constructor and Description |
|---|
ClassCompiler(CompilerEnvirons compilerEnv)
Construct ClassCompiler that uses the specified compiler environment when generating classes.
|
| Modifier and Type | Method and Description |
|---|---|
Object[] |
compileToClassFiles(String source,
String sourceLocation,
int lineno,
String mainClassName)
Compile JavaScript source into one or more Java class files.
|
CompilerEnvirons |
getCompilerEnv()
Get the compiler environment the compiler uses.
|
String |
getMainMethodClass()
Get the name of the class for main method implementation.
|
Class<?> |
getTargetExtends()
Get the class that the generated target will extend.
|
Class<?>[] |
getTargetImplements()
Get the interfaces that the generated target will implement.
|
protected String |
makeAuxiliaryClassName(String mainClassName,
String auxMarker)
Build class name for a auxiliary class generated by compiler.
|
void |
setMainMethodClass(String className)
Set the class name to use for main method implementation.
|
void |
setTargetExtends(Class<?> extendsClass)
Set the class that the generated target will extend.
|
void |
setTargetImplements(Class<?>[] implementsClasses)
Set the interfaces that the generated target will implement.
|
public ClassCompiler(CompilerEnvirons compilerEnv)
public void setMainMethodClass(String className)
public static void main(Script sc, String[] args), it will be called
when main(String[] args) is called in the generated class. The class name should
be fully qulified name and include the package name like in org.foo.Bar.public String getMainMethodClass()
setMainMethodClass(String)public CompilerEnvirons getCompilerEnv()
public Class<?> getTargetExtends()
public void setTargetExtends(Class<?> extendsClass)
extendsClass - the class it extendspublic Class<?>[] getTargetImplements()
public void setTargetImplements(Class<?>[] implementsClasses)
implementsClasses - an array of Class objects, one for each interface the target will
extendprotected String makeAuxiliaryClassName(String mainClassName, String auxMarker)
public Object[] compileToClassFiles(String source, String sourceLocation, int lineno, String mainClassName)
getTargetExtends() or getTargetImplements() are not null, then the first compiled class will extend the specified
super class and implement specified interfaces.Copyright © 2023 HtmlUnit. All rights reserved.