简体   繁体   English

是否可以阻止Ruby脚本在JRuby中导入Java?

[英]Is it possible to stop Ruby scripts from importing Java in JRuby?

From this page: https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby 在此页面上: https : //github.com/jruby/jruby/wiki/CallingJavaFromJRuby

In a Ruby script, if you use require 'java' , the script will be able to create things like JFrame s and such. 在Ruby脚本中,如果使用require 'java' ,则该脚本将能够创建JFrame的东西。

It may sound odd, but, is it possible, in any way, to not allow such feature (disable importing Java )? 听起来很奇怪,但是是否有可能以某种方式不允许这种功能 (禁用Java导入)?


If you are curious as to why am I asking, it is because I'm developing some kind of game engine on Java, but it allows users to script with Ruby to control the game logic - only the game logic. 如果您对我为什么要问感到好奇,那是因为我正在用Java开发某种游戏引擎,但是它允许用户使用Ruby编写脚本来控制游戏逻辑- 游戏逻辑。 I don't want to give the freedom of creating JFrame s. 我不想给创建JFrame的自由。

一种方法是将“ java”放入已加载的功能($“数组)中,然后要求将其假定已被加载,而不是尝试再次加载。用户当然可以将其从该数组中删除,然后重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM