-
Notifications
You must be signed in to change notification settings - Fork 903
Implement ES2025 Iterator constructor #2078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
a5b0893 to
75d541a
Compare
|
Before we get farther on this -- can some of the other users of the project take a look at this feature and let me know how we should handle it? It's the first time we've added a feature flag for something as basic as iterator behavior AFAIK. When we went through this before, we created VERSION_ECMASCRIPT and said that, in the future, we'd track the spec. To me, that means that this feature should not have a feature flag, but should instead be invoked if the language version is VERSION_ECMASCRIPT. Anyone else have an opinion on this? |
e22bf98 to
15cf2fb
Compare
rhino/src/main/java/org/mozilla/javascript/AbstractEcmaObjectOperations.java
Outdated
Show resolved
Hide resolved
37f0c29 to
ab2b35d
Compare
- Remove iterator/iterable support (will be added after Iterator PR merges) - Replace LambdaFunction with BaseFunction for Context safety - Remove AsyncIteratorProcessor (not needed without iterator support) - Keep AsyncArrayLikeProcessor for array-like processing - Avoids dependency on IteratorLikeIterable which has Context capture issues This simplified version ensures Array.fromAsync can be merged independently without waiting for the Iterator constructor PR (mozilla#2078) to be fixed.
This PR implements the ES2025 Iterator constructor and Iterator.from() static method. Changes: - Add NativeES2025Iterator implementing the ES2025 Iterator constructor - Add ES6IteratorAdapter to wrap iterators with Iterator.prototype - Add IteratorOperations with Context-safe utility methods - Fix IteratorLikeIterable Context capture bug (remove Context from instance fields) - Register NativeES2025Iterator in ScriptRuntime - Update test262.properties with regenerated test expectations The Iterator constructor throws TypeError when called directly (per spec). Iterator.from() wraps iterables to inherit from Iterator.prototype. Fixed critical thread safety issue where IteratorLikeIterable was storing Context in instance fields, which breaks in multi-threaded environments.
e682b6a to
671bb1b
Compare
@gbrail before have a serious look at this i like to have it in a good shape. During the last weeks is spend far too much time discussing the pr's having this garbarge test262.properties file. |
Iterator Infrastructure Improvements
This PR adds robust iterator handling infrastructure to Rhino with three new utility classes that solve Context safety and architectural issues.
What's Added
IteratorOperations.java - Context-safe iterator utilities
ES6IteratorAdapter.java - Iterator.from() wrapper
Enhanced IteratorLikeIterable.java - ECMAScript → Java bridge
Why This Matters
Context Safety: Rhino's multi-threaded environment requires careful Context handling. These utilities avoid the common bug of capturing Context in instance variables or closures.
Architecture: Clean separation between ECMAScript iterator protocol and Java's Iterable interface, enabling robust iterator support across Rhino's codebase.
Developer Experience: Consistent, reusable patterns for iterator handling that other contributors can safely use.