开发者

How to use the Rhino javascript engine in an applet

开发者 https://www.devze.com 2022-12-23 14:50 出处:网络
For my java program I\'m using Rhino to execute JS scripts. Now I\'m trying to convert it to an applet which works great, except that everytime it\'s calling evaluateString(...) the JVM throws an Acce

For my java program I'm using Rhino to execute JS scripts. Now I'm trying to convert it to an applet which works great, except that everytime it's calling evaluateString(...) the JVM throws an AccessControlException. After some (a lot) of research I found out that this is cau开发者_C百科sed by Rhino's custom classloader. My problem is that after hours of googling I still can't find a way to stop Rhino from trying to load it's own classloader.

I hope someone can help me...


It seems to work now. What I did is was set the optimization level to -1 like that:

Context context = Context.enter();
context.setOptimizationLevel(-1);

That causes the whole JS engine to run in interpreter mode and it therefore never tries to create a new classloader.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号