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

Jruby 9.2.7 with Java 11 "NoMethodError: undefined method `separator' for Java::JavaIo::File:Class" #5737

Closed
twkatadin opened this issue May 18, 2019 · 2 comments
Milestone

Comments

@twkatadin
Copy link

@twkatadin twkatadin commented May 18, 2019

Environment

jruby 9.2.7.0 (2.5.3) 2019-04-09 8a269e3 OpenJDK 64-Bit Server VM 11+28 on 11+28 +jit
Windows 10

Expected Behavior

From a command prompt the following command under Java 8 returns the system file separator character:
(jruby 9.2.7.0 (2.5.3) 2019-04-09 8a269e3 OpenJDK 64-Bit Server VM 25.212-b04 on 1.8.0_212-b04 +jit [mswin32-x86_64])

jruby -e "separator = java.io.File.separator; puts separator.to_s"
\

Actual Behavior

From a command prompt under Java 11:
jruby -e "separator = java.io.File.separator; puts separator.to_s"
2019-05-17T14:41:22.761-10:00 [main] WARN FilenoUtil : Native subprocess control requires open access to sun.nio.ch
Pass '--add-opens java.base/sun.nio.ch=org.jruby.dist' or '=org.jruby.core' to enable.
java.lang.IllegalCallerException: sun.nio.ch is not open to module org.jruby.dist
at java.base/java.lang.Module.addOpens(Module.java:763)
at org.jruby.dist/com.headius.backport9.modules.impl.Module9.addOpens(Module9.java:28)
at org.jruby.dist/com.headius.backport9.modules.Modules.addOpens(Modules.java:22)
at org.jruby.dist/org.jruby.util.io.FilenoUtil$ReflectiveAccess.(FilenoUtil.java:140)
at org.jruby.dist/org.jruby.util.io.FilenoUtil.getFilenoUsingReflection(FilenoUtil.java:111)
at org.jruby.dist/org.jruby.util.io.FilenoUtil.filenoFrom(FilenoUtil.java:107)
at org.jruby.dist/org.jruby.util.io.ChannelFD.initFileno(ChannelFD.java:42)
at org.jruby.dist/org.jruby.util.io.ChannelFD.(ChannelFD.java:32)
at org.jruby.dist/org.jruby.util.io.OpenFile.setChannel(OpenFile.java:196)
at org.jruby.dist/org.jruby.RubyIO.prepIO(RubyIO.java:261)
at org.jruby.dist/org.jruby.RubyIO.prepStdio(RubyIO.java:190)
at org.jruby.dist/org.jruby.RubyGlobal.initSTDIO(RubyGlobal.java:297)
at org.jruby.dist/org.jruby.RubyGlobal.createGlobals(RubyGlobal.java:211)
at org.jruby.dist/org.jruby.Ruby.init(Ruby.java:1260)
at org.jruby.dist/org.jruby.Ruby.newInstance(Ruby.java:370)
at org.jruby.dist/org.jruby.Main.internalRun(Main.java:273)
at org.jruby.dist/org.jruby.Main.run(Main.java:234)
at org.jruby.dist/org.jruby.Main.main(Main.java:206)
NoMethodError: undefined method `separator' for Java::JavaIo::File:Class
method_missing at org/jruby/RubyBasicObject.java:1708

at -e:1

@kares
Copy link
Member

@kares kares commented May 19, 2019

you should access it using constant syntax, since its a constant: java.io.File::separator

Loading

@headius
Copy link
Member

@headius headius commented May 20, 2019

@kares That was my first thought as well...but that syntax, with a lower-case s, is equivalent to calling the separator method anyway. The problem here is that this is a static final value on java.io.File that does not have a leading cap.

Because the field does not have a leading capital letter, it falls into the logic for accessors, which in 9.2.7.0 used too-restrictive guards for accessibility. That was fixed by #5731.

@twkatadin This behavior should work again in 9.2.8.0. For now you should be able to access these constants using the following code:

$ jruby -e 'p java::io::File.java_class.field(:separator).value(nil)'
"/"

@kares @enebo I guess we should spend some time making sure JI specs run under Java 9+ so we can avoid regressing JI behavior like this.

I will close this as a dup of #5730.

Loading

@headius headius closed this May 20, 2019
@headius headius added this to the JRuby 9.2.8.0 milestone May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants