#332 bsh.engine.BshScriptEngine impls Compilable, throws Error

General (151)
Brett Randall

bsh.engine.BshScriptEngine (JSR-223 javax.script support) implements Compilable, indicating to script hosts that the engine currently supports compilation. I believe that a runtime instanceof Compilable and cast is the main way of determining whether pre-compilation to a CompiledScript is supported by the current ScriptEngine.

In BeanShell 2.0b4 the ScriptEngine class bsh.engine.BshScriptEngine implements Compilable, but then goes on to:

public CompiledScript compile( Reader script ) throws
// todo
throw new Error("unimplemented");

See http://ikayzo.org/svn/beanshell/BeanShell/engine/src/bsh/engine/BshScriptEngine.java

This is unfortunate for clients with pluggable ScriptEngine-s, of which BeanShell may be one, as they can expect to be able to pre-compile scripts due to the presence of the interface, but will always receive the thrown error.

Recommend that the Compilable interface is removed until BeanShell and the BshScriptEngine support compilation.


  • Anonymous

    Status of http://jcp.org/en/jsr/detail?id=274 is "inactive"

    Support of JSR-223 became never an official released feature (as far as i can see at www.beanshell.org - it was part of 2.0 beta 5 which was never released).

    Nevertheless, because beanshell is now dormant there is a fork at http://code.google.com/p/beanshell2

    For jsr-223 support in the fork please comment on http://code.google.com/p/beanshell2/issues/detail?id=43

    Last edit: Anonymous 2015-08-11