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

Allow generating reified Ruby classes with actual name. #5813

Merged
merged 1 commit into from Aug 2, 2019

Conversation

@headius
Copy link
Member

commented Aug 2, 2019

This partially addresses #4643.

One of the main features of the old "reify.classes" feature was that all Object subclasses would reify as their actual names. This is needed for JVM tooling to separate different types of Ruby object since normally they'll all appear to be RubyObject or one of the specialized subclasses like RubyObject1.

However the other features of reify.classes are difficult to reconcile with reified variables from reify.variables, due to the complexity of mapping a Ruby class hierarchy into a Java class hierarchy at the same time we are reifying variables into fields.

This patch goes partway to restore the actual names by forcing reify.variables to use the actual Ruby class name without attempting to match the class hierarchy or generate the other Java methods from reify.classes.

Pass -Xreify.variables.name to get this new behavior (off by default).

$ jruby -e "module Foo; class Bar; end; end; puts JRuby.ref(Foo::Bar.new).getClass"
org.jruby.gen.RubyObject0

$ jruby -Xreify.variables.name -e "module Foo; class Bar; end; end; puts JRuby.ref(Foo::Bar.new).getClass"
org.jruby.gen.Foo.Bar
Allow generating reified Ruby classes with actual name.
This partially addresses #4643.

One of the main features of the old "reify.classes" feature was
that all Object subclasses would reify as their actual names. This
is needed for JVM tooling to separate different types of Ruby
object since normally they'll all appear to be RubyObject or one
of the specialized subclasses like RubyObject1.

However the other features of reify.classes are difficult to
reconcile with reified variables from reify.variables, due to the
complexity of mapping a Ruby class hierarchy into a Java class
hierarchy at the same time we are reifying variables into fields.

This patch goes partway to restore the actual names by forcing
reify.variables to use the actual Ruby class name without
attempting to match the class hierarchy or generate the other
Java methods from reify.classes.

Pass -Xreify.variables.name to get this new behavior (off by
default).

@headius headius added this to the JRuby 9.2.8.0 milestone Aug 2, 2019

@headius headius requested review from enebo and kares Aug 2, 2019

@enebo

enebo approved these changes Aug 2, 2019

@headius headius merged commit dc64294 into jruby:master Aug 2, 2019

1 of 2 checks passed

jruby.jruby Build #20190802.4 failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@headius headius deleted the headius:named_reified_classes branch Aug 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.