Skip to content

NativeJavaList iterator unavailable in SafeStandardObject after commit b5e7f859 #2192

@Rhython

Description

@Rhython

Describe the bug
After the changes introduced by commit b5e7f85, the iterator for NativeJavaList is not available in the SafeStandardObject environment.

To Reproduce
Here is a code example that demonstrates the issue:

try (Context cx = Context.enter()) {
    Scriptable scope = cx.initSafeStandardObjects();
    scope.put("value", scope, List.of("a", "b", "c"));
    Object result = cx.evaluateString(scope, "let res = ''; for (let x of value) { res += x; } res;", "test", 1, null);
    System.out.println(Context.toString(result));
}

This code produces the following confusing error:

org.mozilla.javascript.EcmaError: TypeError: next is not a function, it is object. (test.js#1)

Expected behavior
This code runs as expected in release 1.8.0.

Additional context
This appears to be a regression introduced by commit b5e7f85. Please investigate if iterators support for NativeJavaList should be restored in the SafeStandardObject environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions