User loginNavigation |
Extending Java with YieldThe Yielder library by infomancers (a.k.a. Aviad Ben Dov of the Chaotic Java weblog) is a library providing Java with Ruby/Python/C#-like yield-ing for iterators. It works by using Java 1.5's facility for hooking user-defined class inspectors/transformers into the classloader, and rewriting the bytecode of a yieldNextCore() method containing calls to yieldReturn(foo) so that its local variables are promoted to members of an anonymous inner class, which also maintains the state of the iterator/generator. Examples, rationale and implementation are discussed in detail at Chaotic Java. There is also a collections library built on top of Yielder, with tree traversal iterators and map/filter-like functionality. From a PL perspective, this ability to hook into the classloader and do bytecode manipulation on plain java classes provides an interesting mechanism for prototyping new language features in libraries. It could equally well support an aspect framework (via annotations), and perhaps even something like Terracotta's distributed heap. |
Browse archives
Active forum topics |
Recent comments
21 weeks 6 days ago
21 weeks 6 days ago
21 weeks 6 days ago
44 weeks 23 hours ago
48 weeks 2 days ago
50 weeks 1 hour ago
50 weeks 1 hour ago
1 year 3 days ago
1 year 5 weeks ago
1 year 5 weeks ago