Interface injection

From JVMLangSummit
Jump to navigationJump to search

Interface Injection is a feature that allows adding interfaces that have been defined as injectable into any target class that does not already implement that interface.

"The case for Interface Injection"

Speaker
Tobias Ivarsson
Project
https://github.com/thobe/mlvm (a patchset for the patchset for OpenJDK)
Slides
The case for Interface Injection

Abstract

It is time to start laying out the features for Java 8. I would like to propose considering interface injection for that feature set. Interface injection is the ability to inject an interface defined as injectable into any class in the JVM. In this talk I will outline the current status of the specification and implementation of interface injection. I will go through the various areas where interface injection is applicable, such as low overhead adapters, traits, and dynamic types. And I will discuss how interface injection relates to other features, such as defender methods and invoke dynamic.

Workshop discussions

Add implementation Add interface Add method (<-- hover these titles for description)
Defender methods X add implementations for methods defined in the interface, that the class doesn't implement
Interface adaptation X Add an interface to a class that doesn't declare that it implements that interface, but implements all methods of the interface
Interface injection X X Add an interface to a class that doesn't declare that it implements that interface, also add implementations for the methods of that interface
Implements Dynamic X Invoke any method (name+signature) on a class that declares that it implements a special interface
Inject Dynamic X X X Invoke any method (name+signature) on any class, by adding a special interface