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

[ji] should allow calling protected Java method with send #5310

Open
kares opened this Issue Sep 12, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@kares
Member

kares commented Sep 12, 2018

... works on Java 8 but not on 10(+)

jruby 9.2.1.0-SNAPSHOT (2.5.0) 2018-09-11 055a178 Java HotSpot(TM) 64-Bit Server VM 10.0.1+10 on 10.0.1+10 +jit [linux-x86_64]
irb(main):001:0> Java::JavaUtilLogging::StreamHandler.new.setOutputStream
Traceback (most recent call last):
        6: from /home/kares/workspace/oss/jruby/bin/jirb:13:in `<main>'
        5: from org/jruby/RubyKernel.java:1178:in `catch'
        4: from org/jruby/RubyKernel.java:1178:in `catch'
        3: from org/jruby/RubyKernel.java:1412:in `loop'
        2: from org/jruby/RubyKernel.java:1040:in `eval'
        1: from (irb):1:in `evaluate'
NoMethodError (undefined method `setOutputStream' for #<Java::JavaUtilLogging::StreamHandler:0x18a645fd>)
irb(main):002:0> Java::JavaUtilLogging::StreamHandler.new.send :setOutputStream, nil
Traceback (most recent call last):
        6: from /home/kares/workspace/oss/jruby/bin/jirb:13:in `<main>'
        5: from org/jruby/RubyKernel.java:1178:in `catch'
        4: from org/jruby/RubyKernel.java:1178:in `catch'
        3: from org/jruby/RubyKernel.java:1412:in `loop'
        2: from org/jruby/RubyKernel.java:1040:in `eval'
        1: from (irb):2:in `evaluate'
NoMethodError (undefined method `setOutputStream' for #<Java::JavaUtilLogging::StreamHandler:0x4650a407>)

the first failure is fine (although if it would be marked as a protected instance method the failure would be different), setOutputStream is a protected Java method, the second would be more Ruby if it worked ... this all works on Java 8 - would argue the direct call working is not something JRuby encouraged or specified, nevertheless the second from should work everywhere - seems like we can not set it accessible (due JDK modularization?).

extracted from: #4851 (comment)

related - similar accessibility issue on Java 10: #5284

@prashantvithani

This comment has been minimized.

Show comment
Hide comment
@prashantvithani

prashantvithani Sep 14, 2018

@kares Is there any workaround to solve this other than downgrading to Java-8?

prashantvithani commented Sep 14, 2018

@kares Is there any workaround to solve this other than downgrading to Java-8?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment