Modifier and Type | Class and Description |
---|---|
private static class |
MetaUtil.ClassInfo |
Constructor and Description |
---|
MetaUtil() |
Modifier and Type | Method and Description |
---|---|
static StringBuilder |
appendLocation(StringBuilder sb,
ResolvedJavaMethod method,
int bci)
Appends a string representation of a location specified by a given method and bci to a given
StringBuilder . |
(package private) static void |
appendProfile(StringBuilder buf,
AbstractJavaProfile<?,?> profile,
int bci,
String type,
String sep) |
static ResolvedJavaType |
classForName(String internal,
MetaAccessProvider metaAccess,
ClassLoader cl)
Turns an class name in internal format into a resolved Java type.
|
static long |
getMemorySizeRecursive(MetaAccessProvider access,
ConstantReflectionProvider constantReflection,
JavaConstant constant,
PrintStream out,
int printTopN)
Returns the number of bytes occupied by this constant value or constant object and
recursively all values reachable from this value.
|
(package private) static int |
getNonPublicModifierStaticField(String name)
Used to lookup constants from
Modifier that are not public (VARARGS, SYNTHETIC etc.). |
static String |
getSimpleName(Class<?> clazz,
boolean withEnclosingClass)
Extends the functionality of
Class.getSimpleName() to include a non-empty string for
anonymous and local classes. |
static String |
identityHashCodeString(Object obj)
Gets a string representation of an object based soley on its class and its
identity hash code.
|
static String |
indent(String lines,
String indentation)
Prepends the String
indentation to every line in String lines , including a
possibly non-empty line following the final newline. |
(package private) static String |
internalNameToJava(String name,
boolean qualified,
boolean classForNameCompatible) |
private static void |
pushConstant(Set<JavaConstant> marked,
Deque<JavaConstant> stack,
JavaConstant value) |
static ResolvedJavaType[] |
resolveJavaTypes(JavaType[] types,
ResolvedJavaType accessingClass)
Calls
JavaType.resolve(ResolvedJavaType) on an array of types. |
static String |
toInternalName(String className)
Converts a Java source-language class name into the internal form.
|
static String |
toLocation(ResolvedJavaMethod method,
int bci)
Convenient shortcut for calling
appendLocation(StringBuilder, ResolvedJavaMethod, int) without having to supply a
StringBuilder instance and convert the result to a string. |
public MetaUtil()
public static long getMemorySizeRecursive(MetaAccessProvider access, ConstantReflectionProvider constantReflection, JavaConstant constant, PrintStream out, int printTopN)
constant
- the constant whose bytes should be measuredprintTopN
- print total size and instance count of the top n classes is desiredprivate static void pushConstant(Set<JavaConstant> marked, Deque<JavaConstant> stack, JavaConstant value)
public static ResolvedJavaType[] resolveJavaTypes(JavaType[] types, ResolvedJavaType accessingClass)
JavaType.resolve(ResolvedJavaType)
on an array of types.public static String getSimpleName(Class<?> clazz, boolean withEnclosingClass)
Class.getSimpleName()
to include a non-empty string for
anonymous and local classes.clazz
- the class for which the simple name is being requestedwithEnclosingClass
- specifies if the returned name should be qualified with the name(s)
of the enclosing class/classes of clazz
(if any). This option is ignored
if clazz
denotes an anonymous or local class.static String internalNameToJava(String name, boolean qualified, boolean classForNameCompatible)
public static ResolvedJavaType classForName(String internal, MetaAccessProvider metaAccess, ClassLoader cl)
public static String toLocation(ResolvedJavaMethod method, int bci)
appendLocation(StringBuilder, ResolvedJavaMethod, int)
without having to supply a
StringBuilder
instance and convert the result to a string.public static StringBuilder appendLocation(StringBuilder sb, ResolvedJavaMethod method, int bci)
StringBuilder
. If a stack trace element with a non-null file name and non-negative
line number is available for the
given method, then the string returned is the StackTraceElement.toString()
value of
the stack trace element, suffixed by the bci location. For example:
java.lang.String.valueOf(String.java:2930) [bci: 12]Otherwise, the string returned is the value of applying
JavaMethod.format(String)
with the format string "%H.%n(%p)"
, suffixed by the bci location. For example:
java.lang.String.valueOf(int) [bci: 12]
sb
- method
- bci
- static void appendProfile(StringBuilder buf, AbstractJavaProfile<?,?> profile, int bci, String type, String sep)
public static String toInternalName(String className)
className
- the class namepublic static String indent(String lines, String indentation)
indentation
to every line in String lines
, including a
possibly non-empty line following the final newline.public static String identityHashCodeString(Object obj)
Object.hashCode()
.static int getNonPublicModifierStaticField(String name)
Modifier
that are not public (VARARGS, SYNTHETIC etc.).