Check that scripting engine supports Invocable before casting

This commit is contained in:
Sampo Niskanen 2015-01-10 18:38:47 +02:00
parent 8c00dbf159
commit 45c41537ed

View File

@ -103,7 +103,9 @@ public class ScriptingExtension extends AbstractSimulationExtension {
throw new SimulationException("Invalid script: " + e.getMessage());
}
// TODO: Check for implementation first
if (!(engine instanceof Invocable)) {
throw new SimulationException("The scripting language '" + getLanguage() + "' does not implement the Invocable interface");
}
return new ScriptingSimulationListener((Invocable) engine);
}