s shaw
2014-07-08 00:19:42 UTC
I
n Java
My
Class.class and (new
My
Class()).
getC
lass
()
return the same thin
g. In JRuby the equivalent calls would be
Java::
My
Class
.java_class and Java::MyClass.new.get_class right? But these calls return
Java::JavaClass
and
Java::JavaLang::Class
respectively.
Java::JavaClass
seems like a java.lang.Class: it has
annotation_present
() and encosing_class() methods. But if you call declared_fields() it
returns an array of
Java::JavaFiel
d, which does not have java.lang.Field methods like
generic_type
().
How is one supposed to get a true instance of
java.lang.Class
, one that returns
java.lang.Field
when declared_fields() is called?
It appears that
one must first instantiate
the given class
and then call get_class
; o
f course this does not work for abstract classes...
n Java
My
Class.class and (new
My
Class()).
getC
lass
()
return the same thin
g. In JRuby the equivalent calls would be
Java::
My
Class
.java_class and Java::MyClass.new.get_class right? But these calls return
Java::JavaClass
and
Java::JavaLang::Class
respectively.
Java::JavaClass
seems like a java.lang.Class: it has
annotation_present
() and encosing_class() methods. But if you call declared_fields() it
returns an array of
Java::JavaFiel
d, which does not have java.lang.Field methods like
generic_type
().
How is one supposed to get a true instance of
java.lang.Class
, one that returns
java.lang.Field
when declared_fields() is called?
It appears that
one must first instantiate
the given class
and then call get_class
; o
f course this does not work for abstract classes...