Subj : Re: Javascript / Java To : netscape.public.mozilla.jseng From : alvaro.diaz@roxes.com (Alvaro Diaz) Date : Wed Apr 30 2003 04:41 am neomingus@yahoo.com (ming) wrote in message news:... > I been playing around with rhino 1.5 and it works great, but I have > one problem that I just can't figure out. > How to convert JS array and Java array? > For example: In my test.js file: > function addArray(array1, array2) { > result = new Array(); > for (i = 0 ; i < array1.length; i++) { > result[i] = array1[i] + array[2]; > } > return result > } > The problem is, I call this function from a Java class, passing in two > int[] to this function. The result from the function is simply an > Object, not array. So I have to convert it into java array. > Is there a way to do this easily? > > Thanks call org.mozilla.javascript.JavaAdapter.convertResult( object, new Object[0].getClass()); where object is your result object. the second parameter is the expected type to contvert to. the call should return an java object array. regards, alvaro .