I have a java shell application. I recently brought it back, the main
reason being to see what was going on with all this new java scripting
stuff like invokedynamic. Sort of got it working with some functionality
for JRuby 1.6.7.
Recent talk about performance and invokedynamic got me to thinking maybe
I’d get current and go from there.
I had googled up some stuff and had tried to add a jirb command into the
application. That currently is run off this
public static void main(final String[] args) {
final ConsoleInterface console = CommandLine.getConsole();
final Jirb jirb = new Jirb();
Thread.currentThread().setContextClassLoader(jirb.getClass().getClassLoader());
final RubyInstanceConfig config = new RubyInstanceConfig() {{
setInput(console.getIn());
setOutput(System.out);
setError(System.out);
setArgv(args);
}};
final Ruby runtime = Ruby.newInstance(config);
runtime.getGlobalVariables().defineReadonly(“$$”, new
ValueAccessor(runtime.newFixnum(System.identityHashCode(runtime))));
runtime.getLoadService().init(new ArrayList());
hookIntoRuntime(runtime,jirb);
if (runtime.getClass(“HP”) == null) {
runtime.evalScriptlet(
“class HP\n”
+“require ‘java’\n”
+“def hp(*cmd)\n”
+" _ps = org.cmdline.cmdIO.ArrayCmdOut.getInstance()\n"
+"
org.cmdline.psuedoGestalt.CommandShell.new.command(cmd.join("
"),true,_ps,_ps);\n"
+" _result = _ps.getOutput()\n"
+“end\n”
+“\n”
+“def hpQ(*cmd)\n”
+" _ps = org.cmdline.cmdIO.QueueCmdOut.getInstance()\n"
+"
org.cmdline.psuedoGestalt.CommandShell.new.command(cmd.join("
"),true,_ps,_ps);\n"
+" _result = _ps.getOutput()\n"
+“end\n”
+“end”
);
}
The application is called HalfPipe, since it sometimes seems like I’m
just using it to do new skateboarding tricks. But from that, came the HP
class which is supposed to be glue code to allow the ruby code command
line API type access back into the application shell.
So you could do something like
halfpipe = HP.new
halfpipe.hp(“exec jps”);
This worked fine 1.6.7 but at 1.7.2 I get
jirb
org.jruby.exceptions.RaiseException: (NameError) ArrayJavaProxy is
already defined
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1027)
at
RUBY.require(/Library/Frameworks/JRuby.framework/Versions/Current/lib/ruby/shared/rubygems/custom_require.rb:36)
at RUBY.HP(:2)
at RUBY.(root)(:1)
Would anyone have any thoughts what might be different and how I should
now work this?
Michael H.
trz nio.2 for OS X http://www195.pair.com/mik3hall/index.html#trz
HalfPipe Java 6/7 shell app
http://www195.pair.com/mik3hall/index.html#halfpipe
AppConverter convert Apple jvm to openjdk apps
http://www195.pair.com/mik3hall/index.html#appconverter