diff -r 892b9873e831 -r 2b056941e4dd nashorn/docs/JavaScriptingProgrammersGuide.html --- a/nashorn/docs/JavaScriptingProgrammersGuide.html Mon May 20 23:04:01 2013 +0530 +++ b/nashorn/docs/JavaScriptingProgrammersGuide.html Mon May 20 21:25:14 2013 +0200 @@ -616,26 +616,26 @@
It is also possible to convert between JavaScript and Java arrays.
-Given a JavaScript array and a Java type, Java.toJavaArray
returns a Java array with the same initial contents, and with the specified component type.
+Given a JavaScript array and a Java type, Java.to
returns a Java array with the same initial contents, and with the specified array type.
var anArray = [1, "13", false]
- var javaIntArray = Java.toJavaArray(anArray, "int")
+ var javaIntArray = Java.to(anArray, "int[]")
print(javaIntArray[0]) // prints 1
print(javaIntArray[1]) // prints 13, as string "13" was converted to number 13 as per ECMAScript ToNumber conversion
print(javaIntArray[2]) // prints 0, as boolean false was converted to number 0 as per ECMAScript ToNumber conversion
-You can use either a string or a type object returned from Java.type()
to specify the component type of the array.
+You can use either a string or a type object returned from Java.type()
to specify the type of the array.
You can also omit the array type, in which case a Object[]
will be created.
-Given a Java array or Collection, Java.toJavaScriptArray
returns a JavaScript array with a shallow copy of its contents. Note that in most cases, you can use Java arrays and lists natively in Nashorn; in cases where for some reason you need to have an actual JavaScript native array (e.g. to work with the array comprehensions functions), you will want to use this method.
+Given a Java array or Collection, Java.from
returns a JavaScript array with a shallow copy of its contents. Note that in most cases, you can use Java arrays and lists natively in Nashorn; in cases where for some reason you need to have an actual JavaScript native array (e.g. to work with the array comprehensions functions), you will want to use this method.
var File = Java.type("java.io.File");
var listCurDir = new File(".").listFiles();
-var jsList = Java.toJavaScriptArray(listCurDir);
+var jsList = Java.from(listCurDir);
print(jsList);