Saturn
Saturn

Reputation: 18169

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

From this page: 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 JFrames and such.

It may sound odd, but, is it possible, in any way, to not allow such feature (disable importing 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. I don't want to give the freedom of creating JFrames.

Upvotes: 2

Views: 124

Answers (1)

Charles Oliver Nutter
Charles Oliver Nutter

Reputation: 1426

One hack would be to put 'java' into loaded features (the $" array). Requires would then assume it's already loaded and not try to load it again. A user could certainly remove it from that array, and try again, though.

Upvotes: 1

Related Questions