You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Undefined Method java_kind_of? in JRuby-9.3.0.0 #6862
(NoMethodError) undefined method `java_kind_of?' for #<Java::ComRabbitmqClientImpl::LongStringHelper::ByteArrayLongString:0xa79c8be> Did you mean? java_send
Environment Information
JRuby: jruby 9.3.0.0 (2.6.8) 2021-09-17 85c20e780f OpenJDK 64-Bit Server VM 11.0.12+0 on 11.0.12+0 [darwin-x86_64]
Dev OS: Darwin ofc-03052-m 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64
# @deprecateddefjava_kind_of?(other)# TODO: this can go away now, but people may be using itreturntrueifself.kind_of?(other)returnfalseunlessself.respond_to?(:java_class) && other.respond_to?(:java_class) &&
other.kind_of?(Module) && !self.kind_of?(Module)returnother.java_class.assignable_from?(self.java_class)end
@ThomasKoppensteiner we talked about this on chat and realized for instance of sorts of checks kind_of? works but if you ask on Java type itself (e.g. java.util.ArrayList.kind_of?(java.lang.Class)) it does not. I think this is probably very uncommon but if you happen to ever notice this case we probably need to augment kind_of?.
I believe these should work with kind_of? or is_a as appropriate. The Ruby view of the Java object uses the same class hierarchy as e.g. com.rabbitmw.client.LongString and it should be seen as a supertype of the object's class.
Hello, I am using Logstash to process python script in my pipeline between SQL and ElasticSearch but if I use this filter in my logstash-sample.conf file filter { python { code => ' print("python works") ' } }
I receive these logs :
[2023-05-16T09:26:01,898][ERROR][logstash.filters.python ][main][9159e3828cc8f1ed140577832a7ee56f40772013e30def286e744cbc9c8f7eb1] Python exception occurred: undefined method java_kind_of?' for #Java::OrgPythonCore::PyObjectDerived:0x59f863d5
Did you mean? java_send
python works
python works
[2023-05-16T09:26:01,926][ERROR][logstash.filters.python ][main][9159e3828cc8f1ed140577832a7ee56f40772013e30def286e744cbc9c8f7eb1] Python exception occurred: undefined method java_kind_of?' for #<Java::OrgPythonCore::PyObjectDerived:0x1e55fe7e> Did you mean? java_send python works [2023-05-16T09:26:01,933][ERROR][logstash.filters.python ][main][9159e3828cc8f1ed140577832a7ee56f40772013e30def286e744cbc9c8f7eb1] Python exception occurred: undefined method java_kind_of?' for #Java::OrgPythonCore::PyObjectDerived:0x1e55fe7e`
I am not sure it causes problems but what could I do to prevent that?
I am using Logstash 8.6.2 wich uses JRuby to 9.3.10.0
@AxelPatron I don't know how you insert Ruby into conf (or some other file which happens to be Ruby syntax) but if you figure out such a place you can:
classObject;aliasjava_kind_of?kind_of?;end
I am guessing java_kind_of? is still being used by whatever provides python support.
Activity
ThomasKoppensteiner commentedon Sep 28, 2021
Yes, it was deprecated in
JRuby-9.2.19.0.See: https://github.com/jruby/jruby/blob/9.2.19.0/core/src/main/ruby/jruby/java/core_ext/object.rb#L13-L19
michaelklishin commentedon Sep 29, 2021
So what are our options then? Use
#assignable_from?instead?enebo commentedon Sep 29, 2021
@ThomasKoppensteiner @michaelklishin Is kind_of? working for your needs here:
ThomasKoppensteiner commentedon Sep 30, 2021
@enebo thank you for your suggestion. I used it in this PR for
march_hareruby-amqp/march_hare#156.enebo commentedon Sep 30, 2021
@ThomasKoppensteiner we talked about this on chat and realized for instance of sorts of checks kind_of? works but if you ask on Java type itself (e.g. java.util.ArrayList.kind_of?(java.lang.Class)) it does not. I think this is probably very uncommon but if you happen to ever notice this case we probably need to augment kind_of?.
olleolleolle commentedon Oct 5, 2021
The use-case in the ticket is the following:
value.kind_of(com.rabbitmq.client.LongString)wherevalueseems to be a Java value (we can see checks in there goingvalue.is_a?(java.util.Map)).@enebo Would this be a valid?
I searched for LONG_STRING_TYPE and found that value. https://github.com/ruby-amqp/march_hare/search?q=LONG_STRING_TYPE
headius commentedon Oct 5, 2021
I believe these should work with
kind_of?oris_aas appropriate. The Ruby view of the Java object uses the same class hierarchy as e.g.com.rabbitmw.client.LongStringand it should be seen as a supertype of the object's class.headius commentedon Oct 5, 2021
Closing as won't fix since
kind_of?should work for all interesting use cases.Fix kind_of (9.3.x)
AxelPatron commentedon May 16, 2023
Hello, I am using Logstash to process python script in my pipeline between SQL and ElasticSearch but if I use this filter in my logstash-sample.conf file
filter { python { code => ' print("python works") ' } }I receive these logs :
[2023-05-16T09:26:01,898][ERROR][logstash.filters.python ][main][9159e3828cc8f1ed140577832a7ee56f40772013e30def286e744cbc9c8f7eb1] Python exception occurred: undefined methodjava_kind_of?' for #Java::OrgPythonCore::PyObjectDerived:0x59f863d5Did you mean? java_send
python works
python works
[2023-05-16T09:26:01,926][ERROR][logstash.filters.python ][main][9159e3828cc8f1ed140577832a7ee56f40772013e30def286e744cbc9c8f7eb1] Python exception occurred: undefined method
java_kind_of?' for #<Java::OrgPythonCore::PyObjectDerived:0x1e55fe7e> Did you mean? java_send python works [2023-05-16T09:26:01,933][ERROR][logstash.filters.python ][main][9159e3828cc8f1ed140577832a7ee56f40772013e30def286e744cbc9c8f7eb1] Python exception occurred: undefined methodjava_kind_of?' for #Java::OrgPythonCore::PyObjectDerived:0x1e55fe7e`I am not sure it causes problems but what could I do to prevent that?
I am using
Logstash 8.6.2wich usesJRuby to 9.3.10.0enebo commentedon May 16, 2023
@AxelPatron I don't know how you insert Ruby into conf (or some other file which happens to be Ruby syntax) but if you figure out such a place you can:
I am guessing java_kind_of? is still being used by whatever provides python support.