Skip to content

Commit 865edaf

Browse files
committed
Add compile(String) method
A convenience method to compile from String, analog to eval(String).
1 parent 535760d commit 865edaf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/java/org/scijava/plugins/scripting/java/JavaEngine.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ public Object eval(Reader reader) throws ScriptException {
160160
return null;
161161
}
162162

163+
/**
164+
* Compiles and runs the specified {@code .java} class.
165+
*
166+
* @param script the source code for a Java class
167+
* @return the compiled Java class as {@link Class}.
168+
*/
169+
public Class<?> compile(String script) throws ScriptException {
170+
return compile(new StringReader(script));
171+
}
172+
163173
/**
164174
* Compiles and runs the specified {@code .java} class.
165175
*

0 commit comments

Comments
 (0)