JDK-6804588 : Non-Java languages need interface injection to retrofit pre-existing classes
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 7,9,10
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2009-02-12
  • Updated: 2017-04-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 13

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.