RFR: 8186500: StringConcatFactory.makeConcatWithConstants throws AssertionError when recipe contains non-String constants

Paul Sandoz paul.sandoz at oracle.com
Mon Aug 21 18:06:20 UTC 2017


> On 21 Aug 2017, at 07:48, Claes Redestad <claes.redestad at oracle.com> wrote:
> 
> Hi,
> 
> a trivial test[1] invoking the StringConcatFactory.makeConcatWithConstants fails
> when providing an Integer as a constant, which appears to be due to failure to
> coerce boxed types to the corresponding primitive types when looking up various
> methods in StringConcatHelper:
> 
> Webrev: http://cr.openjdk.java.net/~redestad/8186500/jdk.00/
> Bug: https://bugs.openjdk.java.net/browse/JDK-8186500
> 
> Simply using Wrapper.asPrimitiveType coerces boxed types to their primitive
> counterpart, and is a (semantical) no-op for other types, e.g., String.
> 

Looks good. Perhaps a token test would be useful (maybe hard to test all code paths here without some combinator test).

Paul.

> Thanks!
> 
> /Claes
> 
> [1]
> 
> import java.lang.invoke.*;
> 
> public class Test {
>    public static void main(String ... args) throws Exception {
> StringConcatFactory.makeConcatWithConstants(MethodHandles.lookup(), "name",
>            MethodType.methodType(String.class, String.class, String.class), "\1\2\1", (Integer)1);
>    }
> }
> 



More information about the core-libs-dev mailing list