Skip to content

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

@dstuebe

Description

@dstuebe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions