I’m using JRuby 1.7.13 and Java 7 to perform this task. Firstly, I use
“jrubyc” to compile a simple HelloWorld program into a Java class file
“hello.class”. Next, I download the jruby library
“jruby-complete-1.7.13.jar” and execute the following command:
java -cp .:jruby-complete-1.7.13.jar hello
In the case when I disable the invokedynamic when doing the jrubyc, this
above command executes smoothly and prints out “hello, world!” without
problems. But if invokedynamic is enabled, the following exception
occurs:
Exception in thread “main” java.lang.ClassCastException:
java.lang.Integer cannot be cast to java.lang.invoke.SwitchPoint
at
org.jruby.runtime.invokedynamic.InvocationLinker.invocationFallback(InvocationLinker.java:130)
at hello.file(hello.rb:10)
I’m wondering what this “SwitchPoint” is and why it is causing problems.
I’m scanning through the jruby properties and see the following two
parameters that might be relevant:
#invokedynamic.invocation.java=true
#invokedynamic.invocation.switchpoint=true
But I’ve tried various ways attempting to change the value of these two
parameters but couldn’t manage to do it. I’m also not sure if this is
the correct way of fixing the above exception.
If anyone encounters this, please let me know how you work around with
it. I’m sure there’re people who try to compile a Ruby file with the
latest JRuby version.