public class ClassUtil extends Object
| Constructor and Description |
|---|
ClassUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkMagicNumber(int magicNumber)
Checks whether the given class magic number is correct.
|
static void |
checkVersionNumbers(int classVersion)
Checks whether the given class version number is supported.
|
static int |
externalArrayTypeDimensionCount(String externalType)
Returns the number of dimensions of the given external type.
|
static String |
externalBaseType(String externalArrayType)
Returns the external base type of an external array type, dropping any
array brackets.
|
static String |
externalClassAccessFlags(int accessFlags)
Converts internal class access flags into an external access description.
|
static String |
externalClassAccessFlags(int accessFlags,
String prefix)
Converts internal class access flags into an external access description.
|
static String |
externalClassName(String internalClassName)
Converts an internal class name into an external class name.
|
static String |
externalClassVersion(int classVersion)
Returns the minor part of the given class version number.
|
static String |
externalFieldAccessFlags(int accessFlags)
Converts internal field access flags into an external access description.
|
static String |
externalFieldAccessFlags(int accessFlags,
String prefix)
Converts internal field access flags into an external access description.
|
static String |
externalFullClassDescription(int accessFlags,
String internalClassName)
Converts an internal class description into an external class description.
|
static String |
externalFullFieldDescription(int accessFlags,
String fieldName,
String internalFieldDescriptor)
Converts an internal field description into an external full field description.
|
static String |
externalFullMethodDescription(String internalClassName,
int accessFlags,
String internalMethodName,
String internalMethodDescriptor)
Converts an internal method description into an external full method description.
|
static String |
externalMethodAccessFlags(int accessFlags)
Converts internal method access flags into an external access description.
|
static String |
externalMethodAccessFlags(int accessFlags,
String prefix)
Converts internal method access flags into an external access description.
|
static String |
externalMethodArguments(String internalMethodDescriptor)
Converts an internal method descriptor into an external method argument
description.
|
static String |
externalMethodName(String externalMethodNameAndArguments)
Returns the name part of the given external method name and arguments.
|
static String |
externalMethodReturnType(String internalMethodDescriptor)
Converts an internal method descriptor into an external method return type.
|
static String |
externalPackageName(String externalClassName)
Returns the external package name of the given external class name.
|
static String |
externalPackagePrefix(String externalClassName)
Returns the external package prefix of the given external class name.
|
static String |
externalParameterAccessFlags(int accessFlags)
Converts internal method parameter access flags into an external access
description.
|
static String |
externalParameterAccessFlags(int accessFlags,
String prefix)
Converts internal method parameter access flags into an external access
description.
|
static String |
externalShortClassName(String externalClassName)
Returns the external short class name of an external class name, dropping
the package specification.
|
static String |
externalType(String internalType)
Converts an internal type into an external type.
|
static int |
internalArrayTypeDimensionCount(String internalType)
Returns the number of dimensions of the given internal type.
|
static String |
internalArrayTypeFromClassName(String internalClassName,
int dimensionCount)
Returns the internal array type of a given class name with a given number
of dimensions.
|
static String |
internalClassName(String externalClassName)
Converts an external class name into an internal class name.
|
static String |
internalClassNameFromClassType(String internalClassType)
Returns the internal class name of a given internal class type
(including an array type).
|
static String |
internalClassNameFromType(String internalClassType)
Returns the internal class name of any given internal descriptor type,
disregarding array prefixes.
|
static int |
internalClassVersion(int majorVersion,
int minorVersion)
Returns the combined class version number.
|
static int |
internalClassVersion(String classVersion)
Returns the internal class version number.
|
static int |
internalMajorClassVersion(int classVersion)
Returns the major part of the given class version number.
|
static String |
internalMethodDescriptor(String externalReturnType,
List externalArguments)
Converts the given external method return type and List of arguments to
an internal method descriptor.
|
static String |
internalMethodDescriptor(String externalReturnType,
String externalMethodNameAndArguments)
Converts the given external method return type and name and arguments to
an internal method descriptor.
|
static int |
internalMethodParameterCount(String internalMethodDescriptor)
Returns the number of parameters of the given internal method descriptor.
|
static int |
internalMethodParameterSize(String internalMethodDescriptor)
Returns the size taken up on the stack by the parameters of the given
internal method descriptor.
|
static int |
internalMethodParameterSize(String internalMethodDescriptor,
boolean isStatic)
Returns the size taken up on the stack by the parameters of the given
internal method descriptor.
|
static int |
internalMethodParameterSize(String internalMethodDescriptor,
int accessFlags)
Returns the size taken up on the stack by the parameters of the given
internal method descriptor.
|
static String |
internalMethodReturnType(String internalMethodDescriptor)
Returns the internal type of the given internal method descriptor.
|
static int |
internalMinorClassVersion(int classVersion)
Returns the internal class version number.
|
static String |
internalPackageName(String internalClassName)
Returns the internal package name of the given internal class name.
|
static String |
internalPackagePrefix(String internalClassName)
Returns the internal package prefix of the given internal class name.
|
static String |
internalType(String externalType)
Converts an external type into an internal type.
|
static String |
internalTypeFromArrayType(String internalArrayType)
Returns the internal element type of a given internal array type.
|
static String |
internalTypeFromClassName(String internalClassName)
Returns the internal type of a given class name.
|
static int |
internalTypeSize(String internalType)
Returns the size taken up on the stack by the given internal type.
|
static boolean |
isExternalMethodNameAndArguments(String externalMemberNameAndArguments)
Returns whether the given member String represents an external method
name with arguments.
|
static boolean |
isInitializer(String internalMethodName)
Returns whether the given method name refers to a class initializer or
an instance initializer.
|
static boolean |
isInternalArrayInterfaceName(String internalClassName)
Returns whether the given internal class name is one of the interfaces
that is implemented by all array types.
|
static boolean |
isInternalArrayType(String internalType)
Returns whether the given internal type is an array type.
|
static boolean |
isInternalCategory2Type(String internalType)
Returns whether the given internal type is a primitive Category 2 type.
|
static boolean |
isInternalClassType(String internalType)
Returns whether the given internal type is a plain class type
(including an array type of a plain class type).
|
static boolean |
isInternalMethodDescriptor(String internalDescriptor)
Returns whether the given internal descriptor String represents a method
descriptor.
|
static boolean |
isInternalPrimitiveType(char internalType)
Returns whether the given internal type is a plain primitive type
(not void).
|
public static void checkMagicNumber(int magicNumber)
throws UnsupportedOperationException
magicNumber - the magic number.UnsupportedOperationException - when the magic number is incorrect.public static int internalClassVersion(int majorVersion,
int minorVersion)
majorVersion - the major part of the class version number.minorVersion - the minor part of the class version number.public static int internalMajorClassVersion(int classVersion)
classVersion - the combined class version number.public static int internalMinorClassVersion(int classVersion)
classVersion - the external class version number.public static int internalClassVersion(String classVersion)
classVersion - the external class version number.public static String externalClassVersion(int classVersion)
classVersion - the combined class version number.public static void checkVersionNumbers(int classVersion)
throws UnsupportedOperationException
classVersion - the combined class version number.UnsupportedOperationException - when the version is not supported.public static String internalClassName(String externalClassName)
externalClassName - the external class name,
e.g. "java.lang.Object"java/lang/Object".public static String externalFullClassDescription(int accessFlags, String internalClassName)
accessFlags - the access flags of the class.internalClassName - the internal class name,
e.g. "java/lang/Object".public java.lang.Object".public static String externalClassName(String internalClassName)
internalClassName - the internal class name,
e.g. "java/lang/Object".java.lang.Object".public static String externalBaseType(String externalArrayType)
externalArrayType - the external array type,
e.g. "java.lang.Object[][]"java.lang.Object".public static String externalShortClassName(String externalClassName)
externalClassName - the external class name,
e.g. "java.lang.Object"Object".public static boolean isInternalArrayType(String internalType)
internalType - the internal type,
e.g. "[[Ljava/lang/Object;".true if the given type is an array type,
false otherwise.public static int internalArrayTypeDimensionCount(String internalType)
internalType - the internal type,
e.g. "[[Ljava/lang/Object;".public static boolean isInternalArrayInterfaceName(String internalClassName)
java/lang/Object", "java/lang/Cloneable", and
"java/io/Serializable"internalClassName - the internal class name,
e.g. "java/lang/Object".true if the given type is an array interface name,
false otherwise.public static boolean isInternalPrimitiveType(char internalType)
internalType - the internal type,
e.g. "I".true if the given type is a class type,
false otherwise.public static boolean isInternalCategory2Type(String internalType)
internalType - the internal type,
e.g. "L".true if the given type is a Category 2 type,
false otherwise.public static boolean isInternalClassType(String internalType)
internalType - the internal type,
e.g. "Ljava/lang/Object;".true if the given type is a class type,
false otherwise.public static String internalTypeFromClassName(String internalClassName)
internalClassName - the internal class name,
e.g. "java/lang/Object".Ljava/lang/Object;".public static String internalArrayTypeFromClassName(String internalClassName, int dimensionCount)
internalClassName - the internal class name,
e.g. "java/lang/Object".dimensionCount - the number of array dimensions.Ljava/lang/Object;".public static String internalTypeFromArrayType(String internalArrayType)
internalArrayType - the internal array type,
e.g. "[[Ljava/lang/Object;" or
"[I".Ljava/lang/Object;" or
"I".public static String internalClassNameFromClassType(String internalClassType)
internalClassType - the internal class type,
e.g. "[Ljava/lang/Object;",
"Ljava/lang/Object;", or
"java/lang/Object".java/lang/Object".public static String internalClassNameFromType(String internalClassType)
internalClassType - the internal class type,
e.g. "Ljava/lang/Object;" or
"[[I".java/lang/Object" or
null.public static boolean isInitializer(String internalMethodName)
internalMethodName - the internal method name,
e.g. "<clinit>".true.public static String internalMethodReturnType(String internalMethodDescriptor)
internalMethodDescriptor - the internal method descriptor,
e.g. "(II)Z".Z".public static int internalMethodParameterCount(String internalMethodDescriptor)
internalMethodDescriptor - the internal method descriptor,
e.g. "(ID)Z".public static int internalMethodParameterSize(String internalMethodDescriptor)
internalMethodDescriptor - the internal method descriptor,
e.g. "(ID)Z".public static int internalMethodParameterSize(String internalMethodDescriptor, int accessFlags)
internalMethodDescriptor - the internal method descriptor,
e.g. "(ID)Z".accessFlags - the access flags of the method,
e.g. 0.public static int internalMethodParameterSize(String internalMethodDescriptor, boolean isStatic)
internalMethodDescriptor - the internal method descriptor,
e.g. "(ID)Z".isStatic - specifies whether the method is static,
e.g. false.public static int internalTypeSize(String internalType)
internalType - the internal type,
e.g. "I".public static String internalType(String externalType)
externalType - the external type,
e.g. "java.lang.Object[][]" or
"int[]".[[Ljava/lang/Object;" or
"[I".public static int externalArrayTypeDimensionCount(String externalType)
externalType - the external type,
e.g. "[[Ljava/lang/Object;".public static String externalType(String internalType)
internalType - the internal type,
e.g. "[[Ljava/lang/Object;" or
"[I".java.lang.Object[][]" or
"int[]".public static boolean isInternalMethodDescriptor(String internalDescriptor)
internalDescriptor - the internal descriptor String,
e.g. "(II)Z".true if the given String is a method descriptor,
false otherwise.public static boolean isExternalMethodNameAndArguments(String externalMemberNameAndArguments)
externalMemberNameAndArguments - the external member String,
e.g. "myField" or
e.g. "myMethod(int,int)".true if the given String refers to a method,
false otherwise.public static String externalMethodName(String externalMethodNameAndArguments)
externalMethodNameAndArguments - the external method name and arguments,
e.g. "myMethod(int,int)".myMethod".public static String internalMethodDescriptor(String externalReturnType, String externalMethodNameAndArguments)
externalReturnType - the external method return type,
e.g. "boolean".externalMethodNameAndArguments - the external method name and arguments,
e.g. "myMethod(int,int)".(II)Z".public static String internalMethodDescriptor(String externalReturnType, List externalArguments)
externalReturnType - the external method return type,
e.g. "boolean".externalArguments - the external method arguments,
e.g. { "int", "int" }.(II)Z".public static String externalFullFieldDescription(int accessFlags, String fieldName, String internalFieldDescriptor)
accessFlags - the access flags of the field.fieldName - the field name,
e.g. "myField".internalFieldDescriptor - the internal field descriptor,
e.g. "Z".public boolean myField".public static String externalFullMethodDescription(String internalClassName, int accessFlags, String internalMethodName, String internalMethodDescriptor)
internalClassName - the internal name of the class of the method,
e.g. "mypackage/MyClass".accessFlags - the access flags of the method.internalMethodName - the internal method name,
e.g. "myMethod" or
"<init>".internalMethodDescriptor - the internal method descriptor,
e.g. "(II)Z".public boolean myMethod(int,int)" or
"public MyClass(int,int)".public static String externalClassAccessFlags(int accessFlags)
accessFlags - the class access flags.public final ".public static String externalClassAccessFlags(int accessFlags, String prefix)
accessFlags - the class access flags.prefix - a prefix that is added to each access modifier.public final ".public static String externalFieldAccessFlags(int accessFlags)
accessFlags - the field access flags.public volatile ".public static String externalFieldAccessFlags(int accessFlags, String prefix)
accessFlags - the field access flags.prefix - a prefix that is added to each access modifier.public volatile ".public static String externalMethodAccessFlags(int accessFlags)
accessFlags - the method access flags.public synchronized ".public static String externalMethodAccessFlags(int accessFlags, String prefix)
accessFlags - the method access flags.prefix - a prefix that is added to each access modifier.public static String externalParameterAccessFlags(int accessFlags)
accessFlags - the method parameter access flags.final mandated ".public static String externalParameterAccessFlags(int accessFlags, String prefix)
accessFlags - the method parameter access flags.prefix - a prefix that is added to each access modifier.public static String externalMethodReturnType(String internalMethodDescriptor)
internalMethodDescriptor - the internal method descriptor,
e.g. "(II)Z".boolean".public static String externalMethodArguments(String internalMethodDescriptor)
internalMethodDescriptor - the internal method descriptor,
e.g. "(II)Z".int,int".public static String internalPackageName(String internalClassName)
internalClassName - the internal class name,
e.g. "java/lang/Object".java/lang".public static String internalPackagePrefix(String internalClassName)
internalClassName - the internal class name,
e.g. "java/lang/Object".java/lang/".public static String externalPackageName(String externalClassName)
externalClassName - the external class name,
e.g. "java.lang.Object".java.lang".Copyright © 2015. All Rights Reserved.