Package org.apache.groovy.util
Class JavaShell
- java.lang.Object
-
- org.apache.groovy.util.JavaShell
-
@Incubating public class JavaShell extends Object
A shell for compiling or running pure Java code
-
-
Constructor Summary
Constructors Constructor Description JavaShell()Initializes a newly createdJavaShellobjectJavaShell(ClassLoader parentClassLoader)Initializes a newly createdJavaShellobject
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<?>compile(String className, Iterable<String> options, String src)Compile and return the main classClass<?>compile(String className, String src)Compile and return the main classMap<String,Class<?>>compileAll(String className, Iterable<String> options, String src)Compile and return all classesMap<String,Class<?>>compileAll(String className, String src)Compile and return all classesorg.apache.groovy.util.JavaShell.JavaShellClassLoadergetClassLoader()When and only whencompile(String, String)orcompileAll(String, String)is invoked, returned class loader will reference the compiled classes.voidrun(String className, Iterable<String> options, String src, String... args)Run main methodvoidrun(String className, String src, String... args)Run main method
-
-
-
Constructor Detail
-
JavaShell
public JavaShell()
Initializes a newly createdJavaShellobject
-
JavaShell
public JavaShell(ClassLoader parentClassLoader)
Initializes a newly createdJavaShellobject- Parameters:
parentClassLoader- the parent class loader for delegation
-
-
Method Detail
-
run
public void run(String className, Iterable<String> options, String src, String... args) throws Throwable
Run main method- Parameters:
className- the main class nameoptions- compiler optionssrc- the source codeargs- arguments for main method- Throws:
Throwable
-
run
public void run(String className, String src, String... args) throws Throwable
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, ClassNotFoundException
Compile and return the main class- Parameters:
className- the main class nameoptions- compiler optionssrc- the source code- Returns:
- the main class
- Throws:
IOExceptionClassNotFoundException
-
compile
public Class<?> compile(String className, String src) throws IOException, ClassNotFoundException
Compile and return the main class- Parameters:
className- the main class namesrc- the source code- Returns:
- the main class
- Throws:
IOExceptionClassNotFoundException
-
compileAll
public Map<String,Class<?>> compileAll(String className, Iterable<String> options, String src) throws IOException, ClassNotFoundException
Compile and return all classes- Parameters:
className- the main class nameoptions- compiler optionssrc- the source code- Returns:
- all classes
- Throws:
IOExceptionClassNotFoundException
-
compileAll
public Map<String,Class<?>> compileAll(String className, String src) throws IOException, ClassNotFoundException
Compile and return all classes- Parameters:
className- the main class namesrc- the source code- Returns:
- all classes
- Throws:
IOExceptionClassNotFoundException
-
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.
-
-