I have a homegrown WrapFactory for that. You can find the code at 
<http://markmail.org/message/xkmxywud3dgzfqlw>

A word of caution though: it will expose indexed access through the [] operator 
and for...in, as well as the .length property, but will not make the 
java.util.Lists otherwise act as arrays. i.e. they'll have no .forEach() and 
other methods. You could *probably* create a solution where the lists also get 
the Array.prototype as their prototype; not 100% sure about it though...

Attila.

On 2010.07.07., at 9:50, Daniel Winterstein wrote:

> 
> Is it possible to configure Rhino to do automatic conversion or wrapping 
> between Java types and Javascript equivalents?
> 
> In particular, I'd like to use javascript to call a Java method which returns 
> a List. And have that List be mapped to a Javascript array.
> 
> I understand why this isn't the normal behaviour, but it can be very useful 
> in places. Is there a way to get this behaviour?
> 
> This is probably an old question, but I couldn't find the answer in 
> documentation or archives.
> 
> Background: Our software allows users to write scripts in Javascript, 
> executed using Rhino. These scripts are accessing Java objects. Our users 
> expect lists to behave like Javascript arrays. Which leads to bugs, 
> confusion, distress, etc.
> 
> Thank you in advance for any help.
> 
> Best regards,
> Daniel
> 
> --------------------------------------------
> Dr Daniel Winterstein
> Winterwell Associates Ltd
> tel: 0772 5172 612
> http://www.winterwell.com
> Registered in Scotland, company no. SC342991
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to