rhino

How can you run Javascript using Rhino for Java in a sandbox?

醉酒当歌 提交于 2019-11-26 18:54:35
问题 Part of our java application needs to run javascript that is written by non-developers. These non-developers are using javascript for data formatting. (Simple logic and string concatenation mostly). My question is how can I setup the execution of these scripts to make sure scripting errors don't have a major negative impact on the rest of the application. Need to guard against infinite loops Guard against spawning new threads. Limit access to services and environment File system (Example: If

Has anyone used or written an Ant task to compile (Rhino) JavaScript to Java bytecode?

廉价感情. 提交于 2019-11-26 18:12:05
问题 I'd like to use the Rhino JavaScript compiler to compile some JavaScript to .class bytecode files for use in a project. It seems like this should already exist, since there are groovyc, netrexxc, and jythonc tasks for Groovy, NetREXX(!) and Jython, respectively. Has anyone used or written such an Ant task, or can anyone provide some tips on how to write one? Ideally it would have some way to resolve dependencies among JavaScript or Java classes. 回答1: Why not simply use java task? <java fork=