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 doesn't support DATA and __END__ #3579

Closed
chrisseaton opened this issue Jan 5, 2016 · 12 comments
Closed

JRuby doesn't support DATA and __END__ #3579

chrisseaton opened this issue Jan 5, 2016 · 12 comments

Comments

@chrisseaton
Copy link
Contributor

Looks like it was removed during development for 9.

@headius
Copy link
Member

headius commented Jan 5, 2016

Oops. I guess test coverage is a little weak here.

@chrisseaton
Copy link
Contributor Author

No you've just got the tests tagged!

@headius
Copy link
Member

headius commented Jan 5, 2016

Looks like @enebo removed it in fbaf038 and never got back to reimplementing it.

@chrisseaton
Copy link
Contributor Author

I added some stuff to your lexer to get it working in Truffle in 46bdc3c so that may be useful for you.

@headius
Copy link
Member

headius commented Jan 5, 2016

@chrisseaton Thanks, that probably works for most uses of DATA. It doesn't work for stdin though.

[] ~/projects/jruby $ cat blah.rb
puts DATA.read
__END__
hello

[] ~/projects/jruby $ ruby23 < blah.rb
hello

[] ~/projects/jruby $ jruby -X+T < blah.rb
WARNING: JRuby+Truffle is designed to be run with a JVM that has the Graal compiler. The compilation is disabled Without the Graal compiler and it runs much slower. See https://github.com/jruby/jruby/wiki/Truffle-FAQ#how-do-i-get-jrubytruffle
Truffle internal error: internal implementation error - RuntimeException java.io.IOException: Can't read file /Users/headius/projects/jruby/- org.jruby.truffle.runtime.RubyContext.execute(RubyContext.java:602)
internal implementation error - RuntimeException java.io.IOException: Can't read file /Users/headius/projects/jruby/- org.jruby.truffle.runtime.RubyContext.execute(RubyContext.java:602)
    at org.jruby.truffle.nodes.methods.ExceptionTranslatingNode.execute(ExceptionTranslatingNode.java:78)
    at org.jruby.truffle.nodes.instrument.RubyWrapperNode.execute(RubyWrapperNode.java:61)
    at org.jruby.truffle.nodes.RubyRootNode.execute(RubyRootNode.java:58)

@chrisseaton
Copy link
Contributor Author

Gah didn't think of that.

@headius
Copy link
Member

headius commented Jan 5, 2016

I should have a fix shortly that will enable both runtimes to do it mostly right.

@headius headius closed this as completed in c39e9b1 Jan 6, 2016
@headius
Copy link
Member

headius commented Jan 6, 2016

@chrisseaton @enebo I pushed my fix, which mostly involved getting access to the real FileChannel for the read file, putting it in a RubyFile, and grabbing that on the other side for DATA. This is now fully compatible with MRI's DATA since it's a real File with the actual descriptor/channel used to parse. Not that anyone is ever going to care.

@enebo The previous commit removes buffering from RubyInstanceConfig.getScriptSource. I could not think of a path in our code where the resulting stream wouldn't be buffered already or get buffered by RubyIO anyway.

@chrisseaton I also added LexerSource.getRemainingAsChannel for you to use in creating an appropriate DATA for Truffle.

@enebo
Copy link
Member

enebo commented Jan 6, 2016

@headius yeah script source is fine the others I might worry about

@headius
Copy link
Member

headius commented Jan 6, 2016 via email

@enebo
Copy link
Member

enebo commented Jan 6, 2016

@headius last time I checked they were not but that was also because all buffering had been removed so I added buffering back into the mix :)

@eregon
Copy link
Member

eregon commented Jan 6, 2016

We need a spec for this STDIN case 😄

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

No branches or pull requests

4 participants