Closed
Bug 228446
Opened 22 years ago
Closed 22 years ago
eval returns corrupt arrays when they are very long
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 225831
1.5R5
People
(Reporter: yaar, Assigned: igor)
Details
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Build Identifier: Rhino v1.5.3
The following code works alright:
eval("var a = [['x1','y1'], ['x2','y2']];");
java.lang.System.out.println(a.length);
//prints 2
java.lang.System.out.println(a[0]);
//prints "x1, y1"
java.lang.System.out.println(typeof(a[0]));
//prints "object"
While this code produces bad results:
eval("var a = [['x1','y1'], ['x2','y3'], ..., ['x2000','y2000']];");
java.lang.System.out.println(a.length);
//prints 2000
java.lang.System.out.println(a[0]);
//prints "x1792" instead of "x1, y1"!!!!
java.lang.System.out.println(typeof(a[0]));
//prints "string" instead of "object"!!!!
Reproducible: Always
Steps to Reproduce:
We embed Rhino in a Java application, over JDK 1.4.1_05.
| Assignee | ||
Comment 2•22 years ago
|
||
It is fixed in Rhino CVS tip as bug 225831. For example, the following script
works as expected with N = 2, 2000, 20000:
var N = 20000;
var buf = Array(N + 1);
buf[0] = "var a = [";
for (var i = 1; i != N + 1; ++i) {
buf[i] = "['x"+i+"','y"+i+"']"+(i != N ? "," : "];");
}
var script_str = buf.join("");
eval(script_str)
java.lang.System.out.println(a.length);
java.lang.System.out['println(java.lang.String)'](a[0]);
java.lang.System.out.println(typeof(a[0]));
Note that simple java.lang.System.out.println(a[0]) should not work since a[0]
is 2 element array which makes Rhino to try java.lang.System.out.println(char[])
but then the value of a[0][0] which is 'x1' is not one-char-string and can not
be converted to char. So explicit function selector should be specified.
*** This bug has been marked as a duplicate of 225831 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•