Reputation: 4851
I'm trying to get at the protected variables that are defined in the parent class I have inherited from.
Is this possible? I can't find any documentation saying it is. I've seen tickets that have been closed on earlier versions of JRuby.
Any help would be great.
Edit: To clarify
public class Something {
protected float somethingelse = 1.0f;
}
I want to get at somethingelse.
Upvotes: 0
Views: 766
Reputation: 26763
Since this fix, package access, private
and protected
can be exposed by using field_accessor
or field_reader
:
require 'java'
java_import 'Something'
class Something
field_accessor :somethingelse
end
class Stuff < Something
def anotherstuff
puts self.somethingelse
end
end
Stuff.new.anotherstuff
Upvotes: 2