APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.util

public final Class ModifiedUtf

extends Object
Class Inheritance
Imports
jdk.internal.vm.annotation.ForceInline

Utilities for string encoding and decoding with the Modified UTF-8 format.

Field Summary

Modifier and TypeField and Description
public static final int
CONSTANT_POOL_UTF8_MAX_BYTES

Maximum number of bytes allowed for a Modified UTF-8 encoded string in a java.lang.classfile.constantpool.Utf8Entry or a hotspot Symbol.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean
isValidLengthInConstantPool(String
input string
str
)

Checks whether an input String can be encoded in a java.lang.classfile.constantpool.Utf8Entry, or represented as a hotspot Symbol (which has the same length limit).

public static int
putChar(byte[] buf, int offset, char c)

Writes a char to the pre-sized modified UTF buffer.

public static long
utfLen(String
input string
str
)

Calculate the encoded length of an input String.

public static long
utfLen(String
input string
str
,
int
the number of non-zero ascii characters in the prefix calculated by JLA.countNonZeroAscii(str)
countNonZeroAscii
)

Calculate the encoded length of trailing parts of an input String, after jdk.internal.access.JavaLangAccess#countNonZeroAscii(String) calculates the number of contiguous single-byte characters in the beginning of the string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONSTANT_POOL_UTF8_MAX_BYTESback to summary
public static final int CONSTANT_POOL_UTF8_MAX_BYTES

Maximum number of bytes allowed for a Modified UTF-8 encoded string in a java.lang.classfile.constantpool.Utf8Entry or a hotspot Symbol.

Constructor Detail

ModifiedUtfback to summary
private ModifiedUtf()

Method Detail

isValidLengthInConstantPoolback to summary
public static boolean isValidLengthInConstantPool(String str)

Checks whether an input String can be encoded in a java.lang.classfile.constantpool.Utf8Entry, or represented as a hotspot Symbol (which has the same length limit).

Parameters
str:String

input string

Annotations
@ForceInline
putCharback to summary
public static int putChar(byte[] buf, int offset, char c)

Writes a char to the pre-sized modified UTF buffer.

Annotations
@ForceInline
utfLenback to summary
public static long utfLen(String str)

Calculate the encoded length of an input String. For many workloads that have fast paths for ASCII-only prefixes, utfLen(String, int) skips scanning that prefix.

Parameters
str:String

input string

utfLenback to summary
public static long utfLen(String str, int countNonZeroAscii)

Calculate the encoded length of trailing parts of an input String, after jdk.internal.access.JavaLangAccess#countNonZeroAscii(String) calculates the number of contiguous single-byte characters in the beginning of the string.

Parameters
str:String

input string

countNonZeroAscii:int

the number of non-zero ascii characters in the prefix calculated by JLA.countNonZeroAscii(str)

Annotations
@ForceInline