Forum: JRuby java.lang.invoke.SwitchPoint problem when using invokedynamic

11f2061dae26489e2e0502ad1f9880aa?d=identicon&s=25 O. L. (xiaoni_l)
on 2014-08-19 21:08
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.
2c0c4cf3ccc8da22f7c3b9586ce1cd70?d=identicon&s=25 Christian MICHON (Guest)
on 2014-08-20 09:32
(Received via mailing list)
Isn't it because invokeddynamic is available for JDK8 and not JDK7?

If you've the possibility to upgrade to JDK 1.8.0_11 and report back,
you
might see a different behavior.
11f2061dae26489e2e0502ad1f9880aa?d=identicon&s=25 O. L. (xiaoni_l)
on 2014-08-21 21:48
Yes I upgrade to JDK 8 and now it runs.

But why is it so? invokedynamic is available in JDK 7 as well. I can
enable invokedynamic in JRuby compiler args and compile it to see
invokedynamic appearing in the class files.

Christian MICHON wrote in post #1155571:
> Isn't it because invokeddynamic is available for JDK8 and not JDK7?
>
> If you've the possibility to upgrade to JDK 1.8.0_11 and report back,
> you
> might see a different behavior.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.