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

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

Print this page
rev 10274 : 8050052: Small cleanups in java.lang.invoke code
Reviewed-by: ?
rev 10275 : 8050053: Improve caching of different invokers
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10276 : 8050166: Get rid of some package-private methods on arguments in j.l.i.MethodHandle
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10277 : 8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10281 : [mq]: 11.8050877.conv


2003      *     by a Java casting conversion (JLS 5.5) on the primitive value,
2004      *     possibly followed by a conversion from byte to boolean by testing
2005      *     the low-order bit.
2006      * <li>If <em>T0</em> is a reference and <em>T1</em> a primitive,
2007      *     and if the reference is null at runtime, a zero value is introduced.
2008      * </ul>
2009      * @param target the method handle to invoke after arguments are retyped
2010      * @param newType the expected type of the new method handle
2011      * @return a method handle which delegates to the target after performing
2012      *           any necessary argument conversions, and arranges for any
2013      *           necessary return value conversions
2014      * @throws NullPointerException if either argument is null
2015      * @throws WrongMethodTypeException if the conversion cannot be made
2016      * @see MethodHandle#asType
2017      */
2018     public static
2019     MethodHandle explicitCastArguments(MethodHandle target, MethodType newType) {
2020         if (!target.type().isCastableTo(newType)) {
2021             throw new WrongMethodTypeException("cannot explicitly cast "+target+" to "+newType);
2022         }
2023         return MethodHandleImpl.makePairwiseConvert(target, newType, 2);
2024     }
2025 
2026     /**
2027      * Produces a method handle which adapts the calling sequence of the
2028      * given method handle to a new type, by reordering the arguments.
2029      * The resulting method handle is guaranteed to report a type
2030      * which is equal to the desired new type.
2031      * <p>
2032      * The given array controls the reordering.
2033      * Call {@code #I} the number of incoming parameters (the value
2034      * {@code newType.parameterCount()}, and call {@code #O} the number
2035      * of outgoing parameters (the value {@code target.type().parameterCount()}).
2036      * Then the length of the reordering array must be {@code #O},
2037      * and each element must be a non-negative number less than {@code #I}.
2038      * For every {@code N} less than {@code #O}, the {@code N}-th
2039      * outgoing argument will be taken from the {@code I}-th incoming
2040      * argument, where {@code I} is {@code reorder[N]}.
2041      * <p>
2042      * No argument or return value conversions are applied.
2043      * The type of each incoming argument, as determined by {@code newType},




2003      *     by a Java casting conversion (JLS 5.5) on the primitive value,
2004      *     possibly followed by a conversion from byte to boolean by testing
2005      *     the low-order bit.
2006      * <li>If <em>T0</em> is a reference and <em>T1</em> a primitive,
2007      *     and if the reference is null at runtime, a zero value is introduced.
2008      * </ul>
2009      * @param target the method handle to invoke after arguments are retyped
2010      * @param newType the expected type of the new method handle
2011      * @return a method handle which delegates to the target after performing
2012      *           any necessary argument conversions, and arranges for any
2013      *           necessary return value conversions
2014      * @throws NullPointerException if either argument is null
2015      * @throws WrongMethodTypeException if the conversion cannot be made
2016      * @see MethodHandle#asType
2017      */
2018     public static
2019     MethodHandle explicitCastArguments(MethodHandle target, MethodType newType) {
2020         if (!target.type().isCastableTo(newType)) {
2021             throw new WrongMethodTypeException("cannot explicitly cast "+target+" to "+newType);
2022         }
2023         return MethodHandleImpl.makePairwiseConvert(target, newType, false);
2024     }
2025 
2026     /**
2027      * Produces a method handle which adapts the calling sequence of the
2028      * given method handle to a new type, by reordering the arguments.
2029      * The resulting method handle is guaranteed to report a type
2030      * which is equal to the desired new type.
2031      * <p>
2032      * The given array controls the reordering.
2033      * Call {@code #I} the number of incoming parameters (the value
2034      * {@code newType.parameterCount()}, and call {@code #O} the number
2035      * of outgoing parameters (the value {@code target.type().parameterCount()}).
2036      * Then the length of the reordering array must be {@code #O},
2037      * and each element must be a non-negative number less than {@code #I}.
2038      * For every {@code N} less than {@code #O}, the {@code N}-th
2039      * outgoing argument will be taken from the {@code I}-th incoming
2040      * argument, where {@code I} is {@code reorder[N]}.
2041      * <p>
2042      * No argument or return value conversions are applied.
2043      * The type of each incoming argument, as determined by {@code newType},


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