Closed
Bug 243318
Opened 21 years ago
Closed 20 years ago
Context.newArray does not allow derived array types
Categories
(Rhino Graveyard :: Core, enhancement)
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: rknight, Assigned: igor)
Details
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
Build Identifier:
Context.newArray has an explicit check to prevent derived arrays from being
passed. For example if you have a String[] you are forced to create an Object
[] and copy the contents of the String[] before you pass the array to newArray.
This can be fixed by removing the check in new Array as below:
public final Scriptable newArray(Scriptable scope, Object[] elements)
{
// if (elements.getClass().getComponentType() !=
ScriptRuntime.ObjectClass)
// throw new IllegalArgumentException();
Scriptable result = new NativeArray(elements);
newArrayHelper(scope, result);
return result;
}
Reproducible: Always
Steps to Reproduce:
1.
2.
3.
| Assignee | ||
Comment 1•21 years ago
|
||
The check is done on purpose to prevent cast errors during assignments in JS.
Currently the array code in Rhino does not do any type checks when the array is
assigned and it may lead to hard to debug the errors.
I would prefer for the check to exist until the array code is updated with
proper checks to throw proper JS exceptions.
| Assignee | ||
Comment 2•20 years ago
|
||
There are too many corner cases to implemet this properly. Marking as WONTFIX.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•