Class ScriptEvaluator
- java.lang.Object
-
- org.codehaus.commons.compiler.Cookable
-
- org.codehaus.commons.compiler.MultiCookable
-
- org.codehaus.commons.compiler.jdk.ScriptEvaluator
-
- All Implemented Interfaces:
ICookable,IMultiCookable,IScriptEvaluator
public class ScriptEvaluator extends MultiCookable implements IScriptEvaluator
To set up aScriptEvaluatorobject, proceed as described forIScriptEvaluator. Alternatively, a number of "convenience constructors" exist that execute the described steps instantly.Alternatively, a number of "convenience constructors" exist that execute the steps described above instantly. Their use is discouraged.
Notice that this implementation of
IClassBodyEvaluatoris prone to "Java injection", i.e. an application could get more than one class body compiled by passing a bogus input document.Also notice that the parsing of leading IMPORT declarations is heuristic and has certain limitations; see
ClassBodyEvaluator.parseImportDeclarations(Reader).
-
-
Field Summary
-
Fields inherited from interface org.codehaus.commons.compiler.IScriptEvaluator
DEFAULT_METHOD_NAME, DEFAULT_RETURN_TYPE
-
-
Constructor Summary
Constructors Constructor Description ScriptEvaluator()ScriptEvaluator(java.lang.String script)Equivalent toScriptEvaluator(java.lang.String fileName, java.io.InputStream is, java.lang.Class<?> returnType, java.lang.String[] parameterNames, java.lang.Class<?>[] parameterTypes, java.lang.Class<?>[] thrownExceptions, java.lang.ClassLoader parentClassLoader)Equivalent toScriptEvaluator(java.lang.String fileName, java.io.Reader reader, java.lang.Class<?> returnType, java.lang.String[] parameterNames, java.lang.Class<?>[] parameterTypes, java.lang.Class<?>[] thrownExceptions, java.lang.ClassLoader parentClassLoader)Equivalent toScriptEvaluator(java.lang.String script, java.lang.Class<?> returnType)Equivalent toScriptEvaluator(java.lang.String script, java.lang.Class<?> returnType, java.lang.String[] parameterNames, java.lang.Class<?>[] parameterTypes)Equivalent toScriptEvaluator(java.lang.String script, java.lang.Class<?> returnType, java.lang.String[] parameterNames, java.lang.Class<?>[] parameterTypes, java.lang.Class<?>[] thrownExceptions)Equivalent to
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcook(java.lang.String[] fileNames, java.io.Reader[] readers)Same asCookable.cook(String, Reader), but cooks a set of documents into one class.protected voidcook(java.lang.String[] fileNames, java.io.Reader[] readers, java.lang.String[] imports)voidcook(java.lang.String fileName, java.io.Reader reader)Reads, scans, parses and compiles Java tokens from the givenReader.<T> TcreateFastEvaluator(java.io.Reader r, java.lang.Class<T> interfaceToImplement, java.lang.String[] parameterNames)If the parameter and return types of the expression are known at compile time, then a "fast" script evaluator can be instantiated through this method.<T> TcreateFastEvaluator(java.lang.String script, java.lang.Class<T> interfaceToImplement, java.lang.String[] parameterNames)java.lang.Objectevaluate()Shorthand forevaluate(new Object[0]).java.lang.Objectevaluate(int idx, java.lang.Object[] arguments)Same asIScriptEvaluator.evaluate(Object[]), but for multiple scripts.java.lang.Objectevaluate(java.lang.Object[] arguments)Calls the script with concrete parameter values.java.util.Map<java.lang.String,byte[]>getBytecodes()java.lang.Class<?>getClazz()java.lang.String[]getDefaultImports()java.lang.Class<?>getDefaultReturnType()java.lang.reflect.MethodgetMethod()java.lang.reflect.MethodgetMethod(int idx)Same asIScriptEvaluator.getMethod(), but for multiple scripts.protected java.lang.reflect.Method[]getMethods()java.lang.reflect.Method[]getResult()protected java.lang.Class<?>getReturnType(int i)voidsetClassName(java.lang.String className)voidsetCompileErrorHandler(ErrorHandler compileErrorHandler)Installs anErrorHandlerwhich is invoked during compilation on each error.voidsetDebuggingInformation(boolean debugSource, boolean debugLines, boolean debugVars)Determines what kind of debugging information is included in the generates classes.voidsetDefaultImports(java.lang.String... defaultImports)voidsetDefaultReturnType(java.lang.Class<?> defaultReturnType)When thisIScriptEvaluatoris coooked, then the defaultReturnType applies to all scripts for which no explicit return type was configured.voidsetExtendedClass(java.lang.Class<?> extendedClass)voidsetImplementedInterfaces(java.lang.Class<?>[] implementedInterfaces)voidsetMethodName(java.lang.String methodName)Defines the name of the generated method.voidsetMethodNames(java.lang.String[] methodNames)Same asIScriptEvaluator.setMethodName(String), but for multiple scripts.voidsetOverrideMethod(boolean overrideMethod)Defines whether the generated method overrides a methods declared in a supertype.voidsetOverrideMethod(boolean[] overrideMethod)Same asIScriptEvaluator.setOverrideMethod(boolean), but for multiple scripts.voidsetParameters(java.lang.String[][] parameterNames, java.lang.Class<?>[][] parameterTypes)Same asIScriptEvaluator.setParameters(String[], Class[]), but for multiple scripts.voidsetParameters(java.lang.String[] names, java.lang.Class<?>[] types)Defines the names and types of the parameters of the generated method.voidsetParentClassLoader(java.lang.ClassLoader parentClassLoader)The "parent class loader" is used to load referenced classes.voidsetReturnType(java.lang.Class<?> returnType)Defines the return type of the generated method.voidsetReturnTypes(java.lang.Class<?>[] returnTypes)Configures the return types of the generated methods.voidsetScriptCount(int count)voidsetSourceVersion(int version)Specifies the version of source code accepted, in analogy with JAVAC's-sourcecommand line option.voidsetStaticMethod(boolean staticMethod)Defines whether the generated method should be STATIC or not.voidsetStaticMethod(boolean[] staticMethod)Same asIScriptEvaluator.setStaticMethod(boolean), but for multiple scripts.voidsetTargetVersion(int version)Generates class files that target a specified release of the virtual machine, in analogy with JAVAC's-targetcommand line option.voidsetThrownExceptions(java.lang.Class<?>[] thrownExceptions)Defines the exceptions that the generated method may throw.voidsetThrownExceptions(java.lang.Class<?>[][] thrownExceptions)Same asIScriptEvaluator.setThrownExceptions(Class[]), but for multiple scripts.voidsetWarningHandler(WarningHandler warningHandler)By default, warnings are discarded, but an application my install a customWarningHandler.-
Methods inherited from class org.codehaus.commons.compiler.MultiCookable
cook, cook, cook, cook, cook, cook, cook, cookFiles, cookFiles, cookFiles, cookFiles
-
Methods inherited from class org.codehaus.commons.compiler.Cookable
cook, cook, cook, cook, cook, cook, cook, cookFile, cookFile, cookFile, cookFile
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.codehaus.commons.compiler.ICookable
cook, cook, cook, cook, cook, cook, cook, cookFile, cookFile, cookFile, cookFile
-
Methods inherited from interface org.codehaus.commons.compiler.IMultiCookable
cook, cook, cook, cook, cookFiles, cookFiles, cookFiles, cookFiles
-
Methods inherited from interface org.codehaus.commons.compiler.IScriptEvaluator
cook, cook, cook
-
-
-
-
Constructor Detail
-
ScriptEvaluator
public ScriptEvaluator(java.lang.String script) throws CompileExceptionEquivalent toScriptEvaluator se = new ScriptEvaluator(); se.cook(script);- Throws:
CompileException- See Also:
ScriptEvaluator(),Cookable.cook(String)
-
ScriptEvaluator
public ScriptEvaluator(java.lang.String script, java.lang.Class<?> returnType) throws CompileExceptionEquivalent toScriptEvaluator se = new ScriptEvaluator(); se.setReturnType(returnType); se.cook(script);- Throws:
CompileException- See Also:
ScriptEvaluator(),setReturnType(Class),Cookable.cook(String)
-
ScriptEvaluator
public ScriptEvaluator(java.lang.String script, java.lang.Class<?> returnType, java.lang.String[] parameterNames, java.lang.Class<?>[] parameterTypes) throws CompileExceptionEquivalent toScriptEvaluator se = new ScriptEvaluator(); se.setReturnType(returnType); se.setParameters(parameterNames, parameterTypes); se.cook(script);
-
ScriptEvaluator
public ScriptEvaluator(java.lang.String script, java.lang.Class<?> returnType, java.lang.String[] parameterNames, java.lang.Class<?>[] parameterTypes, java.lang.Class<?>[] thrownExceptions) throws CompileExceptionEquivalent toScriptEvaluator se = new ScriptEvaluator(); se.setReturnType(returnType); se.setParameters(parameterNames, parameterTypes); se.setThrownExceptions(thrownExceptions); se.cook(script);
-
ScriptEvaluator
public ScriptEvaluator(@Nullable java.lang.String fileName, java.io.InputStream is, java.lang.Class<?> returnType, java.lang.String[] parameterNames, java.lang.Class<?>[] parameterTypes, java.lang.Class<?>[] thrownExceptions, @Nullable java.lang.ClassLoader parentClassLoader) throws CompileException, java.io.IOException
Equivalent toScriptEvaluator se = new ScriptEvaluator(); se.setReturnType(returnType); se.setParameters(parameterNames, parameterTypes); se.setThrownExceptions(thrownExceptions); se.setParentClassLoader(parentClassLoader); se.cook(fileName, is);- Parameters:
parentClassLoader-nullmeans use current thread's context class loader- Throws:
CompileExceptionjava.io.IOException- See Also:
ScriptEvaluator(),setReturnType(Class),setParameters(String[], Class[]),setThrownExceptions(Class[]),SimpleCompiler.setParentClassLoader(ClassLoader),Cookable.cook(String, InputStream)
-
ScriptEvaluator
public ScriptEvaluator(@Nullable java.lang.String fileName, java.io.Reader reader, java.lang.Class<?> returnType, java.lang.String[] parameterNames, java.lang.Class<?>[] parameterTypes, java.lang.Class<?>[] thrownExceptions, @Nullable java.lang.ClassLoader parentClassLoader) throws CompileException, java.io.IOException
Equivalent toScriptEvaluator se = new ScriptEvaluator(); se.setReturnType(returnType); se.setParameters(parameterNames, parameterTypes); se.setThrownExceptions(thrownExceptions); se.setParentClassLoader(parentClassLoader); se.cook(reader);- Parameters:
parentClassLoader-nullmeans use current thread's context class loader- Throws:
CompileExceptionjava.io.IOException- See Also:
ScriptEvaluator(),setReturnType(Class),setParameters(String[], Class[]),setThrownExceptions(Class[]),SimpleCompiler.setParentClassLoader(ClassLoader),Cookable.cook(String, Reader)
-
ScriptEvaluator
public ScriptEvaluator()
-
-
Method Detail
-
setParentClassLoader
public void setParentClassLoader(@Nullable java.lang.ClassLoader parentClassLoader)
Description copied from interface:IScriptEvaluatorThe "parent class loader" is used to load referenced classes. Useful values are:System.getSystemClassLoader()The running JVM's class path Thread.currentThread().getContextClassLoader()ornullThe class loader effective for the invoking thread ClassLoaders.BOOTCLASSPATH_CLASS_LOADERThe running JVM's boot class path The parent class loader defaults to the current thread's context class loader.
- Specified by:
setParentClassLoaderin interfaceIScriptEvaluator
-
setDebuggingInformation
public void setDebuggingInformation(boolean debugSource, boolean debugLines, boolean debugVars)Description copied from interface:IScriptEvaluatorDetermines what kind of debugging information is included in the generates classes. The default is typically "-g:none".- Specified by:
setDebuggingInformationin interfaceIScriptEvaluator
-
setSourceVersion
public void setSourceVersion(int version)
Description copied from interface:ICookableSpecifies the version of source code accepted, in analogy with JAVAC's-sourcecommand line option. May be ignored by an implementation (e.g. thejaninoimplementation always accepts the language features as described on the home page). Allowed values, and the default value, depend on the implementation.-1means to use a default version.- Specified by:
setSourceVersionin interfaceICookable
-
setTargetVersion
public void setTargetVersion(int version)
Description copied from interface:ICookableGenerates class files that target a specified release of the virtual machine, in analogy with JAVAC's-targetcommand line option. Allowed values depend on the implementation. The default value also depends on the implementation. The only invariant is that the generated class files are suitable for the currently executing JVM.-1means to use a default version.- Specified by:
setTargetVersionin interfaceICookable
-
setCompileErrorHandler
public void setCompileErrorHandler(@Nullable ErrorHandler compileErrorHandler)
Description copied from interface:IScriptEvaluatorInstalls anErrorHandlerwhich is invoked during compilation on each error. (By default, the compilation throws aCompileExceptionon the first error and terminates.)If the given
ErrorHandlerthrows aCompileException, then the compilation terminates and the exception is propagated.If the given
ErrorHandlerdoes not throw aCompileExceptionbut completes normally, then the compilation may or may not continue, depending on the error. Iff the compilation completes normally but errors were reported, then it will throw aCompileExceptionindicating the number of errors.In other words: The
ErrorHandlermay throw aCompileExceptionor not, but the compilation will definitely throw aCompileExceptionif one or more compile errors have occurred.- Specified by:
setCompileErrorHandlerin interfaceIScriptEvaluator- Parameters:
compileErrorHandler-nullto restore the default behavior (throwing aCompileException)
-
setWarningHandler
public void setWarningHandler(@Nullable WarningHandler warningHandler)
Description copied from interface:IScriptEvaluatorBy default, warnings are discarded, but an application my install a customWarningHandler.- Specified by:
setWarningHandlerin interfaceIScriptEvaluator- Parameters:
warningHandler-nullto indicate that no warnings be issued
-
setScriptCount
public void setScriptCount(int count)
- Throws:
java.lang.IllegalArgumentException- count is different from previous invocations of this method
-
setClassName
public void setClassName(java.lang.String className)
- Specified by:
setClassNamein interfaceIScriptEvaluator- See Also:
IClassBodyEvaluator.setClassName(String)
-
setImplementedInterfaces
public void setImplementedInterfaces(java.lang.Class<?>[] implementedInterfaces)
- Specified by:
setImplementedInterfacesin interfaceIScriptEvaluator- See Also:
IClassBodyEvaluator.setImplementedInterfaces(Class[])
-
setExtendedClass
public void setExtendedClass(@Nullable java.lang.Class<?> extendedClass)
- Specified by:
setExtendedClassin interfaceIScriptEvaluator- See Also:
IClassBodyEvaluator.setExtendedClass(Class)
-
setDefaultReturnType
public void setDefaultReturnType(java.lang.Class<?> defaultReturnType)
Description copied from interface:IScriptEvaluatorWhen thisIScriptEvaluatoris coooked, then the defaultReturnType applies to all scripts for which no explicit return type was configured.The initial default return type (if you want, the "default-default" return type) is
void.class.- Specified by:
setDefaultReturnTypein interfaceIScriptEvaluator- See Also:
IScriptEvaluator.setReturnType(Class),IScriptEvaluator.setReturnTypes(Class[])
-
getDefaultReturnType
public java.lang.Class<?> getDefaultReturnType()
- Specified by:
getDefaultReturnTypein interfaceIScriptEvaluator- Returns:
- The default return type that was previously configured with
IScriptEvaluator.setDefaultReturnType(Class), orIScriptEvaluator.DEFAULT_RETURN_TYPE
-
setDefaultImports
public void setDefaultImports(java.lang.String... defaultImports)
- Specified by:
setDefaultImportsin interfaceIScriptEvaluator- See Also:
IClassBodyEvaluator.setDefaultImports(String...)
-
getDefaultImports
public java.lang.String[] getDefaultImports()
- Specified by:
getDefaultImportsin interfaceIScriptEvaluator- See Also:
IClassBodyEvaluator.getDefaultImports()
-
setOverrideMethod
public void setOverrideMethod(boolean overrideMethod)
Description copied from interface:IScriptEvaluatorDefines whether the generated method overrides a methods declared in a supertype.- Specified by:
setOverrideMethodin interfaceIScriptEvaluator
-
setStaticMethod
public void setStaticMethod(boolean staticMethod)
Description copied from interface:IScriptEvaluatorDefines whether the generated method should be STATIC or not. Defaults totrue.- Specified by:
setStaticMethodin interfaceIScriptEvaluator
-
setReturnType
public void setReturnType(java.lang.Class<?> returnType)
Description copied from interface:IScriptEvaluatorDefines the return type of the generated method. Valuenullmeans "use the default return type".- Specified by:
setReturnTypein interfaceIScriptEvaluator- See Also:
IScriptEvaluator.setDefaultReturnType(Class)
-
setMethodName
public void setMethodName(@Nullable java.lang.String methodName)
Description copied from interface:IScriptEvaluatorDefines the name of the generated method. Initially, the method name is "eval*".- Specified by:
setMethodNamein interfaceIScriptEvaluator- Parameters:
methodName-nullmeans reset to default name- See Also:
IScriptEvaluator.DEFAULT_METHOD_NAME
-
setParameters
public void setParameters(java.lang.String[] names, java.lang.Class<?>[] types)Description copied from interface:IScriptEvaluatorDefines the names and types of the parameters of the generated method.names
.lengthand types.lengthmust be equal. This invariant may be checked immediately, or later when the script is cooked.The parameters can be of primitive type, e.g.
double.class.The default is to have zero parameters.
- Specified by:
setParametersin interfaceIScriptEvaluator
-
setThrownExceptions
public void setThrownExceptions(java.lang.Class<?>[] thrownExceptions)
Description copied from interface:IScriptEvaluatorDefines the exceptions that the generated method may throw.- Specified by:
setThrownExceptionsin interfaceIScriptEvaluator
-
evaluate
@Nullable public java.lang.Object evaluate() throws java.lang.reflect.InvocationTargetException
Description copied from interface:IScriptEvaluatorShorthand forevaluate(new Object[0]).- Specified by:
evaluatein interfaceIScriptEvaluator- Throws:
java.lang.reflect.InvocationTargetException
-
evaluate
@Nullable public java.lang.Object evaluate(@Nullable java.lang.Object[] arguments) throws java.lang.reflect.InvocationTargetException
Description copied from interface:IScriptEvaluatorCalls the script with concrete parameter values.Each argument must have the same type as specified through the
parameterTypesparameter ofIScriptEvaluator.setParameters(String[], Class[]).Arguments of primitive type must passed with their wrapper class objects.
The object returned has the class as specified through
IScriptEvaluator.setReturnType(Class).This method is thread-safe.
Notice: In version 3.1.8, the arguments parameter was changed from
Object[]toObject..., which turned out to be a really bad decision because it caused a very ugly invocation ambiguity withIScriptEvaluator.evaluate(int, Object[]). Thus, with version 3.1.10, the parameter was changed back toObject[].- Specified by:
evaluatein interfaceIScriptEvaluator- Parameters:
arguments- The actual parameter values- Throws:
java.lang.reflect.InvocationTargetException
-
getMethod
public java.lang.reflect.Method getMethod()
- Specified by:
getMethodin interfaceIScriptEvaluator- Returns:
- The generated and loaded
Method
-
setOverrideMethod
public void setOverrideMethod(boolean[] overrideMethod)
Description copied from interface:IScriptEvaluatorSame asIScriptEvaluator.setOverrideMethod(boolean), but for multiple scripts.- Specified by:
setOverrideMethodin interfaceIScriptEvaluator
-
setStaticMethod
public void setStaticMethod(boolean[] staticMethod)
Description copied from interface:IScriptEvaluatorSame asIScriptEvaluator.setStaticMethod(boolean), but for multiple scripts.- Specified by:
setStaticMethodin interfaceIScriptEvaluator
-
setReturnTypes
public void setReturnTypes(java.lang.Class<?>[] returnTypes)
Description copied from interface:IScriptEvaluatorConfigures the return types of the generated methods. If an element of the array isnull, then use the "default return type" for that script.- Specified by:
setReturnTypesin interfaceIScriptEvaluator- Parameters:
returnTypes- The methods' return types;nullelements mean "use the default return type"- See Also:
IScriptEvaluator.setDefaultReturnType(Class),IScriptEvaluator.getDefaultReturnType()
-
setMethodNames
public void setMethodNames(java.lang.String[] methodNames)
Description copied from interface:IScriptEvaluatorSame asIScriptEvaluator.setMethodName(String), but for multiple scripts.Define the names of the generated methods. By default the methods have distinct and implementation-specific names.
If two scripts have the same name, then they must have different parameter types (see
IScriptEvaluator.setParameters(String[][], Class[][])).- Specified by:
setMethodNamesin interfaceIScriptEvaluator
-
setParameters
public void setParameters(java.lang.String[][] parameterNames, java.lang.Class<?>[][] parameterTypes)Description copied from interface:IScriptEvaluatorSame asIScriptEvaluator.setParameters(String[], Class[]), but for multiple scripts.- Specified by:
setParametersin interfaceIScriptEvaluator
-
setThrownExceptions
public void setThrownExceptions(java.lang.Class<?>[][] thrownExceptions)
Description copied from interface:IScriptEvaluatorSame asIScriptEvaluator.setThrownExceptions(Class[]), but for multiple scripts.- Specified by:
setThrownExceptionsin interfaceIScriptEvaluator
-
cook
public void cook(@Nullable java.lang.String fileName, java.io.Reader reader) throws CompileException, java.io.IOException
Description copied from interface:ICookableReads, scans, parses and compiles Java tokens from the givenReader.- Specified by:
cookin interfaceICookable- Specified by:
cookin classCookable- Parameters:
fileName- Used when reporting errors and warnings- Throws:
CompileExceptionjava.io.IOException
-
cook
public void cook(java.lang.String[] fileNames, java.io.Reader[] readers) throws CompileException, java.io.IOExceptionDescription copied from interface:IMultiCookableSame asCookable.cook(String, Reader), but cooks a set of documents into one class. Notice that if any of the documents causes trouble, the entire compilation will fail. If you need to report which of the documents causes the exception, you may want to use thefileNamesparameter to distinguish between the individual token sources.- Specified by:
cookin interfaceIMultiCookable- Specified by:
cookin interfaceIScriptEvaluator- Specified by:
cookin classMultiCookable- Throws:
CompileExceptionjava.io.IOException
-
cook
protected final void cook(java.lang.String[] fileNames, java.io.Reader[] readers, java.lang.String[] imports) throws CompileException, java.io.IOException- Parameters:
readers- The scripts to cook- Throws:
CompileExceptionjava.io.IOException
-
getReturnType
protected final java.lang.Class<?> getReturnType(int i)
- Returns:
- The return type of the ith script
-
createFastEvaluator
public <T> T createFastEvaluator(java.lang.String script, java.lang.Class<T> interfaceToImplement, java.lang.String[] parameterNames) throws CompileException- Specified by:
createFastEvaluatorin interfaceIScriptEvaluator- Parameters:
script- Contains the sequence of script tokens- Throws:
CompileException- See Also:
createFastEvaluator(String, Class, String[])
-
createFastEvaluator
public <T> T createFastEvaluator(java.io.Reader r, java.lang.Class<T> interfaceToImplement, java.lang.String[] parameterNames) throws CompileException, java.io.IOExceptionDescription copied from interface:IScriptEvaluatorIf the parameter and return types of the expression are known at compile time, then a "fast" script evaluator can be instantiated through this method.Script evaluation is faster than through
IScriptEvaluator.evaluate(Object[]), because it is not done through reflection but through direct method invocation.Example:
public interface Foo { int bar(int a, int b); } ... IScriptEvaluator se =CompilerFactoryFactory.getDefaultCompilerFactory().newScriptEvaluator(); // Optionally configure the SE her: se.setClassName("Bar"); se.setDefaultImports(new String[] { "java.util.*" }); se.setExtendedClass(SomeOtherClass.class); se.setParentClassLoader(someClassLoader); Foo f = (Foo) se.createFastScriptEvaluator( "return a - b;", Foo.class, new String[] { "a", "b" } ); System.out.println("1 - 2 = " + f.bar(1, 2));All other configuration (implemented type, static method, return type, method name, parameter names and types, thrown exceptions) are predetermined by the
interfaceToImplement.Notice: The
sinterfaceToImplementmust either be declaredpublic, or with package scope in the same package as the generated class (seeIScriptEvaluator.setClassName(String)).- Specified by:
createFastEvaluatorin interfaceIScriptEvaluator- Parameters:
r- Produces the stream of script tokensinterfaceToImplement- Must declare exactly one methodparameterNames- The names of the parameters of that method- Returns:
- An object that implements the given interface
- Throws:
CompileExceptionjava.io.IOException
-
evaluate
@Nullable public java.lang.Object evaluate(int idx, @Nullable java.lang.Object[] arguments) throws java.lang.reflect.InvocationTargetException
Description copied from interface:IScriptEvaluatorSame asIScriptEvaluator.evaluate(Object[]), but for multiple scripts.- Specified by:
evaluatein interfaceIScriptEvaluator- Throws:
java.lang.reflect.InvocationTargetException
-
getResult
public java.lang.reflect.Method[] getResult()
- Specified by:
getResultin interfaceIScriptEvaluator- Returns:
- The generated and loaded methods that implement the cooked scripts
-
getMethod
public java.lang.reflect.Method getMethod(int idx)
Description copied from interface:IScriptEvaluatorSame asIScriptEvaluator.getMethod(), but for multiple scripts.- Specified by:
getMethodin interfaceIScriptEvaluator
-
getMethods
protected java.lang.reflect.Method[] getMethods()
- Throws:
java.lang.IllegalStateException- ThisScriptEvaluatorhas not yet beencook()ed
-
getClazz
public java.lang.Class<?> getClazz()
- Specified by:
getClazzin interfaceIScriptEvaluator- See Also:
IClassBodyEvaluator.getClazz()
-
getBytecodes
public java.util.Map<java.lang.String,byte[]> getBytecodes()
- Specified by:
getBytecodesin interfaceICookable- Returns:
- The generated Java bytecode; maps class name to bytes
-
-