changeset 55601:01ead3d6c184 intrinsics-project

fallback to XXX::format if Formatter is needed
author vromero
date Tue, 02 Apr 2019 16:45:57 -0400
parents e094cae32946
children 99ed2dfcc0fa
files src/java.base/share/classes/java/lang/invoke/FormatterBootstraps.java
diffstat 1 files changed, 3 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/invoke/FormatterBootstraps.java	Thu Mar 28 22:07:10 2019 +0100
+++ b/src/java.base/share/classes/java/lang/invoke/FormatterBootstraps.java	Tue Apr 02 16:45:57 2019 -0400
@@ -204,22 +204,13 @@
                     constant(String.class, "").asType(methodType) :
                     identity(methodType.parameterType(0)).asType(methodType));
         }
-
-        boolean isFormatterMethod = methodType.parameterCount() > 0 && methodType.parameterType(0) == Formatter.class;
         // Array of formatter args excluding target and locale
         Class<?>[] argTypes = methodType.dropParameterTypes(0, firstFormatterArg(isStringMethod, hasLocaleArg)).parameterArray();
         // index array is needed for argument analysis
         int[] argIndexes = calculateArgumentIndexes(specs, argTypes.length);
-
-        FormatHandleBuilder builder;
-
-        if (isStringMethod && mayNotNeedFormatter(specs, argTypes, argIndexes)) {
-            builder = new StringConcatHandleBuilder(specs, argTypes, argIndexes, hasLocaleArg);
-        } else {
-            builder = new FormatterFormatHandleBuilder(specs, argTypes, argIndexes, hasLocaleArg, isFormatterMethod, isStringMethod);
-        }
-
-        return new ConstantCallSite(builder.getHandle(lookup, methodType));
+        return isStringMethod && mayNotNeedFormatter(specs, argTypes, argIndexes) ?
+            new ConstantCallSite(new StringConcatHandleBuilder(specs, argTypes, argIndexes, hasLocaleArg).getHandle(lookup, methodType)) :
+            new ConstantCallSite(fallbackMethodHandle(lookup, name, methodType, format, isStringMethod, hasLocaleArg, isVarArgs));
     }
 
     private static int[] calculateArgumentIndexes(List<FormatToken> specs, int argCount) {