Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error: illegal access for final methods on ReferencePipeline (stream) in Java 11 #6072

Closed
dstuebe opened this issue Feb 16, 2020 · 4 comments

Comments

@dstuebe
Copy link

dstuebe commented Feb 16, 2020

There appears to be a unit test in JRuby 9.2 that passes with OpenJDK11, but when I try to use a java Stream from Jruby I get Illegal Access errors on the final methods?

I see similar errors in specs for a large application which I have been trying to upgrade from jdk10.2 & Jruby 9.1.17.0 where we use java streams extensively.

I have tried most of the example code in CallingJavaFromRuby and things appear to be working properly otherwise.

Environment Information

$ uname -a
Darwin me.fios-router.home 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan  9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64
$ java --version
openjdk 11.0.6 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

java installed from brew

$ jruby --version
jruby 9.2.9.0 (2.5.7) 2019-10-30 458ad3e OpenJDK 64-Bit Server VM 11.0.6+10 on 11.0.6+10 +jit [darwin-x86_64]

Jruby installed from rbenv (1.1.2)

I have no flags or ruby options set. Nothing installed except bundler (not used here)

Expected Behavior

I expect the code shown in the JRuby unit tests to work.

Actual Behavior

$ irb
irb(main):001:0> require 'java'
=> false
irb(main):002:0> (1..200).to_a.each.to_java.stream.limit(10)
Traceback (most recent call last):
        6: from /usr/local/var/rbenv/versions/jruby-9.2.9.0/bin/irb:13:in `<main>'
        5: from org/jruby/RubyKernel.java:1193:in `catch'
        4: from org/jruby/RubyKernel.java:1193:in `catch'
        3: from org/jruby/RubyKernel.java:1446:in `loop'
        2: from org/jruby/RubyKernel.java:1052:in `eval'
        1: from (irb):2:in `evaluate'
TypeError (illegal access on 'limit': class org.jruby.javasupport.JavaMethod (in module org.jruby.dist) cannot access a member of class java.util.stream.ReferencePipeline (in module java.base) with modifiers "public final")

When I run the same code from the unit test (condensed to one line) I get a TypeError due to Illegal Access for all the final methods in the ReferencePipeline.

@headius
Copy link
Member

headius commented Feb 16, 2020

This should be fixed for 9.2.10. Can you try a nightly snapshot build from https://oss.sonatype.org/content/repositories/snapshots/org/jruby/jruby-dist/9.2.10.0-SNAPSHOT/ and report back?

@dstuebe
Copy link
Author

dstuebe commented Feb 16, 2020

Will do - thanks for the quick reply!

@headius headius added this to the JRuby 9.2.10.0 milestone Feb 16, 2020
@dstuebe
Copy link
Author

dstuebe commented Feb 16, 2020

Issue is resolved in the snapshot. Thank you!

I see the 9.2.10 milestone is 82% complete. Is it likely this was a regression that might allow me to get my product to production with an earlier release of 9.2.X or should I wait for 9.2.10?

I am also curious about the root cause of the issue, though that might be a bigger topic than you want to take on.

@headius
Copy link
Member

headius commented Feb 16, 2020

You might be able to get 9.2.8 working. This was a regression in 9.2.9. Basically we fixed one problem (dispatching to non-public methods triggering illegal access errors) and introduced another (dispatching to non-public classes triggering illegal access errors). In your case, we would attempt to bind calls to the "stream" object using the private JDK implementation class (e.g. ReferencePipeline) rather than the public Stream-related interfaces.

9.2.10 should be released in the next couple days!

@headius headius closed this as completed Feb 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants