src/share/classes/java/lang/invoke/MethodHandle.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7088481 Sdiff src/share/classes/java/lang/invoke

src/share/classes/java/lang/invoke/MethodHandle.java

Print this page




 373  * their function-like types in terms of Java parameterized (generic) types,
 374  * because there are three mismatches between function-like types and parameterized
 375  * Java types.
 376  * <ul>
 377  * <li>Method types range over all possible arities,
 378  * from no arguments to up to 255 of arguments (a limit imposed by the JVM).
 379  * Generics are not variadic, and so cannot represent this.</li>
 380  * <li>Method types can specify arguments of primitive types,
 381  * which Java generic types cannot range over.</li>
 382  * <li>Higher order functions over method handles (combinators) are
 383  * often generic across a wide range of function types, including
 384  * those of multiple arities.  It is impossible to represent such
 385  * genericity with a Java type parameter.</li>
 386  * </ul>
 387  *
 388  * @see MethodType
 389  * @see MethodHandles
 390  * @author John Rose, JSR 292 EG
 391  */
 392 public abstract class MethodHandle {
 393     // { JVM internals:
 394 
 395     private byte       vmentry;    // adapter stub or method entry point
 396     //private int      vmslots;    // optionally, hoist type.form.vmslots
 397     /*non-public*/ Object vmtarget;   // VM-specific, class-specific target value
 398 
 399     // TO DO:  vmtarget should be invisible to Java, since the JVM puts internal
 400     // managed pointers into it.  Making it visible exposes it to debuggers,
 401     // which can cause errors when they treat the pointer as an Object.
 402 
 403     // These two dummy fields are present to force 'I' and 'J' signatures
 404     // into this class's constant pool, so they can be transferred
 405     // to vmentry when this class is loaded.
 406     static final int  INT_FIELD = 0;
 407     static final long LONG_FIELD = 0;
 408 
 409     // vmentry (a void* field) is used *only* by the JVM.
 410     // The JVM adjusts its type to int or long depending on system wordsize.
 411     // Since it is statically typed as neither int nor long, it is impossible
 412     // to use this field from Java bytecode.  (Please don't try to, either.)
 413 
 414     // The vmentry is an assembly-language stub which is jumped to
 415     // immediately after the method type is verified.
 416     // For a direct MH, this stub loads the vmtarget's entry point
 417     // and jumps to it.
 418 
 419     // } End of JVM internals.
 420 
 421     static { MethodHandleImpl.initStatics(); }
 422 
 423     // interface MethodHandle<R throws X extends Exception,A...>
 424     // { MethodType<R throws X,A...> type(); public R invokeExact(A...) throws X; }
 425 
 426     /**
 427      * Internal marker interface which distinguishes (to the Java compiler)
 428      * those methods which are <a href="MethodHandle.html#sigpoly">signature polymorphic</a>.
 429      */
 430     @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD})
 431     @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
 432     @interface PolymorphicSignature { }
 433 
 434     private MethodType type;
 435 
 436     /**
 437      * Reports the type of this method handle.
 438      * Every invocation of this method handle via {@code invokeExact} must exactly match this type.
 439      * @return the method handle type
 440      */




 373  * their function-like types in terms of Java parameterized (generic) types,
 374  * because there are three mismatches between function-like types and parameterized
 375  * Java types.
 376  * <ul>
 377  * <li>Method types range over all possible arities,
 378  * from no arguments to up to 255 of arguments (a limit imposed by the JVM).
 379  * Generics are not variadic, and so cannot represent this.</li>
 380  * <li>Method types can specify arguments of primitive types,
 381  * which Java generic types cannot range over.</li>
 382  * <li>Higher order functions over method handles (combinators) are
 383  * often generic across a wide range of function types, including
 384  * those of multiple arities.  It is impossible to represent such
 385  * genericity with a Java type parameter.</li>
 386  * </ul>
 387  *
 388  * @see MethodType
 389  * @see MethodHandles
 390  * @author John Rose, JSR 292 EG
 391  */
 392 public abstract class MethodHandle {




























 393     static { MethodHandleImpl.initStatics(); }
 394 
 395     // interface MethodHandle<R throws X extends Exception,A...>
 396     // { MethodType<R throws X,A...> type(); public R invokeExact(A...) throws X; }
 397 
 398     /**
 399      * Internal marker interface which distinguishes (to the Java compiler)
 400      * those methods which are <a href="MethodHandle.html#sigpoly">signature polymorphic</a>.
 401      */
 402     @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD})
 403     @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
 404     @interface PolymorphicSignature { }
 405 
 406     private MethodType type;
 407 
 408     /**
 409      * Reports the type of this method handle.
 410      * Every invocation of this method handle via {@code invokeExact} must exactly match this type.
 411      * @return the method handle type
 412      */


src/share/classes/java/lang/invoke/MethodHandle.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File