-
-
Notifications
You must be signed in to change notification settings - Fork 921
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 reified classes to store instance variables in raw fields (fixed) #7150
Conversation
This is principally for making Java integration produce more idomatic Ruby. This allows users to configure a class to store specific ivars in a field of a reified class.
core/src/main/java/org/jruby/runtime/ivars/RawFieldVariableAccessor.java
Outdated
Show resolved
Hide resolved
I have confirmed this will be green once merged with my Logger test fixes: https://github.com/jruby/jruby/actions/runs/2022952391 However I can't figure out why this example does not work... where is the field?
This seems to mimic the (working) specs so I must be doing something wrong here. Once I understand what I'm doing wrong, this is ready to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes are approved, but I need an explanation for why my naive example is not working.
I always run into this too: any usage of the methods that are shared between irb(main):001:0> class Foo < java.lang.Object; java_field "java.lang.String stringField"; end; f = Foo.new; puts f.class.java_class.declared_fields.to_a
private final org.jruby.java.proxies.ConcreteJavaProxy rubyobj.Foo.this$rubyObject
private static final org.jruby.javasupport.proxy.JavaProxyClass rubyobj.Foo.this$rubyProxyClass
private static final org.jruby.javasupport.Java$JCtorCache rubyobj.Foo.this$rubyCtorCache
private static final org.jruby.Ruby rubyobj.Foo.ruby
private static final org.jruby.RubyClass rubyobj.Foo.rubyClass
=> nil
irb(main):002:0> require 'jruby/core_ext'
=> true
irb(main):003:0> class Foo2 < java.lang.Object; java_field "java.lang.String stringField"; end; f = Foo2.new; puts f.class.java_class.declared_fields.to_a
private final org.jruby.java.proxies.ConcreteJavaProxy rubyobj.Foo2.this$rubyObject
private static final org.jruby.javasupport.proxy.JavaProxyClass rubyobj.Foo2.this$rubyProxyClass
private static final org.jruby.javasupport.Java$JCtorCache rubyobj.Foo2.this$rubyCtorCache
private static final org.jruby.Ruby rubyobj.Foo2.ruby
private static final org.jruby.RubyClass rubyobj.Foo2.rubyClass
public java.lang.String rubyobj.Foo2.stringField
=> nil
irb(main):004:0> |
@byteit101 Oh boy, that does fix it. Ok, we should do something better than that in the future, but that's not your bug. Let's merge this! |
See #7012 though now hopefully fixed