APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.lang

pack-priv final Class StringConcatHelper

extends Object
Class Inheritance
Imports
jdk.internal.misc.Unsafe, jdk.internal.util.DecimalDigits, jdk.internal.vm.annotation.ForceInline, .Stable, java.lang.invoke.MethodHandle, .MethodHandles, .MethodType

Helper for string concatenation. These methods are mostly looked up with private lookups from java.lang.invoke.StringConcatFactory, and used in java.lang.invoke.MethodHandle combinators there.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv abstract static class

Field Summary

Modifier and TypeField and Description
private static final Unsafe

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static int

Returns:

the given parameter value, if valid
checkOverflow
(int value)

Check for overflow, throw exception on overflow.

pack-priv static String
concat(String prefix, Object value, String suffix)

private static String
concat0(String prefix, String str, String suffix)

pack-priv static String

Returns:

String resulting string
doConcat
(String
first argument
s1
,
String
second argument
s2
)

Perform a simple concatenation between two non-empty strings.

pack-priv static MethodHandle
lookupStatic(String name, MethodType methodType)

pack-priv static byte[]

Returns:

the newly allocated byte array
newArray
(int length)

Allocates an uninitialized byte array based on the length

pack-priv static byte[]

Returns:

the newly allocated byte array
newArrayWithSuffix
(String suffix, int
final char index in the buffer
index
,
byte
coder of the buffer
coder
)

Allocates an uninitialized byte array based on the length and coder information, then prepends the given suffix string at the end of the byte array before returning it.

pack-priv static String

Returns:

String resulting string
newStringOf
(Object
the only argument
arg
)

Produce a String from a concatenation of single argument, which we end up using for trivial concatenations like "" + arg.

pack-priv static int

Returns:

updated index
prepend
(int
final char index in the buffer
index
,
byte
coder of the buffer
coder
,
byte[]
buffer to append to
buf
,
boolean
boolean value to encode
value
,
String
a constant to prepend before value
prefix
)

Prepends constant and the stringly representation of value into buffer, given the coder and final index.

pack-priv static int

Returns:

updated index
prepend
(int
final char index in the buffer
index
,
byte
coder of the buffer
coder
,
byte[]
buffer to append to
buf
,
char
char value to encode
value
,
String
a constant to prepend before value
prefix
)

Prepends constant and the stringly representation of value into buffer, given the coder and final index.

pack-priv static int

Returns:

updated index
prepend
(int
final char index in the buffer
index
,
byte
coder of the buffer
coder
,
byte[]
buffer to append to
buf
,
int
int value to encode
value
,
String
a constant to prepend before value
prefix
)

Prepends constant and the stringly representation of value into buffer, given the coder and final index.

pack-priv static int

Returns:

updated index
prepend
(int
final char index in the buffer
index
,
byte
coder of the buffer
coder
,
byte[]
buffer to append to
buf
,
long
long value to encode
value
,
String
a constant to prepend before value
prefix
)

Prepends constant and the stringly representation of value into buffer, given the coder and final index.

pack-priv static int

Returns:

updated index
prepend
(int
final char index in the buffer
index
,
byte
coder of the buffer
coder
,
byte[]
buffer to append to
buf
,
String
boolean value to encode
value
,
String
a constant to prepend before value
prefix
)

Prepends constant and the stringly representation of value into buffer, given the coder and final index.

pack-priv static String

Returns:

String resulting string
simpleConcat
(Object
first argument
first
,
Object
second argument
second
)

Perform a simple concatenation between two objects.

pack-priv static byte

Returns:

coder
stringCoder
(char
character
value
)

Return the coder for the character.

pack-priv static String
stringOf(Object value)

We need some additional conversion for Objects in general, because String.valueOf(Object) may return null.

pack-priv static String
stringOf(float value)

pack-priv static String
stringOf(double value)

pack-priv static int

Returns:

new length
stringSize
(int
length
length
,
char
value to add stringSize
value
)

return add stringSize of value

pack-priv static int

Returns:

new length
stringSize
(int
length
length
,
boolean
value to add stringSize
value
)

return add stringSize of value

pack-priv static int

Returns:

new length
stringSize
(int
length
length
,
int
value
value
)

return add stringSize of value

pack-priv static int

Returns:

new length
stringSize
(int
length
length
,
long
value to add stringSize
value
)

return add stringSize of value

pack-priv static int

Returns:

new length
stringSize
(int
length
length
,
String
value to add stringSize
value
)

return add stringSize of value

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

UNSAFEback to summary
private static final Unsafe UNSAFE

Constructor Detail

StringConcatHelperback to summary
private StringConcatHelper()

Method Detail

checkOverflowback to summary
pack-priv static int checkOverflow(int value)

Check for overflow, throw exception on overflow.

Returns:int

the given parameter value, if valid

Annotations
@ForceInline
concatback to summary
pack-priv static String concat(String prefix, Object value, String suffix)
Annotations
@ForceInline
concat0back to summary
private static String concat0(String prefix, String str, String suffix)
Annotations
@ForceInline
doConcatback to summary
pack-priv static String doConcat(String s1, String s2)

Perform a simple concatenation between two non-empty strings.

Parameters
s1:String

first argument

s2:String

second argument

Returns:String

String resulting string

Annotations
@ForceInline
lookupStaticback to summary
pack-priv static MethodHandle lookupStatic(String name, MethodType methodType)
newArrayback to summary
pack-priv static byte[] newArray(int length)

Allocates an uninitialized byte array based on the length

Returns:byte[]

the newly allocated byte array

Annotations
@ForceInline
newArrayWithSuffixback to summary
pack-priv static byte[] newArrayWithSuffix(String suffix, int index, byte coder)

Allocates an uninitialized byte array based on the length and coder information, then prepends the given suffix string at the end of the byte array before returning it. The calling code must adjust the indexCoder so that it's taken the coder of the suffix into account, but subtracted the length of the suffix.

Parameters
index:int

final char index in the buffer

coder:byte

coder of the buffer

Returns:byte[]

the newly allocated byte array

Annotations
@ForceInline
newStringOfback to summary
pack-priv static String newStringOf(Object arg)

Produce a String from a concatenation of single argument, which we end up using for trivial concatenations like "" + arg. This will always create a new Object to comply with JLS 15.18.1: "The String object is newly created unless the expression is a compile-time constant expression".

Parameters
arg:Object

the only argument

Returns:String

String resulting string

Annotations
@ForceInline
prependback to summary
pack-priv static int prepend(int index, byte coder, byte[] buf, boolean value, String prefix)

Prepends constant and the stringly representation of value into buffer, given the coder and final index. Index is measured in chars, not in bytes!

Parameters
index:int

final char index in the buffer

coder:byte

coder of the buffer

buf:byte[]

buffer to append to

value:boolean

boolean value to encode

prefix:String

a constant to prepend before value

Returns:int

updated index

prependback to summary
pack-priv static int prepend(int index, byte coder, byte[] buf, char value, String prefix)

Prepends constant and the stringly representation of value into buffer, given the coder and final index. Index is measured in chars, not in bytes!

Parameters
index:int

final char index in the buffer

coder:byte

coder of the buffer

buf:byte[]

buffer to append to

value:char

char value to encode

prefix:String

a constant to prepend before value

Returns:int

updated index

prependback to summary
pack-priv static int prepend(int index, byte coder, byte[] buf, int value, String prefix)

Prepends constant and the stringly representation of value into buffer, given the coder and final index. Index is measured in chars, not in bytes!

Parameters
index:int

final char index in the buffer

coder:byte

coder of the buffer

buf:byte[]

buffer to append to

value:int

int value to encode

prefix:String

a constant to prepend before value

Returns:int

updated index

prependback to summary
pack-priv static int prepend(int index, byte coder, byte[] buf, long value, String prefix)

Prepends constant and the stringly representation of value into buffer, given the coder and final index. Index is measured in chars, not in bytes!

Parameters
index:int

final char index in the buffer

coder:byte

coder of the buffer

buf:byte[]

buffer to append to

value:long

long value to encode

prefix:String

a constant to prepend before value

Returns:int

updated index

prependback to summary
pack-priv static int prepend(int index, byte coder, byte[] buf, String value, String prefix)

Prepends constant and the stringly representation of value into buffer, given the coder and final index. Index is measured in chars, not in bytes!

Parameters
index:int

final char index in the buffer

coder:byte

coder of the buffer

buf:byte[]

buffer to append to

value:String

boolean value to encode

prefix:String

a constant to prepend before value

Returns:int

updated index

simpleConcatback to summary
pack-priv static String simpleConcat(Object first, Object second)

Perform a simple concatenation between two objects. Added for startup performance, but also demonstrates the code that would be emitted by java.lang.invoke.StringConcatFactory$MethodHandleInlineCopyStrategy for two Object arguments.

Parameters
first:Object

first argument

second:Object

second argument

Returns:String

String resulting string

Annotations
@ForceInline
stringCoderback to summary
pack-priv static byte stringCoder(char value)

Return the coder for the character.

Parameters
value:char

character

Returns:byte

coder

stringOfback to summary
pack-priv static String stringOf(Object value)

We need some additional conversion for Objects in general, because String.valueOf(Object) may return null. String conversion rules in Java state we need to produce "null" String in this case, so we provide a customized version that deals with this problematic corner case.

stringOfback to summary
pack-priv static String stringOf(float value)
stringOfback to summary
pack-priv static String stringOf(double value)
stringSizeback to summary
pack-priv static int stringSize(int length, char value)

return add stringSize of value

Parameters
length:int

length

value:char

value to add stringSize

Returns:int

new length

stringSizeback to summary
pack-priv static int stringSize(int length, boolean value)

return add stringSize of value

Parameters
length:int

length

value:boolean

value to add stringSize

Returns:int

new length

stringSizeback to summary
pack-priv static int stringSize(int length, int value)

return add stringSize of value

Parameters
length:int

length

value:int

value

Returns:int

new length

stringSizeback to summary
pack-priv static int stringSize(int length, long value)

return add stringSize of value

Parameters
length:int

length

value:long

value to add stringSize

Returns:int

new length

stringSizeback to summary
pack-priv static int stringSize(int length, String value)

return add stringSize of value

Parameters
length:int

length

value:String

value to add stringSize

Returns:int

new length

java.lang back to summary

pack-priv final Class StringConcatHelper.Concat1

extends StringConcatBase
Class Inheritance

Field Summary

Inherited from java.lang.StringConcatHelper.StringConcatBase:
coderconstantslength

Constructor Summary

AccessConstructor and Description
pack-priv
Concat1(String[] constants)

Method Summary

Modifier and TypeMethod and Description
pack-priv String
concat(boolean value)

pack-priv String
concat(char value)

pack-priv String
concat(int value)

pack-priv String
concat(long value)

pack-priv String
concat(Object value)

pack-priv String
concat(float value)

pack-priv String
concat(double value)

pack-priv String
concat0(String value)

Constructor Detail

Concat1back to summary
pack-priv Concat1(String[] constants)

Method Detail

concatback to summary
pack-priv String concat(boolean value)
Annotations
@ForceInline
concatback to summary
pack-priv String concat(char value)
Annotations
@ForceInline
concatback to summary
pack-priv String concat(int value)
Annotations
@ForceInline
concatback to summary
pack-priv String concat(long value)
Annotations
@ForceInline
concatback to summary
pack-priv String concat(Object value)
Annotations
@ForceInline
concatback to summary
pack-priv String concat(float value)
Annotations
@ForceInline
concatback to summary
pack-priv String concat(double value)
Annotations
@ForceInline
concat0back to summary
pack-priv String concat0(String value)
Annotations
@ForceInline
java.lang back to summary

pack-priv abstract Class StringConcatHelper.StringConcatBase

extends Object
Class Inheritance
Known Direct Subclasses
java.lang.StringConcatHelper.Concat1

Field Summary

Modifier and TypeField and Description
pack-priv final byte
pack-priv final String[]
pack-priv final int

Constructor Summary

AccessConstructor and Description
pack-priv
StringConcatBase(String[] constants)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

coderback to summary
pack-priv final byte coder
constantsback to summary
pack-priv final String[] constants
Annotations
@Stable
lengthback to summary
pack-priv final int length

Constructor Detail

StringConcatBaseback to summary
pack-priv StringConcatBase(String[] constants)