logo       

Re: java.lang.reflect.Array considered harmful?: msg#00028

lang.jruby.user

Subject: Re: java.lang.reflect.Array considered harmful?

robert kuzelj wrote:

hi,


I'm messing with JMX and I'm trying to call

Object invoke(Objectame, String opName, Object[] args, String[] signature)

Problem: is there a way to create an empty String[] with JRuby?

I've been messing with java.lang.reflect.Array and its newInstance method, but that doesn work because include_class-ing it will mess up JRuby, because it seems like java.lang.reflect.Array replaces JRuby's Array. I think this is the case, because after the include_class, I keep on getting the error message
"No method '<<' on Array"


can you send the code?

Well this reprodcues the error message:
include_class "java.lang.reflect.Array"
foo=[]
foo << 1

Which is clear enough (the reflect.Array seems to replace Rubys Array).


The problematic JMX Code I'm trying to use is this ('mb' is an instance
of com.sun.jmx.mbeanserver.JmxMBeanServer):
mb.invoke(mem.objectName, "getThreadUserTime", [], [])

The first [] must be an Object[], the second one must be a String[].
The Object[] doesn't seem to be a problem; but no matter what I do,
the second parameter is always turned into a RubyArray instance.

I even tried hacks like calling
x = StringBuffer.new("")
"".toString.split("XXX"),
which return an empty String array (or one containing an empty string), but that returns a RubyArray as well.



murphee
--
Blog @ http://jroller.com/page/murphee


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise