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

RubyEnumerator implements java.util.Iterator #4054

Merged
merged 5 commits into from
Aug 24, 2016

Conversation

kares
Copy link
Member

@kares kares commented Aug 8, 2016

feels like a good fit and this makes enumerator usable with Java 8 (with some boilerplate) :
java.util.Spliterators.spliterator(enum.to_java, enum.size || -1, charactestistics)

... ideally some more integration would be handy but JRuby would need compiling under Java 8 for easy : [1, 2, 3, 4, 5].each.to_java.stream or Enumerator.new { ... }.to_java.spliterator implementations.
esp. since the Enumeration's size and the spliterator characteristic are depend on internals. so this would like get revisited after a potential compilation switch in another release.

Ruby enumerator (and thus Ruby array) usability with 8 streaming is confirmed with test-cases.

@kares
Copy link
Member Author

kares commented Aug 15, 2016

... ideally some more integration would be handy but JRuby would need compiling under Java 8 for easy : [1, 2, 3, 4, 5].each.to_java.stream or Enumerator.new { ... }.to_java.spliterator implementations.
esp. since the Enumeration's size and the spliterator characteristic are depend on internals. so this would like get revisited after a potential compilation switch in another release.

also possible by hooking up stream/spliterator on org.jruby.RubyEnumerator (in plain .rb for now)

// cc @headius @enebo let me know what do you think about getting this merged for 9.1.3

@headius
Copy link
Member

headius commented Aug 23, 2016

@kares 👍 from me. @enebo?

... this would be desirable/possible to do in RubyEnumerator.java
but we can not since we're not compliling under Java 8

it is still useful to be able to do `enum.to_java.stream` from Ruby
@kares
Copy link
Member Author

kares commented Aug 24, 2016

thanks for the review, have added the .rb part helpers (under Java 8) spliterator and stream since due compilation under Java 7 those can not be implemented in org.jruby.RubyEnumerator atm

@enebo
Copy link
Member

enebo commented Aug 24, 2016

@kares looks fine by me

@kares kares merged commit a0ea58c into jruby:master Aug 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants