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

src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java

Print this page
rev 10938 : [mq]: remove.use_lf_editor


 174 
 175     /**
 176      * Create a JVM-level adapter method handle to conform the given method
 177      * handle to the similar newType, using only pairwise argument conversions.
 178      * For each argument, convert incoming argument to the exact type needed.
 179      * The argument conversions allowed are casting, boxing and unboxing,
 180      * integral widening or narrowing, and floating point widening or narrowing.
 181      * @param srcType required call type
 182      * @param target original method handle
 183      * @param strict if true, only asType conversions are allowed; if false, explicitCastArguments conversions allowed
 184      * @param monobox if true, unboxing conversions are assumed to be exactly typed (Integer to int only, not long or double)
 185      * @return an adapter to the original handle with the desired new type,
 186      *          or the original target if the types are already identical
 187      *          or null if the adaptation cannot be made
 188      */
 189     static MethodHandle makePairwiseConvert(MethodHandle target, MethodType srcType,
 190                                             boolean strict, boolean monobox) {
 191         MethodType dstType = target.type();
 192         if (srcType == dstType)
 193             return target;
 194         if (USE_LAMBDA_FORM_EDITOR) {
 195             return makePairwiseConvertByEditor(target, srcType, strict, monobox);
 196         } else {
 197             return makePairwiseConvertIndirect(target, srcType, strict, monobox);
 198         }
 199     }
 200 
 201     private static int countNonNull(Object[] array) {
 202         int count = 0;
 203         for (Object x : array) {
 204             if (x != null)  ++count;
 205         }
 206         return count;
 207     }
 208 
 209     static MethodHandle makePairwiseConvertByEditor(MethodHandle target, MethodType srcType,
 210                                                     boolean strict, boolean monobox) {
 211         Object[] convSpecs = computeValueConversions(srcType, target.type(), strict, monobox);
 212         int convCount = countNonNull(convSpecs);
 213         if (convCount == 0)
 214             return target.viewAsType(srcType, strict);
 215         MethodType basicSrcType = srcType.basicType();
 216         MethodType midType = target.type().basicType();
 217         BoundMethodHandle mh = target.rebind();
 218         // FIXME: Reduce number of bindings when there is more than one Class conversion.




 174 
 175     /**
 176      * Create a JVM-level adapter method handle to conform the given method
 177      * handle to the similar newType, using only pairwise argument conversions.
 178      * For each argument, convert incoming argument to the exact type needed.
 179      * The argument conversions allowed are casting, boxing and unboxing,
 180      * integral widening or narrowing, and floating point widening or narrowing.
 181      * @param srcType required call type
 182      * @param target original method handle
 183      * @param strict if true, only asType conversions are allowed; if false, explicitCastArguments conversions allowed
 184      * @param monobox if true, unboxing conversions are assumed to be exactly typed (Integer to int only, not long or double)
 185      * @return an adapter to the original handle with the desired new type,
 186      *          or the original target if the types are already identical
 187      *          or null if the adaptation cannot be made
 188      */
 189     static MethodHandle makePairwiseConvert(MethodHandle target, MethodType srcType,
 190                                             boolean strict, boolean monobox) {
 191         MethodType dstType = target.type();
 192         if (srcType == dstType)
 193             return target;

 194         return makePairwiseConvertByEditor(target, srcType, strict, monobox);



 195     }
 196 
 197     private static int countNonNull(Object[] array) {
 198         int count = 0;
 199         for (Object x : array) {
 200             if (x != null)  ++count;
 201         }
 202         return count;
 203     }
 204 
 205     static MethodHandle makePairwiseConvertByEditor(MethodHandle target, MethodType srcType,
 206                                                     boolean strict, boolean monobox) {
 207         Object[] convSpecs = computeValueConversions(srcType, target.type(), strict, monobox);
 208         int convCount = countNonNull(convSpecs);
 209         if (convCount == 0)
 210             return target.viewAsType(srcType, strict);
 211         MethodType basicSrcType = srcType.basicType();
 212         MethodType midType = target.type().basicType();
 213         BoundMethodHandle mh = target.rebind();
 214         // FIXME: Reduce number of bindings when there is more than one Class conversion.


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