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

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

Closed
kares opened this issue Mar 5, 2024 · 0 comments · Fixed by #8140 or #8185
Closed

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

kares opened this issue Mar 5, 2024 · 0 comments · Fixed by #8140 or #8185

Comments

@kares
Copy link
Member

kares commented Mar 5, 2024

This is a bit of a stretch, usually not something that happens in production but still Ruby class removing is not that uncommon.

class SubList < java.util.ArrayList
  def initialize(arg1, arg2)
    puts "initialize #{self}"
    super(arg1 + arg2)
  end
end

class SubSubList < SubList
end

p SubSubList.new(1, 2)

Object.send(:remove_const, :SubSubList) 
# ... while parent SubList stays around (if it's removed as well it's not an issue)

class SubSubList < SubList
end

p SubSubList.new(1, 2)

Environment Information

Provide at least:

  • JRuby 9.3.0.0 - 9.4.6.0

Expected Behavior

  • Script works, reification is able to deal with the removed sub-class while parent was kept

Actual Behavior

  • Second SubSubList.new will fail:
initialize 
#<SubSubList: []>
ArgumentError: wrong number of arguments for constructor
  <main> at repro_java_sub_class.rb:26

due (-XreifylogErrors):

2024-03-05T15:10:02.637+01:00 [main] ERROR RubyClass : failed to reify class SubSubList due to: 
java.lang.LinkageError: loader org.jruby.util.OneShotClassLoader @1f172892 attempted duplicate class definition for rubyobj.SubSubList. (rubyobj.SubSubList is in unnamed module of loader org.jruby.util.OneShotClassLoader @1f172892, parent loader org.jruby.java.codegen.MultiClassLoader @6ba6557e)
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
	at org.jruby.dist/org.jruby.util.OneShotClassLoader.defineClass(OneShotClassLoader.java:20)
	at org.jruby.dist/org.jruby.RubyClass.reify(RubyClass.java:1447)

@kares kares linked a pull request Mar 5, 2024 that will close this issue
kares added a commit to kares/jruby that referenced this issue Mar 7, 2024
@kares kares linked a pull request Mar 7, 2024 that will close this issue
@kares kares linked a pull request Apr 2, 2024 that will close this issue
@headius headius added this to the JRuby 9.4.7.0 milestone Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants