RFR [9] 8150829: Enhanced drop-args, identity and default constant, varargs adjustment
shilpi.rastogi at oracle.com
shilpi.rastogi at oracle.com
Wed Apr 13 12:12:07 UTC 2016
Thank You Paul for the suggestions.
Please review the updated webrev
http://cr.openjdk.java.net/~srastogi/8150829/webrev.05
Thanks,
Shilpi
On 4/12/2016 7:32 PM, Paul Sandoz wrote:
> Hi,
>
> Just minor comments, below.
>
> Paul.
>
>
> MethodHandle
> —
>
> 972 /**
> 973 * Adapts this method handle to be {@linkplain #asVarargsCollector variable arity}
> 974 * if the boolean flag is true, else {@linkplain #asFixedArity fixed arity}.
> 975 * If the method handle is already of the proper arity mode, it is returned
> 976 * unchanged.
> 977 * <p>This method is sometimes useful when adapting a method handle that
> 978 * may be variable arity, to ensure that the resulting adapter is also
> 979 * variable arity if and only if the original handle was. For example,
> 980 * this code changes the first argument of a handle
>
> , {@code mh},
>
> to {@code int} without
> 981 * disturbing its variable arity property:
> 982 * {@code mh.asType(mh.type().changeParameterType(0,int.class)).withVarargs(mh.isVarargsCollector())}
>
> The above paragraph can be an @apiNote.
>
> Also can you format the code block over two lines to emphasise the last call., otherwise i think it is harder to read.
>
>
> 983 * @param makeVarargs true if the return method handle should have variable arity behavior
> 984 * @return a method handle of the same type, with possibly adjusted variable arity behavior
> 985 * @throws IllegalArgumentException if {@code makeVarargs} is true and
> 986 * this method handle does not have a trailing array parameter
> 987 * @since 9
>
> Add
>
> @see #asVarargsCollector
> @see #asFixedArity
>
> ?
>
> 988 */
> 989 public MethodHandle withVarargs(boolean makeVarargs) {
>
>
>
> MethodHandles
> —
>
> 2387 /** Produces a constant method handle of the requested return type which
>
> new line after ‘/**'
>
>
> 2388 * returns the default value for that type every time it is invoked.
> 2389 * The resulting constant method handle will have no side effects.
> 2390 * <p>The returned method handle is equivalent to {@code empty(methodType(type))}.
> 2391 * It is also equivalent to {@code explicitCastArguments(constant(Object.class, null), methodType(type))},
> 2392 * since {@code explicitCastArguments} converts {@code null} to default values.
>
> Is this method more efficient than the other two?
It is existing method made it public and renamed it to zero from zeroHandle.
>
>
> 2393 * @param type the expected return type of the desired method handle
> 2394 * @return a constant method handle that takes no arguments and returns the default value of the given type (or void, if the type is void)
>
> Can you format to be a little more consistent and not so long on the line length, as it becomes really tricky read.
>
>
> 2395 * @throws NullPointerException if the argument is null
> 2396 * @see MethodHandles#constant
> 2397 * @see MethodHandles#empty
> 2398 * @since 9
> 2399 */
> 2400 public static MethodHandle zero(Class<?> type) {
> 2401 Objects.requireNonNull(type);
> 2402 return type.isPrimitive() ? zero(Wrapper.forPrimitiveType(type), type) : zero(Wrapper.OBJECT, type);
> 2403 }
> 2404
>
>
> 2409 /**
> 2410 * Produces a method handle of the requested type which ignores any arguments, does nothing,
> 2411 * and returns a suitable default depending on the return type.
> 2412 * That is, it returns a zero primitive value, a {@code null}, or {@code void}.
> 2413 * <p>The returned method handle is equivalent to
> 2414 * {@code dropArguments(zero(type.returnType()), 0, type.parameterList())}.
> 2415 * <p>
> 2416 * Example: Given a predicate and target, a useful "if-then" construct can be constructed as
>
> s/Example:/@apiNote (same applies to the method dropArgumentsToMatch)
>
> s/constructed/produced
>
>
> 2417 * {@code guardWithTest(pred, target, empty(target.type())}.
> 2418 * @param type the type of the desired method handle
> 2419 * @return a constant method handle of the given type, which returns a default value of the given return type
> 2420 * @throws NullPointerException if the argument is null
> 2421 * @see MethodHandles#zero
> 2422 * @see MethodHandles#constant
> 2423 * @since 9
> 2424 */
> 2425 public static MethodHandle empty(MethodType type) {
>
>
> 2726 MethodHandle h0= constant(boolean.class, true);
>
> Space before '='
>
>
> ConstantIdentityMHTest
> —
>
> You should test the signatures and values for all primitives, ref and void.
>
>
>
>
>> On 11 Apr 2016, at 07:47, shilpi.rastogi at oracle.com wrote:
>>
>> Gentle Reminder!
>>
>> -------- Forwarded Message --------
>> Subject: RFR [9] 8150829: Enhanced drop-args, identity and default constant, varargs adjustment
>> Date: Thu, 24 Mar 2016 11:18:56 +0530
>> From: shilpi.rastogi at oracle.com <shilpi.rastogi at oracle.com>
>> Reply-To: core-libs-dev at openjdk.java.net
>> To: mlvm-dev at openjdk.java.net
>>
>> Hi All,
>>
>> Please review the following-
>>
>>
>> https://bugs.openjdk.java.net/browse/JDK-8150829
>> http://cr.openjdk.java.net/~srastogi/8150829/webrev.04
>>
>>
>>
>> Thanks,
>> Shilpi
>>
>>
>>
>> _______________________________________________
>> mlvm-dev mailing list
>> mlvm-dev at openjdk.java.net
>> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>
>
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20160413/60863916/attachment.html>
More information about the mlvm-dev
mailing list