Replies: 1 comment 1 reply
-
There is some unification of these types by @kares in #6513, due to ship in 9.3 "any day now". That PR unifies the JavaClass API and the java.lang.reflect.Class API by decorating the latter with the former's methods. However the result is still a reflective "mirror" object and is not a true metaclass. @dmikurube discovered I recall other folks asking why we don't have JavaClass/java.lang.Class methods on the proxy metaclasses, or why the static methods of a class are not bound on the JavaClass/java.lang.Class object. The only answers I could come up with were "we just haven't done it" or "the static methods might collide with an existing method" but I don't recall having had a discussion about it. |
Beta Was this translation helpful? Give feedback.
-
From a recommendation by @headius, let me share my use-case of a "Java class" in JRuby.
https://twitter.com/headius/status/1375130217518403586
I wanted to call a static method of a Java class from JRuby in a simple manner. Although I can call it with a JRuby wrapper like
Java::java.lang.String.join(":", "a", "b")
easily, it is not very easy to call it with a Java class. For example,Java::java.lang.String.java_class.join(":", "a", "b")
does not work.I know that
Java::java.lang.String.java_class.join(":", "a", "b")
was an arbitrary case. A simpified example of my actual use-case was a Java class loaded by my own class loader.Instead, I had to insert
ruby_class
for the loaded Java class:The
ruby_class
was actually a sufficient workaround for me. But, let me share this case to help the JRuby team improving thejava_class
object in 9.3. Hope it helps!Beta Was this translation helpful? Give feedback.
All reactions