<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.jvmlangsummit.com/index.php?action=history&amp;feed=atom&amp;title=Why_Interface_Injection</id>
	<title>Why Interface Injection - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.jvmlangsummit.com/index.php?action=history&amp;feed=atom&amp;title=Why_Interface_Injection"/>
	<link rel="alternate" type="text/html" href="https://wiki.jvmlangsummit.com/index.php?title=Why_Interface_Injection&amp;action=history"/>
	<updated>2026-05-23T11:51:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://wiki.jvmlangsummit.com/index.php?title=Why_Interface_Injection&amp;diff=762&amp;oldid=prev</id>
		<title>Jrose: New page: Do we need interface injection, or do ClassValue and invokedynamic do everything we want?  Let's gather the use cases.  Definitions and design discussion may be found at [[Interface_inject...</title>
		<link rel="alternate" type="text/html" href="https://wiki.jvmlangsummit.com/index.php?title=Why_Interface_Injection&amp;diff=762&amp;oldid=prev"/>
		<updated>2011-07-20T23:07:46Z</updated>

		<summary type="html">&lt;p&gt;New page: Do we need interface injection, or do ClassValue and invokedynamic do everything we want?  Let&amp;#039;s gather the use cases.  Definitions and design discussion may be found at [[Interface_inject...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Do we need interface injection, or do ClassValue and invokedynamic do everything we want?&lt;br /&gt;
&lt;br /&gt;
Let's gather the use cases.&lt;br /&gt;
&lt;br /&gt;
Definitions and design discussion may be found at [[Interface_injection|Tobias Ivarsson's &amp;quot;Case for Interface Injection&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
== use cases for injecting the supertype *only* ==&lt;br /&gt;
&lt;br /&gt;
In many cases, adding runtime information to arbitrary target classes can best be done with java.lang.ClassValue.  The invokedynamic instruction can encode associated operations with this ClassValue.&lt;br /&gt;
&lt;br /&gt;
In some cases, there is a prior commitment or inclination to use Java interfaces and perhaps interface inheritance.&lt;br /&gt;
&lt;br /&gt;
=== Infinite Supertypes ===&lt;br /&gt;
Some languages (a) have infinite sets of supertypes, and (b) want to represent their types as Java classes and interfaces.  Scala and Fortress are in this category.&lt;br /&gt;
&lt;br /&gt;
Example:  Given the way function types work, ()-&amp;gt;String is a subtype of ()-&amp;gt;Object.  Argument type &amp;quot;go backwards&amp;quot;, so (String)-&amp;gt;void is a *supertype* of (Object)-&amp;gt;void.  In fact, (Foo)-&amp;gt;void is a supertype of (Object-&amp;gt;void for every subclass Foo of object!  Thus, if a language represents (Object)-&amp;gt;void as an interface IFn_Object_V, it may attempt to declare super-interfaces in the classfile of IFn_Object_V, including IFn_String_V, etc.  If a new type Foo is loaded, then IFn_Foo_V should be retroactively added to the super-interface list for IFn_Object_V.&lt;br /&gt;
&lt;br /&gt;
Workaround:  Have the language use JVM interface subtyping as a first resort, but have its own subtype algorithm (like the JVM's) as a last resort.  Same idea for method lookup, if IFn_Foo_V contains Java methods.&lt;br /&gt;
&lt;br /&gt;
== use cases for injecting methods ==&lt;br /&gt;
&lt;br /&gt;
=== Defender methods ===&lt;br /&gt;
Defenders are methods which can be added to implementations of interfaces, where the implementation class and the interface are statically related; there is no need to modify a type's supertypes.&lt;br /&gt;
&lt;br /&gt;
== external links ==&lt;br /&gt;
;Old Proposal: http://blogs.oracle.com/jrose/entry/interface_injection_in_the_vm&lt;/div&gt;</summary>
		<author><name>Jrose</name></author>
		
	</entry>
</feed>