RFR: JDK-8285932 Implementation of JEP-430 String Templates (Preview) [v7]

Jim Laskey jlaskey at openjdk.org
Thu Nov 3 14:46:47 UTC 2022


On Wed, 2 Nov 2022 17:23:24 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/runtime/TemplateSupport.java line 184:
>> 
>>> 182:         MethodHandle mh = MethodHandles.insertArguments(DEFAULT_PROCESS_MH, 0, fragments, processor);
>>> 183:         mh = mh.withVarargs(true);
>>> 184:         mh = mh.asType(type);
>> 
>> I suggest doing:
>> Suggestion:
>> 
>>         mh = mh.asCollector(Object[].class, type.parameterCount());
>>         mh = mh.asType(type);
>> 
>> Instead, as it is more straightforward in terms of the code that gets called. (the impl of `withVarargs` + `asType` does the same thing in a more roundabout way).
>
> As a side note: I think we can add an overload to `asCollector` that takes a `MethodType`, and does the 2 lines above in one. (the array type would be the return type of the method type).

Changing

-------------

PR: https://git.openjdk.org/jdk/pull/10889


More information about the compiler-dev mailing list