Nashorn-interrupt is java-agent (only premain currenty implemented so can't attach to running JVM) which do nashorn scripts interruptable. It modifies scripts what passed to NashornScriptEngine
adding checks of interrupt
status.
It protects from while (true) {...}
or for (i = 0; i >= 0; i++) {...}
problems. For more cases see RewriteVisitorWithAgentTest
.
It modifies AST of script adding invocation of interrupt checker function.
while (true) {...}
converted to while (true) { _interrupt_check(); ... }
before script evaluated.
- make agent with
mvn package
- add java agent option when run
java -javaagent:agent.jar