Package org.openjdk.jmc.agent.util
Class TypeUtils
java.lang.Object
org.openjdk.jmc.agent.util.TypeUtils
Helper methods for doing transforms.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe internal name of this class.static final Stringstatic final Stringstatic final Stringstatic final StringThe file extension for java source files (.java).private static final Stringstatic final org.objectweb.asm.Typestatic final org.objectweb.asm.Typestatic final org.objectweb.asm.Typeprivate static final Objectprivate static final Methodprivate static final Stringprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Objectbox(byte val) static Objectbox(char val) static Objectbox(double val) static Objectbox(float val) static Objectbox(int val) static Objectbox(long val) static Objectbox(short val) static Class<?> defineClass(String eventClassName, byte[] eventClass, int i, int length, ClassLoader definingClassLoader, ProtectionDomain protectionDomain) static Stringprivate static voidstatic StringgetCanonicalName(String binaryName) Converts a internal class name (binary name) into the canonical form.static intgetConstZeroOpcode(org.objectweb.asm.Type type) Returns the constant loading instruction that pushes a zero value of the given type onto the operand stack.static ObjectgetFrameVerificationType(org.objectweb.asm.Type type) Returns a array element for ASM'sMethodVisitor.visitFrame()method used for frame verification of a given type.static StringgetInternalName(String className) Converts a canonical class name into the internal form (binary name).static StringgetNamePart(String fqcn) static StringgetPathPart(String fqcn) private static Objectprivate static Class<?> private static MethodgetUnsafeDefineClassMethod(Object unsafe) static booleanisSupportedType(org.objectweb.asm.Type type) Returns true if the type provided is supported for a JFR event field.static booleanisValidJavaIdentifier(String identifier) static Stringparameterize(String className) Transforms a FQN in internal form, so that it can be used in e.g.static voidstringify(org.objectweb.asm.MethodVisitor mv) static Stringprivate static StringType agnostic array toString() which also handles primitive arrays.static voidvisitBox(org.objectweb.asm.MethodVisitor mv, org.objectweb.asm.Type type) Ensure that the operand is on the stack before calling.
-
Field Details
-
NULL_REFERENCE_STRING
- See Also:
-
INAME
The internal name of this class. -
TYPE_OBJECT
public static final org.objectweb.asm.Type TYPE_OBJECT -
TYPE_OBJECT_ARRAY
public static final org.objectweb.asm.Type TYPE_OBJECT_ARRAY -
TYPE_STRING
public static final org.objectweb.asm.Type TYPE_STRING -
INTERNAL_NAME_STRING
- See Also:
-
INTERNAL_NAME_THREAD
-
INTERNAL_NAME_CLASS
-
UNSAFE_JDK_7_CLASS
- See Also:
-
UNSAFE_JDK_11_CLASS
- See Also:
-
UNSAFE
-
UNSAFE_DEFINE_CLASS_METHOD
-
JAVA_FILE_EXTENSION
The file extension for java source files (.java).- See Also:
-
-
Constructor Details
-
TypeUtils
private TypeUtils()
-
-
Method Details
-
box
-
box
-
box
-
box
-
box
-
box
-
box
-
toString
-
defineClass
public static Class<?> defineClass(String eventClassName, byte[] eventClass, int i, int length, ClassLoader definingClassLoader, ProtectionDomain protectionDomain) -
visitBox
public static void visitBox(org.objectweb.asm.MethodVisitor mv, org.objectweb.asm.Type type) Ensure that the operand is on the stack before calling. If type is void, this is a noop, and depending on your use case you may instead want to push Opcodes.ACONST_NULL. -
isValidJavaIdentifier
-
deriveIdentifierPart
-
getPathPart
-
getNamePart
-
stringify
public static void stringify(org.objectweb.asm.MethodVisitor mv) -
parameterize
Transforms a FQN in internal form, so that it can be used in e.g. formal descriptors.- Parameters:
className- the fully qualified class name in internal form.- Returns:
- the transformed class name.
-
getInternalName
Converts a canonical class name into the internal form (binary name). eg.com.company.projectconverts intocom/company/project- Parameters:
className- the canonical class name- Returns:
- the internal form
-
getCanonicalName
Converts a internal class name (binary name) into the canonical form. ie.com/company/projectconverts intocom.company.project- Parameters:
binaryName- the internal class name- Returns:
- in canonical form
-
getConstZeroOpcode
public static int getConstZeroOpcode(org.objectweb.asm.Type type) Returns the constant loading instruction that pushes a zero value of the given type onto the operand stack. A null reference is pushed if the given type is an object or an array.- Parameters:
type- the type of the operand- Returns:
- the instruction
-
getFrameVerificationType
Returns a array element for ASM'sMethodVisitor.visitFrame()method used for frame verification of a given type.- Parameters:
type- the type of the element on the operand stack or in the local variable table.- Returns:
- a array element for
MethodVisitor.visitFrame()'s parameter.
-
isSupportedType
public static boolean isSupportedType(org.objectweb.asm.Type type) Returns true if the type provided is supported for a JFR event field.- Parameters:
type- the type to check.- Returns:
- true if the type provided is supported for a JFR event field.
-
toString
Type agnostic array toString() which also handles primitive arrays. -
emitBox
-
getUnsafe
-
getUnsafeDefineClassMethod
-
getUnsafeClass
-