Top Inners Fields Constructors Methods
jdk.internal.vm

public Class VMSupport

extends Object
Class Inheritance
Imports
jdk.internal.misc.Unsafe, .VM, jdk.internal.access.SharedSecrets, .JavaLangAccess, jdk.internal.reflect.ConstantPool, sun.reflect.annotation.AnnotationParser, .AnnotationSupport, .AnnotationType, java.io.ByteArrayInputStream, .ByteArrayOutputStream, .DataInputStream, .DataOutputStream, .IOException, java.lang.annotation.Annotation, .IncompleteAnnotationException, java.nio.charset.StandardCharsets, java.util.Collection, .LinkedHashMap, .Map, .Properties, .Set, .List

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
VMSupport.AnnotationDecoder<
type to which a type name is resolved
T
,
type of the object representing a decoded annotation
A
,
type of the object representing a decoded enum constant
E
,
type of the object representing a decoded error
X
>

Helper for decodeAnnotations(byte[], AnnotationDecoder) to convert a byte array (ostensibly produced by VMSupport#encodeAnnotations) into objects.

pack-priv static interface

Field Summary

Modifier and TypeField and Description
private static Properties
private static final Unsafe
U

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static byte[]
bufferToBytes(long buffer)

public static void
decodeAndThrowThrowable(int
specifies how to interpret buffer:
            0: buffer was created by encodeThrowable
            1: native memory for buffer could not be allocated
            2: an OutOfMemoryError was thrown while encoding the exception
            3: some other problem occured while encoding the exception. If buffer != 0,
               it contains a struct { u4 len; char[len] desc} where desc describes the problem
           
format
,
long
encoded info about the exception to throw (depends on format)
buffer
,
boolean
[@code true} if executing in the JVM heap, false otherwise
inJVMHeap
,
boolean
specifies whether debug stack traces should be enabled in case of translation failure
debug
)

Decodes the exception described by format and buffer and throws it.

private static <T, A, E, X> A
public static <
type to which a type name is resolved
T
,
type of the object representing a decoded annotation
A
,
type of the object representing a decoded enum constant
E
,
type of the object representing a decoded error
X
>
List<A>

Returns:

an immutable list of A objects
decodeAnnotations
(byte[] encoded, VMSupport.AnnotationDecoder<T, A, E, X> decoder)

Decodes annotations serialized in encoded to objects.

private static <T, A, E, X> Object
private static void
public static byte[]
encodeAnnotations(byte[] rawAnnotations, Class<?> declaringClass, ConstantPool cp, boolean forClass, Class<? extends Annotation>[] selectAnnotationClasses)

Parses rawAnnotations into a list of Annotations and then serializes them to a byte array with encodeAnnotations(Collection).

public static byte[]
encodeAnnotations(Collection<Annotation> annotations)

Encodes annotations to a byte array.

public static int

Returns:

the number of bytes written into buffer if bufferSize is large enough, otherwise -N where N is the value bufferSize needs to be to fit the encoding
encodeThrowable
(Throwable
the exception to encode
throwable
,
long
a native byte buffer
buffer
,
int
the size of buffer in bytes
bufferSize
)

If bufferSize is large enough, encodes throwable into a byte array and writes it to buffer.

public static synchronized Properties
getAgentProperties()

Returns the agent properties.

public static native String
private static native Properties
private static Properties

Returns:

a Properties object containing only the entries in p whose key and value are both Strings
onlyStrings
(Properties p)

private static List<Object>

Returns:

an immutable list of A objects
readArray
(DataInputStream dis, VMSupport.IOReader
reads array elements from dis
reader
)

Reads an array encoded at the current read position of dis and returns it in an immutable list.

private static <T, A, E, X> T
readClass(DataInputStream dis, VMSupport.AnnotationDecoder<T, A, E, X> decoder)

Reads a class encoded at the current read position of dis and returns it as an object of type T.

private static <T, A, E, X> E
readEnum(DataInputStream dis, VMSupport.AnnotationDecoder<T, A, E, X> decoder, T enumType)

Reads an enum encoded at the current read position of dis and returns it as an object of type E.

private static int
public static byte[]
private static byte[]
serializePropertiesToByteArray(Properties p)

Writes the given properties list to a byte array and return it.

public static byte[]
private static void
writeLength(DataOutputStream dos, int length)

Encodes length in 1 byte if it is less than 128.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

agentPropsback to summary
private static Properties agentProps
Uback to summary
private static final Unsafe U

Constructor Detail

VMSupportback to summary
public VMSupport()

Method Detail

bufferToBytesback to summary
private static byte[] bufferToBytes(long buffer)
decodeAndThrowThrowableback to summary
public static void decodeAndThrowThrowable(int format, long buffer, boolean inJVMHeap, boolean debug) throws Throwable

Decodes the exception described by format and buffer and throws it.

Parameters
format:int

specifies how to interpret buffer:

            0: buffer was created by encodeThrowable
            1: native memory for buffer could not be allocated
            2: an OutOfMemoryError was thrown while encoding the exception
            3: some other problem occured while encoding the exception. If buffer != 0,
               it contains a struct { u4 len; char[len] desc} where desc describes the problem
           
buffer:long

encoded info about the exception to throw (depends on format)

inJVMHeap:boolean

[@code true} if executing in the JVM heap, false otherwise

debug:boolean

specifies whether debug stack traces should be enabled in case of translation failure

decodeAnnotationback to summary
private static <T, A, E, X> A decodeAnnotation(DataInputStream dis, VMSupport.AnnotationDecoder<T, A, E, X> decoder) throws IOException
Annotations
@SuppressWarnings:rawtypes, unchecked
decodeAnnotationsback to summary
public static <T, A, E, X> List<A> decodeAnnotations(byte[] encoded, VMSupport.AnnotationDecoder<T, A, E, X> decoder)

Decodes annotations serialized in encoded to objects.

Parameters
<T>
type to which a type name is resolved
<A>
type of the object representing a decoded annotation
<E>
type of the object representing a decoded enum constant
<X>
type of the object representing a decoded error
Returns:List<A>

an immutable list of A objects

Annotations
@SuppressWarnings:rawtypes, unchecked
decodeArrayback to summary
private static <T, A, E, X> Object decodeArray(DataInputStream dis, VMSupport.AnnotationDecoder<T, A, E, X> decoder) throws IOException
encodeAnnotationback to summary
private static void encodeAnnotation(DataOutputStream dos, Annotation a) throws Exception
encodeAnnotationsback to summary
public static byte[] encodeAnnotations(byte[] rawAnnotations, Class<?> declaringClass, ConstantPool cp, boolean forClass, Class<? extends Annotation>[] selectAnnotationClasses)

Parses rawAnnotations into a list of Annotations and then serializes them to a byte array with encodeAnnotations(Collection).

encodeAnnotationsback to summary
public static byte[] encodeAnnotations(Collection<Annotation> annotations)

Encodes annotations to a byte array. The byte array can be decoded with decodeAnnotations(byte[], AnnotationDecoder).

encodeThrowableback to summary
public static int encodeThrowable(Throwable throwable, long buffer, int bufferSize)

If bufferSize is large enough, encodes throwable into a byte array and writes it to buffer. The encoding in buffer can be decoded by decodeAndThrowThrowable.

Parameters
throwable:Throwable

the exception to encode

buffer:long

a native byte buffer

bufferSize:int

the size of buffer in bytes

Returns:int

the number of bytes written into buffer if bufferSize is large enough, otherwise -N where N is the value bufferSize needs to be to fit the encoding

getAgentPropertiesback to summary
public static synchronized Properties getAgentProperties()

Returns the agent properties.

getVMTemporaryDirectoryback to summary
public static native String getVMTemporaryDirectory()
initAgentPropertiesback to summary
private static native Properties initAgentProperties(Properties props)
onlyStringsback to summary
private static Properties onlyStrings(Properties p)
Returns:Properties

a Properties object containing only the entries in p whose key and value are both Strings

readArrayback to summary
private static List<Object> readArray(DataInputStream dis, VMSupport.IOReader reader) throws IOException

Reads an array encoded at the current read position of dis and returns it in an immutable list.

Parameters
reader:VMSupport.IOReader

reads array elements from dis

Returns:List<Object>

an immutable list of A objects

readClassback to summary
private static <T, A, E, X> T readClass(DataInputStream dis, VMSupport.AnnotationDecoder<T, A, E, X> decoder) throws IOException

Reads a class encoded at the current read position of dis and returns it as an object of type T.

readEnumback to summary
private static <T, A, E, X> E readEnum(DataInputStream dis, VMSupport.AnnotationDecoder<T, A, E, X> decoder, T enumType) throws IOException

Reads an enum encoded at the current read position of dis and returns it as an object of type E.

readLengthback to summary
private static int readLength(DataInputStream dis) throws IOException
serializeAgentPropertiesToByteArrayback to summary
public static byte[] serializeAgentPropertiesToByteArray() throws IOException
serializePropertiesToByteArrayback to summary
private static byte[] serializePropertiesToByteArray(Properties p) throws IOException

Writes the given properties list to a byte array and return it. The stream written to the byte array is ISO 8859-1 encoded.

serializePropertiesToByteArrayback to summary
public static byte[] serializePropertiesToByteArray() throws IOException
writeLengthback to summary
private static void writeLength(DataOutputStream dos, int length) throws IOException

Encodes length in 1 byte if it is less than 128.

jdk.internal.vm back to summary

public Interface VMSupport.AnnotationDecoder<T, A, E, X>

Type Parameters
<T>
type to which a type name is resolved
<A>
type of the object representing a decoded annotation
<E>
type of the object representing a decoded enum constant
<X>
type of the object representing a decoded error

Helper for decodeAnnotations(byte[], AnnotationDecoder) to convert a byte array (ostensibly produced by VMSupport#encodeAnnotations) into objects.

Method Summary

Modifier and TypeMethod and Description
public A
newAnnotation(T
the annotation interface of the annotation
type
,
Map.Entry<String, Object>[]
elements of the annotation
elements
)

Creates an object representing a decoded annotation.

public E
newEnumValue(T
the enum type
enumType
,
String
the name of the enum constant
name
)

Creates an object representing a decoded enum constant.

public X
newErrorValue(String
of the error
description
)

Creates an object representing a decoded error value.

public T
resolveType(String name)

Resolves a name in Class#getName() format to an object of type T.

Method Detail

newAnnotationback to summary
public A newAnnotation(T type, Map.Entry<String, Object>[] elements)

Creates an object representing a decoded annotation.

Parameters
type:T

the annotation interface of the annotation

elements:Map.Entry<String, Object>[]

elements of the annotation

newEnumValueback to summary
public E newEnumValue(T enumType, String name)

Creates an object representing a decoded enum constant.

Parameters
enumType:T

the enum type

name:String

the name of the enum constant

newErrorValueback to summary
public X newErrorValue(String description)

Creates an object representing a decoded error value.

Parameters
description:String

of the error

resolveTypeback to summary
public T resolveType(String name)

Resolves a name in Class#getName() format to an object of type T.

jdk.internal.vm back to summary

pack-priv Interface VMSupport.IOReader

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public Object
read()

Method Detail

readback to summary
public Object read() throws IOException