Package org.h2.util
Class SourceCompiler
java.lang.Object
org.h2.util.SourceCompiler
This class allows to convert source code to a class. It uses one class loader
per class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClass<?> Get the class object for the given name.getCompiledScript(String packageAndClassName) Get the compiled script.Get the first public static method of the given class.static booleanisJavaxScriptSource(String source) Whether the passed source can be compiled usingScriptEngineManager.voidsetJavaSystemCompiler(boolean enabled) Enable or disable the usage of the Java system compiler.voidSet the source code for the specified class.
-
Constructor Details
-
SourceCompiler
public SourceCompiler()
-
-
Method Details
-
setSource
Set the source code for the specified class. This will reset all compiled classes.- Parameters:
className- the class namesource- the source code
-
setJavaSystemCompiler
public void setJavaSystemCompiler(boolean enabled) Enable or disable the usage of the Java system compiler.- Parameters:
enabled- true to enable
-
getClass
Get the class object for the given name.- Parameters:
packageAndClassName- the class name- Returns:
- the class
- Throws:
ClassNotFoundException- on failure
-
isJavaxScriptSource
Whether the passed source can be compiled usingScriptEngineManager.- Parameters:
source- the source to test.- Returns:
trueifgetCompiledScript(String)can be called.
-
getCompiledScript
Get the compiled script.- Parameters:
packageAndClassName- the package and class name- Returns:
- the compiled script
- Throws:
ScriptException- on failure
-
getMethod
Get the first public static method of the given class.- Parameters:
className- the class name- Returns:
- the method name
- Throws:
ClassNotFoundException- on failure
-