Skip to content

[ji] support re-reifying class hierarchy#8147

Closed
kares wants to merge 6 commits intojruby:masterfrom
kares:fix-java_sub_class_re-reify2
Closed

[ji] support re-reifying class hierarchy#8147
kares wants to merge 6 commits intojruby:masterfrom
kares:fix-java_sub_class_re-reify2

Conversation

@kares
Copy link
Member

@kares kares commented Mar 7, 2024

this is an alternative to #8140

the difference is no class-loader magic on re-created reified classes but it changes the Java class naming:

module Bar
  class Foo < java.lang.Object
  end
end

when reified this class would be named:

  • current rubyobj.Bar.Foo
  • after the change in this MR: rubyobj.23e5fef5.Bar.Foo

to support the case of potential dropping and re-creating a named Ruby class


⚠️ the fix would need to revert #1229 which I do not think has a good test assuming 2 classes with the same name would share the same Java class

@kares kares linked an issue Mar 7, 2024 that may be closed by this pull request
final CharSequence name = StringSupport.replaceAll(getName(), "::", ".");
// we need to include a Class identifier in the Java class name, since a Ruby class might be dropped
// (using remove_const) and re-created in which case using the same name would cause a conflict...
return basePackagePrefix + identityHash + '.' + name; // TheFoo::Bar -> rubyobj.320efdf5.TheFoo.Bar
Copy link
Member Author

@kares kares Mar 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and while this works "better" (except for 'breaking' the rubyobj. naming convention) it might still be better to version the name. given patching of a reified class should re-generate the Java class which means there needs to be more classloader-fu or we simply add a v2 suffix and keep the existing loader (previous class is no longer used so should GC away, eventually)

but starting with a simple name that is backwards compatible
@kares kares closed this Apr 2, 2024
@enebo enebo added this to the Invalid or Duplicate milestone Apr 29, 2024
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.

can not re-reify sub-class of a Java sub-class

2 participants