JRuby field_accessor final member
I have a java field that I want to subclass in jruby defined like so:
public abstract class FilterObjectStream<S, T> implements ObjectStream<T> {
protected final ObjectStream<S> samples;
I then want to subclass this class and access this member, I have tried to access the protected final member like this, using field_accessor:
class NameSampleDataStream
field_accessor :samples
end
class HtmlNameSampleDataStream < NameSampleDa开发者_运维百科taStream
def read
token = self.samples.read()
token
end
end
I am getting an error message:
SecurityError: Cannot change final field 'samples'
I guess the exception answers the question but is there anyway that I can access this variable or is the game up?
I cannot change the java source unfortunately.
Can you try just doing "field_reader"? It's possible to set a final field accessible, but we don't do that for you, and what you want here is just a reader, right?
精彩评论