Top Description Inners Fields Constructors Methods
java.lang.invoke

public final Class StringConcatFactory

extends Object
Class Inheritance
Imports
jdk.internal.access.JavaLangAccess, .SharedSecrets, jdk.internal.misc.VM, jdk.internal.util.ClassFileDumper, jdk.internal.vm.annotation.Stable, sun.invoke.util.Wrapper, java.lang.classfile.ClassBuilder, .ClassFile, .CodeBuilder, .TypeKind, java.lang.constant.ClassDesc, .ConstantDescs, .MethodTypeDesc, java.lang.invoke.MethodHandles.Lookup, java.lang.reflect.AccessFlag, java.util.Objects, .Set, java.util.function.Consumer

Methods to facilitate the creation of String concatenation methods, that can be used to efficiently concatenate a known number of arguments of known types, possibly after type adaptation and partial evaluation of arguments. These methods are typically used as bootstrap methods for invokedynamic call sites, to support the string concatenation feature of the Java Programming Language.

Indirect access to the behavior specified by the provided MethodHandle proceeds in order through two phases:

  1. Linkage occurs when the methods in this class are invoked. They take as arguments a method type describing the concatenated arguments count and types, and optionally the String recipe, plus the constants that participate in the String concatenation. The details on accepted recipe shapes are described further below. Linkage may involve dynamically loading a new class that implements the expected concatenation behavior. The CallSite holds the MethodHandle pointing to the exact concatenation method. The concatenation methods may be shared among different CallSites, e.g. if linkage methods produce them as pure functions.
  2. Invocation occurs when a generated concatenation method is invoked with the exact dynamic arguments. This may occur many times for a single concatenation method. The method referenced by the behavior MethodHandle is invoked with the static arguments and any additional dynamic arguments provided on invocation, as if by MethodHandle#invoke(Object...).

This class provides two forms of linkage methods: a simple version (makeConcat(java.lang.invoke.MethodHandles.Lookup, String, MethodType)) using only the dynamic arguments, and an advanced version (makeConcatWithConstants(java.lang.invoke.MethodHandles.Lookup, String, MethodType, String, Object...) using the advanced forms of capturing the constant arguments. The advanced strategy can produce marginally better invocation bytecode, at the expense of exploding the number of shapes of string concatenation methods present at runtime, because those shapes would include constant static arguments as well.

API Note

There is a JVM limit (classfile structural constraint): no method can call with more than 255 slots. This limits the number of static and dynamic arguments one can pass to bootstrap method. Since there are potential concatenation strategies that use MethodHandle combinators, we need to reserve a few empty slots on the parameter lists to capture the temporal results. This is why bootstrap methods in this factory do not accept more than 200 argument slots. Users requiring more than 200 argument slots in concatenation are expected to split the large concatenation in smaller expressions.

Authors
Aleksey Shipilev, Remi Forax, Peter Levart
Since
9

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
StringConcatFactory.SimpleStringBuilderStrategy

Bytecode StringBuilder strategy.

Field Summary

Modifier and TypeField and Description
private static final int
private static MethodHandle
private static final int
private static MethodHandle
private static final MethodHandle[][]
private static final MethodHandle[][]
private static MethodHandle
private static MethodHandle
private static final int
private static final long
private static final int
private static MethodHandle
private static final JavaLangAccess
private static final int
private static MethodHandle
private static final int
MAX_INDY_CONCAT_ARG_SLOTS

Maximum number of argument slots in String Concat call.

private static final int[]
private static final int[]
private static final int[]
private static final MethodHandle[]
private static MethodHandle
private static MethodHandle
private static MethodHandle
private static MethodHandle
private static final MethodHandle[]
private static MethodHandle
OBJECT_STRINGIFIER

Public gateways to public "stringify" methods.

private static MethodHandle
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final MethodHandle[]
private static MethodHandle
private static final int
private static final char
TAG_ARG

Tag used to demarcate an ordinary argument.

private static final char
TAG_CONST

Tag used to demarcate a constant.

private static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static StringConcatException
argumentMismatch(MethodType concatType, int oCount)

private static MethodHandle
private static MethodHandle
private static int
private static StringConcatException
constantMismatch(Object[] constants, int cCount)

private static MethodHandle
private static MethodHandle
filterAndFoldInMixers(MethodHandle mh, long initialLengthCoder, Class<?>[] ptypes)

private static MethodHandle
filterInPrependers(MethodHandle mh, String[] constants, Class<?>[] ptypes)

pack-priv static int[]
filterMixerArgPositions(int[] argPositions, int pos, int count)

pack-priv static int[]
filterPrependArgPositions(int[] argPositions, int pos, int count)

private static MethodHandle
private static MethodHandle
foldInLastMixers(MethodHandle mh, long initialLengthCoder, int pos, Class<?>[] ptypes, int count)

private static MethodHandle
generateMHInlineCopy(MethodType mt, String[] constants)

This strategy replicates what StringBuilders are doing: it builds the byte[] array on its own and passes that byte[] array to String constructor.

private static MethodHandle
private static MethodHandle
public static CallSite

Returns:

a CallSite whose target can be used to perform String concatenation, with dynamic concatenation arguments described by the given concatType.
makeConcat
(MethodHandles.Lookup
Represents a lookup context with the accessibility privileges of the caller. Specifically, the lookup context must have full privilege access. When used with invokedynamic, this is stacked automatically by the VM.
lookup
,
String
The name of the method to implement. This name is arbitrary, and has no meaning for this linkage method. When used with invokedynamic, this is provided by the NameAndType of the InvokeDynamic structure and is stacked automatically by the VM.
name
,
MethodType
The expected signature of the CallSite. The parameter types represent the types of concatenation arguments; the return type is always assignable from java.lang.String. When used with invokedynamic, this is provided by the NameAndType of the InvokeDynamic structure and is stacked automatically by the VM.
concatType
)

Facilitates the creation of optimized String concatenation methods, that can be used to efficiently concatenate a known number of arguments of known types, possibly after type adaptation and partial evaluation of arguments.

public static CallSite

Returns:

a CallSite whose target can be used to perform String concatenation, with dynamic concatenation arguments described by the given concatType.
makeConcatWithConstants
(MethodHandles.Lookup
Represents a lookup context with the accessibility privileges of the caller. Specifically, the lookup context must have full privilege access. When used with invokedynamic, this is stacked automatically by the VM.
lookup
,
String
The name of the method to implement. This name is arbitrary, and has no meaning for this linkage method. When used with invokedynamic, this is provided by the NameAndType of the InvokeDynamic structure and is stacked automatically by the VM.
name
,
MethodType
The expected signature of the CallSite. The parameter types represent the types of dynamic concatenation arguments; the return type is always assignable from java.lang.String. When used with invokedynamic, this is provided by the NameAndType of the InvokeDynamic structure and is stacked automatically by the VM.
concatType
,
String
Concatenation recipe, described above.
recipe
,
Object...
A vararg parameter representing the constants passed to the linkage method.
constants
)

Facilitates the creation of optimized String concatenation methods, that can be used to efficiently concatenate a known number of arguments of known types, possibly after type adaptation and partial evaluation of arguments.

private static MethodHandle
mixer(Class<?> cl)

private static MethodHandle
mixer(Class<?> cl, Class<?> cl2)

private static MethodHandle
mixer(Class<?> cl, Class<?> cl2, Class<?> cl3)

private static MethodHandle
mixer(Class<?> cl, Class<?> cl2, Class<?> cl3, Class<?> cl4)

private static MethodHandle
private static MethodHandle
private static MethodHandle
private static MethodHandle
private static MethodHandle
private static MethodHandle
private static String[]
parseRecipe(MethodType concatType, String recipe, Object[] constants)

private static MethodHandle
private static MethodHandle
prepender(String prefix, Class<?> cl)

private static MethodHandle
private static MethodHandle
prepender(String prefix, Class<?> cl, String prefix2, Class<?> cl2)

private static MethodHandle
prepender(int pos, String[] constants, Class<?>[] ptypes, int count)

private static Class<?>
promoteToIntType(Class<?> t)

Promote integral types to int.

private static MethodHandle
private static MethodHandle

Returns:

stringifier; null, if not available
stringifierFor
(Class<?>
class to stringify
t
)

Returns a stringifier for references and floats/doubles only.

private static MethodHandle
stringValueOf(Class<?> ptype)

private static MethodHandle
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BOOLEAN_IDXback to summary
private static final int BOOLEAN_IDX
BOOLEAN_STRINGIFIERback to summary
private static MethodHandle BOOLEAN_STRINGIFIER
Annotations
@Stable
CHAR_IDXback to summary
private static final int CHAR_IDX
CHAR_STRINGIFIERback to summary
private static MethodHandle CHAR_STRINGIFIER
Annotations
@Stable
DOUBLE_MIXERSback to summary
private static final MethodHandle[][] DOUBLE_MIXERS
Annotations
@Stable
DOUBLE_PREPENDERSback to summary
private static final MethodHandle[][] DOUBLE_PREPENDERS
Annotations
@Stable
DOUBLE_STRINGIFIERback to summary
private static MethodHandle DOUBLE_STRINGIFIER
Annotations
@Stable
FLOAT_STRINGIFIERback to summary
private static MethodHandle FLOAT_STRINGIFIER
Annotations
@Stable
HIGH_ARITY_THRESHOLDback to summary
private static final int HIGH_ARITY_THRESHOLD
INITIAL_CODERback to summary
private static final long INITIAL_CODER
INT_IDXback to summary
private static final int INT_IDX
INT_STRINGIFIERback to summary
private static MethodHandle INT_STRINGIFIER
Annotations
@Stable
JLAback to summary
private static final JavaLangAccess JLA
LONG_IDXback to summary
private static final int LONG_IDX
LONG_STRINGIFIERback to summary
private static MethodHandle LONG_STRINGIFIER
Annotations
@Stable
MAX_INDY_CONCAT_ARG_SLOTSback to summary
private static final int MAX_INDY_CONCAT_ARG_SLOTS

Maximum number of argument slots in String Concat call. While the maximum number of argument slots that indy call can handle is 253, we do not use all those slots, to let the strategies with MethodHandle combinators to use some arguments.

MIX_FILTER_SECOND_ARGSback to summary
private static final int[] MIX_FILTER_SECOND_ARGS
MIX_FILTER_SECOND_PAIR_ARGSback to summary
private static final int[] MIX_FILTER_SECOND_PAIR_ARGS
MIX_FILTER_THIRD_ARGSback to summary
private static final int[] MIX_FILTER_THIRD_ARGS
MIXERSback to summary
private static final MethodHandle[] MIXERS
Annotations
@Stable
NEW_ARRAYback to summary
private static MethodHandle NEW_ARRAY
Annotations
@Stable
NEW_ARRAY_SUFFIXback to summary
private static MethodHandle NEW_ARRAY_SUFFIX
Annotations
@Stable
NEW_STRINGback to summary
private static MethodHandle NEW_STRING
Annotations
@Stable
NEW_STRINGIFIERback to summary
private static MethodHandle NEW_STRINGIFIER
Annotations
@Stable
NO_PREFIX_PREPENDERSback to summary
private static final MethodHandle[] NO_PREFIX_PREPENDERS
Annotations
@Stable
OBJECT_STRINGIFIERback to summary
private static MethodHandle OBJECT_STRINGIFIER

Public gateways to public "stringify" methods. These methods have the form String apply(T obj), and normally delegate to String.valueOf, depending on argument's type.

Annotations
@Stable
PREPEND_BASEback to summary
private static MethodHandle PREPEND_BASE
Annotations
@Stable
PREPEND_FILTER_FIRST_ARGSback to summary
private static final int[] PREPEND_FILTER_FIRST_ARGS
PREPEND_FILTER_FIRST_PAIR_ARGSback to summary
private static final int[] PREPEND_FILTER_FIRST_PAIR_ARGS
PREPEND_FILTER_SECOND_ARGSback to summary
private static final int[] PREPEND_FILTER_SECOND_ARGS
PREPEND_FILTER_SECOND_PAIR_ARGSback to summary
private static final int[] PREPEND_FILTER_SECOND_PAIR_ARGS
PREPEND_FILTER_THIRD_ARGSback to summary
private static final int[] PREPEND_FILTER_THIRD_ARGS
PREPENDERSback to summary
private static final MethodHandle[] PREPENDERS
Annotations
@Stable
SIMPLE_CONCATback to summary
private static MethodHandle SIMPLE_CONCAT
Annotations
@Stable
STRING_IDXback to summary
private static final int STRING_IDX
TAG_ARGback to summary
private static final char TAG_ARG

Tag used to demarcate an ordinary argument.

TAG_CONSTback to summary
private static final char TAG_CONST

Tag used to demarcate a constant.

TYPE_COUNTback to summary
private static final int TYPE_COUNT

Constructor Detail

StringConcatFactoryback to summary
private StringConcatFactory()

Method Detail

argumentMismatchback to summary
private static StringConcatException argumentMismatch(MethodType concatType, int oCount)
booleanStringifierback to summary
private static MethodHandle booleanStringifier()
charStringifierback to summary
private static MethodHandle charStringifier()
classIndexback to summary
private static int classIndex(Class<?> cl)
constantMismatchback to summary
private static StringConcatException constantMismatch(Object[] constants, int cCount)
doubleStringifierback to summary
private static MethodHandle doubleStringifier()
filterAndFoldInMixersback to summary
private static MethodHandle filterAndFoldInMixers(MethodHandle mh, long initialLengthCoder, Class<?>[] ptypes)
filterInPrependersback to summary
private static MethodHandle filterInPrependers(MethodHandle mh, String[] constants, Class<?>[] ptypes)
filterMixerArgPositionsback to summary
pack-priv static int[] filterMixerArgPositions(int[] argPositions, int pos, int count)
filterPrependArgPositionsback to summary
pack-priv static int[] filterPrependArgPositions(int[] argPositions, int pos, int count)
floatStringifierback to summary
private static MethodHandle floatStringifier()
foldInLastMixersback to summary
private static MethodHandle foldInLastMixers(MethodHandle mh, long initialLengthCoder, int pos, Class<?>[] ptypes, int count)
generateMHInlineCopyback to summary
private static MethodHandle generateMHInlineCopy(MethodType mt, String[] constants)

This strategy replicates what StringBuilders are doing: it builds the byte[] array on its own and passes that byte[] array to String constructor. This strategy requires access to some private APIs in JDK, most notably, the private String constructor that accepts byte[] arrays without copying.

intStringifierback to summary
private static MethodHandle intStringifier()
longStringifierback to summary
private static MethodHandle longStringifier()
makeConcatback to summary
public static CallSite makeConcat(MethodHandles.Lookup lookup, String name, MethodType concatType) throws StringConcatException

Facilitates the creation of optimized String concatenation methods, that can be used to efficiently concatenate a known number of arguments of known types, possibly after type adaptation and partial evaluation of arguments. Typically used as a bootstrap method for invokedynamic call sites, to support the string concatenation feature of the Java Programming Language.

When the target of the CallSite returned from this method is invoked, it returns the result of String concatenation, taking all function arguments passed to the linkage method as inputs for concatenation. The target signature is given by concatType. For a target accepting:

  • zero inputs, concatenation results in an empty string;
  • one input, concatenation results in the single input converted as per JLS 5.1.11 "String Conversion"; otherwise
  • two or more inputs, the inputs are concatenated as per requirements stated in JLS 15.18.1 "String Concatenation Operator +". The inputs are converted as per JLS 5.1.11 "String Conversion", and combined from left to right.

Assume the linkage arguments are as follows:

  • concatType, describing the CallSite signature

Then the following linkage invariants must hold:

  • The number of parameter slots in concatType is less than or equal to 200
  • The return type in concatType is assignable from java.lang.String
Parameters
lookup:MethodHandles.Lookup

Represents a lookup context with the accessibility privileges of the caller. Specifically, the lookup context must have full privilege access. When used with invokedynamic, this is stacked automatically by the VM.

name:String

The name of the method to implement. This name is arbitrary, and has no meaning for this linkage method. When used with invokedynamic, this is provided by the NameAndType of the InvokeDynamic structure and is stacked automatically by the VM.

concatType:MethodType

The expected signature of the CallSite. The parameter types represent the types of concatenation arguments; the return type is always assignable from java.lang.String. When used with invokedynamic, this is provided by the NameAndType of the InvokeDynamic structure and is stacked automatically by the VM.

Returns:CallSite

a CallSite whose target can be used to perform String concatenation, with dynamic concatenation arguments described by the given concatType.

Exceptions
StringConcatException:
If any of the linkage invariants described here are violated, or the lookup context does not have private access privileges.
NullPointerException:
If any of the incoming arguments is null. This will never happen when a bootstrap method is called with invokedynamic.
Java Language Specification
5.1.11 String Conversion, 15.18.1 String Concatenation Operator +
makeConcatWithConstantsback to summary
public static CallSite makeConcatWithConstants(MethodHandles.Lookup lookup, String name, MethodType concatType, String recipe, Object... constants) throws StringConcatException

Facilitates the creation of optimized String concatenation methods, that can be used to efficiently concatenate a known number of arguments of known types, possibly after type adaptation and partial evaluation of arguments. Typically used as a bootstrap method for invokedynamic call sites, to support the string concatenation feature of the Java Programming Language.

When the target of the CallSite returned from this method is invoked, it returns the result of String concatenation, taking all function arguments and constants passed to the linkage method as inputs for concatenation. The target signature is given by concatType, and does not include constants. For a target accepting:

  • zero inputs, concatenation results in an empty string;
  • one input, concatenation results in the single input converted as per JLS 5.1.11 "String Conversion"; otherwise
  • two or more inputs, the inputs are concatenated as per requirements stated in JLS 15.18.1 "String Concatenation Operator +". The inputs are converted as per JLS 5.1.11 "String Conversion", and combined from left to right.

The concatenation recipe is a String description for the way to construct a concatenated String from the arguments and constants. The recipe is processed from left to right, and each character represents an input to concatenation. Recipe characters mean:

  • \1 (Unicode point 0001): an ordinary argument. This input is passed through dynamic argument, and is provided during the concatenation method invocation. This input can be null.
  • \2 (Unicode point 0002): a constant. This input passed through static bootstrap argument. This constant can be any value representable in constant pool. If necessary, the factory would call toString to perform a one-time String conversion.
  • Any other char value: a single character constant.

Assume the linkage arguments are as follows:

  • concatType, describing the CallSite signature
  • recipe, describing the String recipe
  • constants, the vararg array of constants

Then the following linkage invariants must hold:

  • The number of parameter slots in concatType is less than or equal to 200
  • The parameter count in concatType is equal to number of \1 tags in recipe
  • The return type in concatType is assignable from java.lang.String, and matches the return type of the returned MethodHandle
  • The number of elements in constants is equal to number of \2 tags in recipe

API Note

Code generators have three distinct ways to process a constant string operand S in a string concatenation expression. First, S can be materialized as a reference (using ldc) and passed as an ordinary argument (recipe '\1'). Or, S can be stored in the constant pool and passed as a constant (recipe '\2') . Finally, if S contains neither of the recipe tag characters ('\1', '\2') then S can be interpolated into the recipe itself, causing its characters to be inserted into the result.

Parameters
lookup:MethodHandles.Lookup

Represents a lookup context with the accessibility privileges of the caller. Specifically, the lookup context must have full privilege access. When used with invokedynamic, this is stacked automatically by the VM.

name:String

The name of the method to implement. This name is arbitrary, and has no meaning for this linkage method. When used with invokedynamic, this is provided by the NameAndType of the InvokeDynamic structure and is stacked automatically by the VM.

concatType:MethodType

The expected signature of the CallSite. The parameter types represent the types of dynamic concatenation arguments; the return type is always assignable from java.lang.String. When used with invokedynamic, this is provided by the NameAndType of the InvokeDynamic structure and is stacked automatically by the VM.

recipe:String

Concatenation recipe, described above.

constants:Object[]

A vararg parameter representing the constants passed to the linkage method.

Returns:CallSite

a CallSite whose target can be used to perform String concatenation, with dynamic concatenation arguments described by the given concatType.

Exceptions
StringConcatException:
If any of the linkage invariants described here are violated, or the lookup context does not have private access privileges.
NullPointerException:
If any of the incoming arguments is null, or any constant in recipe is null. This will never happen when a bootstrap method is called with invokedynamic.
Java Language Specification
5.1.11 String Conversion, 15.18.1 String Concatenation Operator +
mixerback to summary
private static MethodHandle mixer(Class<?> cl)
mixerback to summary
private static MethodHandle mixer(Class<?> cl, Class<?> cl2)
mixerback to summary
private static MethodHandle mixer(Class<?> cl, Class<?> cl2, Class<?> cl3)
mixerback to summary
private static MethodHandle mixer(Class<?> cl, Class<?> cl2, Class<?> cl3, Class<?> cl4)
newArrayback to summary
private static MethodHandle newArray()
newArrayWithSuffixback to summary
private static MethodHandle newArrayWithSuffix(String suffix)
newStringback to summary
private static MethodHandle newString()
newStringifierback to summary
private static MethodHandle newStringifier()
noPrefixPrependerback to summary
private static MethodHandle noPrefixPrepender(Class<?> cl)
objectStringifierback to summary
private static MethodHandle objectStringifier()
parseRecipeback to summary
private static String[] parseRecipe(MethodType concatType, String recipe, Object[] constants) throws StringConcatException
prependBaseback to summary
private static MethodHandle prependBase()
prependerback to summary
private static MethodHandle prepender(String prefix, Class<?> cl)
prependerback to summary
private static MethodHandle prepender(Class<?> cl)
prependerback to summary
private static MethodHandle prepender(String prefix, Class<?> cl, String prefix2, Class<?> cl2)
prependerback to summary
private static MethodHandle prepender(int pos, String[] constants, Class<?>[] ptypes, int count)
promoteToIntTypeback to summary
private static Class<?> promoteToIntType(Class<?> t)

Promote integral types to int.

simpleConcatback to summary
private static MethodHandle simpleConcat()
stringifierForback to summary
private static MethodHandle stringifierFor(Class<?> t)

Returns a stringifier for references and floats/doubles only. Always returns null for other primitives.

Parameters
t:Class<?>

class to stringify

Returns:MethodHandle

stringifier; null, if not available

stringValueOfback to summary
private static MethodHandle stringValueOf(Class<?> ptype)
unaryConcatback to summary
private static MethodHandle unaryConcat(Class<?> cl)
java.lang.invoke back to summary

private final Class StringConcatFactory.SimpleStringBuilderStrategy

extends Object
Class Inheritance
  • java.lang.Object
  • java.lang.invoke.StringConcatFactory.SimpleStringBuilderStrategy

Bytecode StringBuilder strategy.

This strategy emits StringBuilder chains as similar as possible to what javac would. No exact sizing of parameters or estimates.

Field Summary

Modifier and TypeField and Description
pack-priv static final MethodTypeDesc
pack-priv static final MethodTypeDesc
pack-priv static final MethodTypeDesc
pack-priv static final MethodTypeDesc
pack-priv static final MethodTypeDesc
pack-priv static final MethodTypeDesc
pack-priv static final MethodTypeDesc
pack-priv static final MethodTypeDesc
pack-priv static final int
ARGUMENT_SIZE_FACTOR

Ensure a capacity in the initial StringBuilder to accommodate all constants plus this factor times the number of arguments.

pack-priv static final ClassFileDumper
pack-priv static final MethodTypeDesc
pack-priv static final String
pack-priv static final Set<MethodHandles.Lookup.ClassOption>
pack-priv static final ClassDesc
pack-priv static final MethodTypeDesc

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static MethodHandle
generate(MethodHandles.Lookup lookup, MethodType args, String[] constants)

private static Consumer<CodeBuilder>
generateMethod(String[] constants, MethodType args)

private static String
getClassName(Class<?> hostClass)

The generated class is in the same package as the host class as it's the implementation of the string concatenation for the host class.

private static MethodTypeDesc
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

APPEND_BOOLEAN_TYPEback to summary
pack-priv static final MethodTypeDesc APPEND_BOOLEAN_TYPE
APPEND_CHAR_TYPEback to summary
pack-priv static final MethodTypeDesc APPEND_CHAR_TYPE
APPEND_DOUBLE_TYPEback to summary
pack-priv static final MethodTypeDesc APPEND_DOUBLE_TYPE
APPEND_FLOAT_TYPEback to summary
pack-priv static final MethodTypeDesc APPEND_FLOAT_TYPE
APPEND_INT_TYPEback to summary
pack-priv static final MethodTypeDesc APPEND_INT_TYPE
APPEND_LONG_TYPEback to summary
pack-priv static final MethodTypeDesc APPEND_LONG_TYPE
APPEND_OBJECT_TYPEback to summary
pack-priv static final MethodTypeDesc APPEND_OBJECT_TYPE
APPEND_STRING_TYPEback to summary
pack-priv static final MethodTypeDesc APPEND_STRING_TYPE
ARGUMENT_SIZE_FACTORback to summary
pack-priv static final int ARGUMENT_SIZE_FACTOR

Ensure a capacity in the initial StringBuilder to accommodate all constants plus this factor times the number of arguments.

DUMPERback to summary
pack-priv static final ClassFileDumper DUMPER
INT_CONSTRUCTOR_TYPEback to summary
pack-priv static final MethodTypeDesc INT_CONSTRUCTOR_TYPE
METHOD_NAMEback to summary
pack-priv static final String METHOD_NAME
SET_OF_STRONGback to summary
pack-priv static final Set<MethodHandles.Lookup.ClassOption> SET_OF_STRONG
STRING_BUILDERback to summary
pack-priv static final ClassDesc STRING_BUILDER
TO_STRING_TYPEback to summary
pack-priv static final MethodTypeDesc TO_STRING_TYPE

Constructor Detail

SimpleStringBuilderStrategyback to summary
private SimpleStringBuilderStrategy()

Method Detail

generateback to summary
private static MethodHandle generate(MethodHandles.Lookup lookup, MethodType args, String[] constants) throws Exception
generateMethodback to summary
private static Consumer<CodeBuilder> generateMethod(String[] constants, MethodType args)
getClassNameback to summary
private static String getClassName(Class<?> hostClass)

The generated class is in the same package as the host class as it's the implementation of the string concatenation for the host class.

getSBAppendDescback to summary
private static MethodTypeDesc getSBAppendDesc(Class<?> cl)