Skip to content

Allow generating reified Ruby classes with actual name.#5813

Merged
headius merged 1 commit intojruby:masterfrom
headius:named_reified_classes
Aug 2, 2019
Merged

Allow generating reified Ruby classes with actual name.#5813
headius merged 1 commit intojruby:masterfrom
headius:named_reified_classes

Conversation

@headius
Copy link
Member

@headius headius 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

This partially addresses jruby#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 August 2, 2019 17:52
@headius headius merged commit dc64294 into jruby:master Aug 2, 2019
@headius headius deleted the named_reified_classes branch August 2, 2019 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants