Package org.apache.groovy.util
Class JavaShell
java.lang.Object
org.apache.groovy.util.JavaShell
A shell for compiling or running pure Java code
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes a newly createdJavaShell
objectJavaShell(ClassLoader parentClassLoader)
Initializes a newly createdJavaShell
object -
Method Summary
Modifier and TypeMethodDescriptionClass<?>
Compile and return the main classClass<?>
Compile and return the main classcompileAll(String className, Iterable<String> options, String src)
Compile and return all classescompileAll(String className, String src)
Compile and return all classesorg.apache.groovy.util.JavaShell.JavaShellClassLoader
When and only whencompile(String, String)
orcompileAll(String, String)
is invoked, returned class loader will reference the compiled classes.void
Run main methodvoid
Run main method
-
Constructor Details
-
JavaShell
public JavaShell()Initializes a newly createdJavaShell
object -
JavaShell
Initializes a newly createdJavaShell
object- Parameters:
parentClassLoader
- the parent class loader for delegation
-
-
Method Details
-
run
public void run(String className, Iterable<String> options, String src, String... args) throws ThrowableRun main method- Parameters:
className
- the main class nameoptions
- compiler optionssrc
- the source codeargs
- arguments for main method- Throws:
Throwable
-
run
Run main method- Parameters:
className
- the main class namesrc
- the source codeargs
- arguments for main method- Throws:
Throwable
-
compile
public Class<?> compile(String className, Iterable<String> options, String src) throws IOException, ClassNotFoundExceptionCompile and return the main class- Parameters:
className
- the main class nameoptions
- compiler optionssrc
- the source code- Returns:
- the main class
- Throws:
IOException
ClassNotFoundException
-
compile
Compile and return the main class- Parameters:
className
- the main class namesrc
- the source code- Returns:
- the main class
- Throws:
IOException
ClassNotFoundException
-
compileAll
public Map<String,Class<?>> compileAll(String className, Iterable<String> options, String src) throws IOException, ClassNotFoundExceptionCompile and return all classes- Parameters:
className
- the main class nameoptions
- compiler optionssrc
- the source code- Returns:
- all classes
- Throws:
IOException
ClassNotFoundException
-
compileAll
public Map<String,Class<?>> compileAll(String className, String src) throws IOException, ClassNotFoundExceptionCompile and return all classes- Parameters:
className
- the main class namesrc
- the source code- Returns:
- all classes
- Throws:
IOException
ClassNotFoundException
-
getClassLoader
public org.apache.groovy.util.JavaShell.JavaShellClassLoader getClassLoader()When and only whencompile(String, String)
orcompileAll(String, String)
is invoked, returned class loader will reference the compiled classes.
-