Package org.h2.util
Class SourceCompiler
- java.lang.Object
-
- org.h2.util.SourceCompiler
-
public class SourceCompiler extends java.lang.ObjectThis class allows to convert source code to a class. It uses one class loader per class.
-
-
Constructor Summary
Constructors Constructor Description SourceCompiler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Class<?>getClass(java.lang.String packageAndClassName)Get the class object for the given name.javax.script.CompiledScriptgetCompiledScript(java.lang.String packageAndClassName)Get the compiled script.java.lang.reflect.MethodgetMethod(java.lang.String className)Get the first public static method of the given class.static booleanisJavaxScriptSource(java.lang.String source)Whether the passed source can be compiled usingScriptEngineManager.voidsetJavaSystemCompiler(boolean enabled)Enable or disable the usage of the Java system compiler.voidsetSource(java.lang.String className, java.lang.String source)Set the source code for the specified class.
-
-
-
Method Detail
-
setSource
public void setSource(java.lang.String className, java.lang.String source)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
public java.lang.Class<?> getClass(java.lang.String packageAndClassName) throws java.lang.ClassNotFoundExceptionGet the class object for the given name.- Parameters:
packageAndClassName- the class name- Returns:
- the class
- Throws:
java.lang.ClassNotFoundException- on failure
-
isJavaxScriptSource
public static boolean isJavaxScriptSource(java.lang.String source)
Whether the passed source can be compiled usingScriptEngineManager.- Parameters:
source- the source to test.- Returns:
trueifgetCompiledScript(String)can be called.
-
getCompiledScript
public javax.script.CompiledScript getCompiledScript(java.lang.String packageAndClassName) throws javax.script.ScriptExceptionGet the compiled script.- Parameters:
packageAndClassName- the package and class name- Returns:
- the compiled script
- Throws:
javax.script.ScriptException- on failure
-
getMethod
public java.lang.reflect.Method getMethod(java.lang.String className) throws java.lang.ClassNotFoundExceptionGet the first public static method of the given class.- Parameters:
className- the class name- Returns:
- the method name
- Throws:
java.lang.ClassNotFoundException- on failure
-
-