Re: [jruby-user] Re: Differences Between MyClass.class and getClass() in JRuby

s shaw <[email protected]>
Newsgroups gmane.comp.lang.jruby.user
Message-ID <CACnU8SGXxOtvsqr2ePuhz0uTj+SyGAUY=w_PXXH3XodC8R01AQ@mail.gmail.com>
> I'm getting the expected result.

That's because inspect is calling toString() which outputs "class ...".
If you look at the ruby class you can see the difference:

~ >cat /tmp/reflect.rb
klass = java.lang.String
p klass.new.get_class.class
p klass.java_class.class
p klass.new.get_class.declared_fields[0].generic_type
p klass.java_class.declared_fields[0].generic_type
~ >ruby -v !!:$
ruby -v /tmp/reflect.rb
jruby 1.7.12 (1.9.3p392) 2014-06-20 643e292 on Java HotSpot(TM) 64-Bit
Server VM 1.6.0_65-b14-462-11M4609 [darwin-x86_64]
Java::JavaLang::Class
Java::JavaClass
class [C
NoMethodError: undefined method `generic_type' for private final char[]
java.lang.String.value:Java::JavaField
  (root) at /tmp/reflect.rb:5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.