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

Claes Redestad claes.redestad at oracle.com
Mon Aug 21 14:48:26 UTC 2017


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.

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