柯鴻儀
柯鴻儀

Reputation: 623

How to not import system lib classes in java rhino lib script?

I use java Rhino lib as a script engine in my application, so that users can write their own script to control the application to do some job,

but I don't want them to use the java system lib classes in script ,ex:"java.lang.Sytem.exit()",

does anyone know how to do?? thank you

Upvotes: 0

Views: 301

Answers (1)

David P. Caldwell
David P. Caldwell

Reputation: 3821

Call Context.setClassShutter(ClassShutter) on your context with an appropriate ClassShutter implementation that implements the method visibleToScripts(String fullClassName) in whatever way you wish to filter out (or in) whatever classes you want to have be usable from the scripts.

Upvotes: 1

Related Questions