Extension methods

Rémi Forax forax at univ-mlv.fr
Fri Nov 20 17:53:11 PST 2009


Le 21/11/2009 02:31, Neal Gafter a écrit :
> On Fri, Nov 20, 2009 at 5:34 PM, Rémi Forax <forax at univ-mlv.fr 
> <mailto:forax at univ-mlv.fr>> wrote:
>
>     There is already an existing mechanism to insert extension methods
>     at runtime: interface injection
>     (http://openjdk.java.net/projects/mlvm/subprojects.html#InterfaceInjection)
>
>     This mechanism allow to add an interface + implementation to a
>     class at runtime.
>
>     Written in Java, it will be something like that:
>     package java.util;
>     public extension interface ExtMap<K,V> extends Map<K,V> {
>       public Map.entry getEntry(K key) {
>         ...
>       }
>     }
>
>     package java.util;
>     public interface Map<K,V> extension ExtMap<K,V> {
>       ...
>     }
>
>
> When at runtime is the extension done?  When ExtMap is statically 
> initialized?

The extension is done for each implementation of Map the first time
there is a checkcast (and reflection counterparts) from an 
implementation of Map to ExtMap.
ExtMap is initialized when needed as usual.

Rémi



More information about the coin-dev mailing list