When Java needs to add a new interface to existing objects, the injection of the new interface can be managed as part of the roll-out of the JDK which contains the new libraries and/or language features. For example, when the collections API came out, the same JDK release introduced Comparable in various predefined types.
This approach not practical for languages not directly supported by the JDK (i.e., languages other than Java). We propose a type-safe, secure, modular way for language runtimes to inject new utility interfaces (like Comparable) into pre-existing classes.
This feature also supports "traits", a common feature whereby implementation types can be retroactively assigned new structural interface types, and even be equipped with (generic) methods.
Finally, this feature supports efficient integration of classes into metaobject protocols, even when the classes were written (and their engineering frozen) long before any given metaobject protocol.
Posted Date : 2009-02-12 07:32:25.0