Class ClassUtil

java.lang.Object
proguard.classfile.util.ClassUtil

public class ClassUtil extends Object
Utility methods for:
  • Converting between internal and external representations of names and descriptions
  • Operation on Clazz
  • Method Details

    • checkMagicNumber

      public static void checkMagicNumber(int magicNumber) throws UnsupportedOperationException
      Checks whether the given class magic number is correct.
      Parameters:
      magicNumber - the magic number.
      Throws:
      UnsupportedOperationException - when the magic number is incorrect.
    • internalClassVersion

      public static int internalClassVersion(int majorVersion, int minorVersion)
      Returns the combined class version number.
      Parameters:
      majorVersion - the major part of the class version number.
      minorVersion - the minor part of the class version number.
      Returns:
      the combined class version number.
    • internalMajorClassVersion

      public static int internalMajorClassVersion(int internalClassVersion)
      Returns the major part of the given class version number.
      Parameters:
      internalClassVersion - the combined class version number.
      Returns:
      the major part of the class version number.
    • internalMinorClassVersion

      public static int internalMinorClassVersion(int internalClassVersion)
      Returns the minor part of the given class version number.
      Parameters:
      internalClassVersion - the combined class version number.
      Returns:
      the minor part of the class version number.
    • internalClassVersion

      public static int internalClassVersion(String externalClassVersion)
      Returns the internal class version number.
      Parameters:
      externalClassVersion - the external class version number.
      Returns:
      the internal class version number, or 0 if unrecognized.
    • externalClassVersion

      public static String externalClassVersion(int internalClassVersion)
      Returns the external class version number.
      Parameters:
      internalClassVersion - the internal class version number.
      Returns:
      the external class version number, or null if unrecognized.
    • checkVersionNumbers

      public static void checkVersionNumbers(int internalClassVersion) throws UnsupportedOperationException
      Checks whether the given class version number is supported.
      Parameters:
      internalClassVersion - the combined class version number.
      Throws:
      UnsupportedOperationException - when the version is not supported.
    • internalClassName

      public static String internalClassName(String externalClassName)
      Converts an external class name into an internal class name.
      Parameters:
      externalClassName - the external class name, e.g. "java.lang.Object"
      Returns:
      the internal class name, e.g. "java/lang/Object".
    • canonicalClassName

      public static String canonicalClassName(String externalClassName)
      Converts an external class name into a canonical class name.
      Parameters:
      externalClassName - the external class name e.g. com.example.Enclosing$Inner
      Returns:
      the canonical class name, e.g. com.example.Enclosing.Inner
    • externalFullClassDescription

      public static String externalFullClassDescription(int accessFlags, String internalClassName)
      Converts an internal class description into an external class description.
      Parameters:
      accessFlags - the access flags of the class.
      internalClassName - the internal class name, e.g. "java/lang/Object".
      Returns:
      the external class description, e.g. "public java.lang.Object".
    • externalClassName

      public static String externalClassName(String internalClassName, boolean quoted)
      Converts an internal class name into an external class name.
      Parameters:
      internalClassName - the internal class name, e.g. "java/lang/Object".
      quoted - whether the result should be quoted; should be set to true if it is going to be parsed as configuration later. Uses quotedIdentifier(String) for quoting.
      Returns:
      the external class name, e.g. "java.lang.Object".
    • externalClassName

      public static String externalClassName(String internalClassName)
      Converts an internal class name into an external class name.
      Parameters:
      internalClassName - the internal class name, e.g. "java/lang/Object".
      Returns:
      the external class name, e.g. "java.lang.Object".
    • externalBaseType

      public static String externalBaseType(String externalArrayType)
      Returns the external base type of an external array type, dropping any array brackets.
      Parameters:
      externalArrayType - the external array type, e.g. "java.lang.Object[][]"
      Returns:
      the external base type, e.g. "java.lang.Object".
    • externalShortClassName

      public static String externalShortClassName(String externalClassName)
      Returns the external short class name of an external class name, dropping the package specification.
      Parameters:
      externalClassName - the external class name, e.g. "java.lang.Object"
      Returns:
      the external short class name, e.g. "Object".
    • internalShortClassName

      public static String internalShortClassName(String internalClassName)
      Returns the internal short class name of an internal class name, dropping the package specification.
      Parameters:
      internalClassName - the internal class name, e.g. "java/lang/Object"
      Returns:
      the internal short class name, e.g. "Object".
    • isInternalArrayType

      public static boolean isInternalArrayType(String internalType)
      Returns whether the given internal type is an array type.
      Parameters:
      internalType - the internal type, e.g. "[[Ljava/lang/Object;".
      Returns:
      true if the given type is an array type, false otherwise.
    • internalArrayTypeDimensionCount

      public static int internalArrayTypeDimensionCount(String internalType)
      Returns the number of dimensions of the given internal type.
      Parameters:
      internalType - the internal type, e.g. "[[Ljava/lang/Object;".
      Returns:
      the number of dimensions, e.g. 2.
    • isInternalArrayInterfaceName

      public static boolean isInternalArrayInterfaceName(String internalClassName)
      Returns whether the given internal class name is one of the interfaces that is implemented by all array types. These class names are "java/lang/Object", " java/lang/Cloneable", and "java/io/Serializable"
      Parameters:
      internalClassName - the internal class name, e.g. "java/lang/Object".
      Returns:
      true if the given type is an array interface name, false otherwise.
    • isInternalPrimitiveType

      public static boolean isInternalPrimitiveType(char internalType)
      Returns whether the given internal type is a plain primitive type (not void).
      Parameters:
      internalType - the internal type, e.g. "I".
      Returns:
      true if the given type is a class type, false otherwise.
    • isInternalPrimitiveType

      public static boolean isInternalPrimitiveType(String internalType)
      Returns whether the given internal type is a plain primitive type (not void).
      Parameters:
      internalType - the internal type, e.g. "I".
      Returns:
      true if the given type is an internal primitive type, false otherwise.
    • isInternalPrimitiveBoxingType

      public static boolean isInternalPrimitiveBoxingType(String internalType)
      Returns whether the given class is a class boxing a primitive type (not void).
      Parameters:
      internalType - the internal type, e.g. "Ljava/lang/Integer;".
      Returns:
      true if the given type is a boxing internal type of a class boxing a primitive, false otherwise.
    • internalPrimitiveTypeFromPrimitiveBoxingType

      public static char internalPrimitiveTypeFromPrimitiveBoxingType(String type)
      Returns the primitive type corresponding to the given internal primitive boxing type.
      Parameters:
      type - an internal primitive boxing type, e.g. "Ljava/lang/Integer;".
      Returns:
      the corresponding primitive type, e.g. "I".
    • primitiveClassFromInternalBoxingType

      public static Class<?> primitiveClassFromInternalBoxingType(String internalBoxingType)
    • isInternalPrimitiveTypeOrString

      public static boolean isInternalPrimitiveTypeOrString(String internalType)
      Returns whether the given internal type is a plain primitive type (not void) or a java/lang/String.
      Parameters:
      internalType - the internal type, e.g. "I".
      Returns:
      true if the given type is a class type, false otherwise.
    • isInternalCategory2Type

      public static boolean isInternalCategory2Type(String internalType)
      Returns whether the given internal type is a primitive Category 2 type.
      Parameters:
      internalType - the internal type, e.g. "L".
      Returns:
      true if the given type is a Category 2 type, false otherwise.
    • isInternalClassType

      public 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).
      Parameters:
      internalType - the internal type, e.g. "Ljava/lang/Object;".
      Returns:
      true if the given type is a class type, false otherwise.
    • isInternalType

      public static boolean isInternalType(String type)
      Returns whether the given type is an internal type, i.e. one of:

      - an internal array type; - an internal primitive type; - an internal class type.

      Parameters:
      type - the type, e.g. "Ljava/lang/String;", "I"
      Returns:
      true if the given type is a class type, false otherwise.
    • internalTypeFromClassName

      public static String internalTypeFromClassName(String internalClassName)
      Returns the internal type of a given class name.
      Parameters:
      internalClassName - the internal class name, e.g. "java/lang/Object".
      Returns:
      the internal type, e.g. "Ljava/lang/Object;".
    • internalArrayTypeFromClassName

      public static String internalArrayTypeFromClassName(String internalClassName, int dimensionCount)
      Returns the internal array type of a given class name with a given number of dimensions. If the number of dimensions is 0, the class name itself is returned.
      Parameters:
      internalClassName - the internal class name, e.g. "java/lang/Object".
      dimensionCount - the number of array dimensions.
      Returns:
      the internal array type of the array elements, e.g. "Ljava/lang/Object;".
    • internalArrayTypeFromType

      public static String internalArrayTypeFromType(String internalType, int dimensionDelta)
      Returns the internal array type of a given type, with a given number of additional dimensions.
      Parameters:
      internalType - the internal class name, e.g. "[Ljava/lang/Object;".
      dimensionDelta - the number of additional array dimensions, e.g. 1.
      Returns:
      the internal array type of the array elements, e.g. "[[Ljava/lang/Object; ".
    • internalTypeFromArrayType

      public static String internalTypeFromArrayType(String internalArrayType)
      Returns the internal element type of a given internal array type.
      Parameters:
      internalArrayType - the internal array type, e.g. "[[Ljava/lang/Object;" or " [I".
      Returns:
      the internal type of the array elements, e.g. "Ljava/lang/Object;" or " I".
    • internalClassTypeFromType

      public static String internalClassTypeFromType(String internalType)
      Returns the internal class type (class name or array type) of a given internal type (including an array type). This is the type that can be stored in a class constant.
      Parameters:
      internalType - the internal class type, e.g. "[I", "[Ljava/lang/Object; ", or "Ljava/lang/Object;".
      Returns:
      the internal class name, e.g. "[I", "[Ljava/lang/Object;", or "java/lang/Object".
    • internalTypeFromClassType

      public static String internalTypeFromClassType(String internalType)
      Returns the internal type of a given class type (class name or array type). This is the type that can be stored in a class constant.
      Parameters:
      internalType - the internal class type, e.g. "[I", "[Ljava/lang/Object; ", or "java/lang/Object".
      Returns:
      the internal class name, e.g. "[I", "[Ljava/lang/Object;", or "Ljava/lang/Object;".
    • internalClassNameFromClassType

      public static String internalClassNameFromClassType(String internalClassType)
      Returns the internal class name of a given internal class type (including an array type). Types involving primitive types are returned unchanged.
      Note: If you are parsing a Signature attribute string, use internalClassNameFromClassSignature(String) instead, as this method will not handle generic type parameters and the '.' as inner class separator.
      Parameters:
      internalClassType - the internal class type, e.g. "[Ljava/lang/Object;", " Ljava/lang/Object;", or "java/lang/Object".
      Returns:
      the internal class name, e.g. "java/lang/Object".
    • internalClassNameFromClassSignature

      public static String internalClassNameFromClassSignature(String classSignature)
      Returns the internal class name for a given Class Signature.
      Parameters:
      classSignature - the class signature, e.g. "Lsome/package/Klass< T;>.Inner"
      Returns:
      the internal class name, e.g. "some/package/Klass$Inner".
    • removeGenericTypes

      public static String removeGenericTypes(String descriptor)
      Remove any generic type parameters from the given descriptor.
    • internalClassNameFromType

      public static String internalClassNameFromType(String internalClassType)
      Returns the internal class name of any given internal descriptor type, disregarding array prefixes.
      Parameters:
      internalClassType - the internal class type, e.g. "Ljava/lang/Object;" or " [[I".
      Returns:
      the internal class name, e.g. "java/lang/Object" or null.
    • internalNumericClassNameFromPrimitiveType

      public static String internalNumericClassNameFromPrimitiveType(char internalPrimitiveType)
      Returns the internal numeric (or void or array) class name corresponding to the given internal primitive type.
      Parameters:
      internalPrimitiveType - the internal class type, e.g. "I" or "V ".
      Returns:
      the internal class name, e.g. "java/lang/Integer" or java/lang/Void .
    • internalPrimitiveTypeFromNumericClassName

      public static char internalPrimitiveTypeFromNumericClassName(String internalPrimitiveClassName)
      Returns the internal numeric (or void or array) class name corresponding to the given internal primitive type.
      Parameters:
      internalPrimitiveClassName - the internal class name, e.g. "java/lang/Integer " or java/lang/Void.
      Returns:
      the internal class type, e.g. "I" or "V".
    • internalSimpleClassName

      public static String internalSimpleClassName(String internalClassName)
      Returns the simple name of an internal class name, dropping the package specification and any outer class part.
      Parameters:
      internalClassName - the internal class name, e.g. "java/lang/Object"
      Returns:
      the simple class name, e.g. "Object".
    • internalPrimitiveTypeToComputationalType

      public static int internalPrimitiveTypeToComputationalType(String internalPrimitiveType)
      The internal primitive type computational type.
      Parameters:
      internalPrimitiveType - an internal primitive type (e.g., "Z")
      Returns:
      the int representing the type internally (from the constants in Value).
    • isInitializer

      public static boolean isInitializer(String internalMethodName)
      Returns whether the given method name refers to a class initializer or an instance initializer.
      Parameters:
      internalMethodName - The internal method name, e.g. "<clinit>".
      Returns:
      Whether the method name refers to an initializer, e.g. true.
    • isClassInitializer

      public static boolean isClassInitializer(String internalMethodName)
      Returns whether the given method name refers to a class initializer.
      Parameters:
      internalMethodName - The internal method name, e.g. "<clinit>".
      Returns:
      Whether the method name refers to a class initializer, e.g. true.
    • isInstanceInitializer

      public static boolean isInstanceInitializer(String internalMethodName)
      Returns whether the given method name refers to an instance initializer.
      Parameters:
      internalMethodName - The internal method name, e.g. "<init>".
      Returns:
      Whether the method name refers to an instance initializer, e.g. true.
    • internalMethodReturnType

      public static String internalMethodReturnType(String internalMethodDescriptor)
      Returns the internal type of the given internal method descriptor.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(II)Z".
      Returns:
      the internal return type, e.g. "Z".
    • internalMethodParameterCount

      public static int internalMethodParameterCount(String internalMethodDescriptor)
      Returns the number of parameters of the given internal method descriptor.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(ID)Z".
      Returns:
      the number of parameters, e.g. 2.
    • internalMethodParameterCount

      public static int internalMethodParameterCount(String internalMethodDescriptor, int accessFlags)
      Returns the number of parameters of the given internal method descriptor.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(ID)Z".
      accessFlags - the access flags of the method, e.g. 0.
      Returns:
      the number of parameters, e.g. 3.
    • internalMethodParameterCount

      public static int internalMethodParameterCount(String internalMethodDescriptor, boolean isStatic)
      Returns the number of parameters of the given internal method descriptor.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(ID)Z".
      isStatic - specifies whether the method is static, e.g. false.
      Returns:
      the number of parameters, e.g. 3.
    • internalMethodParameterSize

      public static int internalMethodParameterSize(String internalMethodDescriptor)
      Returns the size taken up on the stack by the parameters of the given internal method descriptor. This accounts for long and double parameters taking up two entries.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(ID)Z".
      Returns:
      the size taken up on the stack, e.g. 3.
    • internalMethodParameterSize

      public static int internalMethodParameterSize(String internalMethodDescriptor, int accessFlags)
      Returns the size taken up on the stack by the parameters of the given internal method descriptor. This accounts for long and double parameters taking up two entries, and a non-static method taking up an additional entry.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(ID)Z".
      accessFlags - the access flags of the method, e.g. 0.
      Returns:
      the size taken up on the stack, e.g. 4.
    • internalMethodParameterSize

      public static int internalMethodParameterSize(String internalMethodDescriptor, boolean isStatic)
      Returns the size taken up on the stack by the parameters of the given internal method descriptor. This accounts for long and double parameters taking up two spaces, and a non-static method taking up an additional entry.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(ID)Z".
      isStatic - specifies whether the method is static, e.g. false.
      Returns:
      the size taken up on the stack, e.g. 4.
    • internalMethodParameterNumber

      public static int internalMethodParameterNumber(String internalMethodDescriptor, int accessFlags, int variableIndex)
      Returns the parameter number in the given internal method descriptor, corresponding to the given variable index. This accounts for long and double parameters taking up two spaces, and a non-static method taking up an additional entry. The method returns 0 if the index corresponds to the 'this' parameter and -1 if the index does not correspond to a parameter.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(IDI)Z".
      accessFlags - the access flags of the method, e.g. 0.
      variableIndex - the variable index of the parameter, e.g. 4.
      Returns:
      the parameter number in the descriptor, e.g. 3.
    • internalMethodParameterNumber

      public static int internalMethodParameterNumber(String internalMethodDescriptor, boolean isStatic, int variableIndex)
      Returns the parameter number in the given internal method descriptor, corresponding to the given variable index. This accounts for long and double parameters taking up two spaces, and a non-static method taking up an additional entry. The method returns 0 if the index corresponds to the 'this' parameter and -1 if the index does not correspond to a parameter.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(IDI)Z".
      isStatic - specifies whether the method is static, e.g. false.
      variableIndex - the variable index of the parameter, e.g. 4.
      Returns:
      the parameter number in the descriptor, e.g. 3.
    • internalMethodVariableIndex

      public static int internalMethodVariableIndex(String internalMethodDescriptor, int accessFlags, int parameterNumber)
      Returns the variable index corresponding to the given parameter number in the given internal method descriptor. This accounts for long and double parameters taking up two spaces, and a non-static method taking up an additional entry. The method returns 0 if the number corresponds to the 'this' parameter and -1 if the number does not correspond to a parameter.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(IDI)Z".
      accessFlags - the access flags of the method, e.g. 0.
      parameterNumber - the parameter number, e.g. 3.
      Returns:
      the corresponding variable index, e.g. 4.
    • internalMethodVariableIndex

      public static int internalMethodVariableIndex(String internalMethodDescriptor, boolean isStatic, int parameterNumber)
      Returns the parameter index in the given internal method descriptor, corresponding to the given variable number. This accounts for long and double parameters taking up two spaces, and a non-static method taking up an additional entry. The method returns 0 if the number corresponds to the 'this' parameter and -1 if the number does not correspond to a parameter.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(IDI)Z".
      isStatic - specifies whether the method is static, e.g. false.
      parameterNumber - the parameter number, e.g. 3.
      Returns:
      the corresponding variable index, e.g. 4.
    • internalMethodParameterType

      public static String internalMethodParameterType(String internalMethodDescriptor, int parameterIndex)
      Returns the internal type of the parameter in the given method descriptor, at the given index.
      Parameters:
      internalMethodDescriptor - the internal method descriptor e.g. "(IDI)Z".
      parameterIndex - the parameter index, e.g. 1.
      Returns:
      the parameter's type, e.g. "D".
    • internalTypeSize

      public static int internalTypeSize(String internalType)
      Returns the size taken up on the stack by the given internal type. The size is 1, except for long and double types, for which it is 2, and for the void type, for which 0 is returned.
      Parameters:
      internalType - the internal type, e.g. "I".
      Returns:
      the size taken up on the stack, e.g. 1.
    • internalType

      public static String internalType(String externalType)
      Converts an external type into an internal type.
      Parameters:
      externalType - the external type, e.g. "java.lang.Object[][]" or "int[] ".
      Returns:
      the internal type, e.g. "[[Ljava/lang/Object;" or "[I".
    • externalArrayTypeDimensionCount

      public static int externalArrayTypeDimensionCount(String externalType)
      Returns the number of dimensions of the given external type.
      Parameters:
      externalType - the external type, e.g. "[[Ljava/lang/Object;".
      Returns:
      the number of dimensions, e.g. 2.
    • externalType

      public static String externalType(String internalType, boolean quoted)
      Converts an internal type into an external type.
      Parameters:
      internalType - the internal type, e.g. "Ljava/lang/Object;" or " [[Ljava/lang/Object;" or "[I".
      quoted - whether the result should be quoted; should be set to true if it is going to be parsed as configuration later. Uses quotedIdentifier(String) for quoting.
      Returns:
      the external type, e.g. "java.lang.Object" or "java.lang.Object[][] " or "int[]".
      Throws:
      IllegalArgumentException - if the type is invalid.
    • externalType

      public static String externalType(String internalType)
      Converts an internal type into an external type.
      Parameters:
      internalType - the internal type, e.g. "Ljava/lang/Object;" or " [[Ljava/lang/Object;" or "[I".
      Returns:
      the external type, e.g. "java.lang.Object" or "java.lang.Object[][] " or "int[]".
      Throws:
      IllegalArgumentException - if the type is invalid.
    • externalClassForNameType

      public static String externalClassForNameType(String internalType)
      Converts an internal type into an external type, as expected by Class.forName.
      Parameters:
      internalType - the internal type, e.g. "Ljava/lang/Object;" or " [[Ljava/lang/Object;" or "[I".
      Returns:
      the external type, e.g. "java.lang.Object" or "[[Ljava.lang.Object; " or "[I".
    • isInternalMethodDescriptor

      public static boolean isInternalMethodDescriptor(String internalDescriptor)
      Returns whether the given internal descriptor String represents a method descriptor.
      Parameters:
      internalDescriptor - the internal descriptor String, e.g. "(II)Z".
      Returns:
      true if the given String is a method descriptor, false otherwise.
    • isExternalMethodNameAndArguments

      public static boolean isExternalMethodNameAndArguments(String externalMemberNameAndArguments)
      Returns whether the given member String represents an external method name with arguments.
      Parameters:
      externalMemberNameAndArguments - the external member String, e.g. "myField" or e.g. "myMethod(int,int)".
      Returns:
      true if the given String refers to a method, false otherwise.
    • externalMethodName

      public static String externalMethodName(String externalMethodNameAndArguments)
      Returns the name part of the given external method name and arguments.
      Parameters:
      externalMethodNameAndArguments - the external method name and arguments, e.g. " myMethod(int,int)".
      Returns:
      the name part of the String, e.g. "myMethod".
    • internalMethodDescriptor

      public static String internalMethodDescriptor(String externalReturnType, String externalMethodNameAndArguments)
      Converts the given external method return type and name and arguments to an internal method descriptor.
      Parameters:
      externalReturnType - the external method return type, e.g. "boolean".
      externalMethodNameAndArguments - the external method name and arguments, e.g. " myMethod(int,int)".
      Returns:
      the internal method descriptor, e.g. "(II)Z".
    • internalMethodDescriptor

      public static String internalMethodDescriptor(String externalReturnType, List<String> externalArguments)
      Converts the given external method return type and List of arguments to an internal method descriptor.
      Parameters:
      externalReturnType - the external method return type, e.g. "boolean".
      externalArguments - the external method arguments, e.g. { "int", "int" }.
      Returns:
      the internal method descriptor, e.g. "(II)Z".
    • internalMethodDescriptorFromInternalTypes

      public static String internalMethodDescriptorFromInternalTypes(String internalReturnType, List<String> internalArguments)
      Converts the given internal method return type and List of arguments to an internal method descriptor.
      Parameters:
      internalReturnType - the external method return type, e.g. "Z".
      internalArguments - the external method arguments, e.g. { "I", "I" }.
      Returns:
      the internal method descriptor, e.g. "(II)Z".
    • externalFullFieldDescription

      public static String externalFullFieldDescription(int accessFlags, String fieldName, String internalFieldDescriptor, boolean quoted)
      Converts an internal field description into an external full field description.
      Parameters:
      accessFlags - the access flags of the field.
      fieldName - the field name, e.g. "myField".
      internalFieldDescriptor - the internal field descriptor, e.g. "Z".
      quoted - whether the identifiers should be quoted; should be set to true if it is going to be parsed as configuration later. Uses quotedIdentifier(String) for quoting.
      Returns:
      the external full field description, e.g. "public boolean myField".
    • externalFullFieldDescription

      public static String externalFullFieldDescription(int accessFlags, String fieldName, String internalFieldDescriptor)
    • externalFullMethodDescription

      public static String externalFullMethodDescription(String internalClassName, int accessFlags, String internalMethodName, String internalMethodDescriptor, boolean quoted)
      Converts an internal method description into an external full method description.
      Parameters:
      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".
      quoted - whether the types and names should be quoted; should be set to true if it is going to be parsed as configuration later. Uses quotedIdentifier(String) for quoting.
      Returns:
      the external full method description, e.g. "public boolean myMethod(int,int) " or "public MyClass(int,int)".
    • externalFullMethodDescription

      public static String externalFullMethodDescription(String internalClassName, int accessFlags, String internalMethodName, String internalMethodDescriptor)
      Converts an internal method description into an external full method description.
      Parameters:
      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".
      Returns:
      the external full method description, e.g. "public boolean myMethod(int,int) " or "public MyClass(int,int)".
    • externalClassAccessFlags

      public static String externalClassAccessFlags(int accessFlags)
      Converts internal class access flags into an external access description.
      Parameters:
      accessFlags - the class access flags.
      Returns:
      the external class access description, e.g. "public final ".
    • externalClassAccessFlags

      public static String externalClassAccessFlags(int accessFlags, String prefix)
      Converts internal class access flags into an external access description.
      Parameters:
      accessFlags - the class access flags.
      prefix - a prefix that is added to each access modifier.
      Returns:
      the external class access description, e.g. "public final ".
    • externalFieldAccessFlags

      public static String externalFieldAccessFlags(int accessFlags)
      Converts internal field access flags into an external access description.
      Parameters:
      accessFlags - the field access flags.
      Returns:
      the external field access description, e.g. "public volatile ".
    • externalFieldAccessFlags

      public static String externalFieldAccessFlags(int accessFlags, String prefix)
      Converts internal field access flags into an external access description.
      Parameters:
      accessFlags - the field access flags.
      prefix - a prefix that is added to each access modifier.
      Returns:
      the external field access description, e.g. "public volatile ".
    • externalMethodAccessFlags

      public static String externalMethodAccessFlags(int accessFlags)
      Converts internal method access flags into an external access description.
      Parameters:
      accessFlags - the method access flags.
      Returns:
      the external method access description, e.g. "public synchronized ".
    • externalMethodAccessFlags

      public static String externalMethodAccessFlags(int accessFlags, String prefix)
      Converts internal method access flags into an external access description.
      Parameters:
      accessFlags - the method access flags.
      prefix - a prefix that is added to each access modifier.
      Returns:
      the external method access description, e.g. "public synchronized ".
    • externalParameterAccessFlags

      public static String externalParameterAccessFlags(int accessFlags)
      Converts internal method parameter access flags into an external access description.
      Parameters:
      accessFlags - the method parameter access flags.
      Returns:
      the external method parameter access description, e.g. "final mandated ".
    • externalParameterAccessFlags

      public static String externalParameterAccessFlags(int accessFlags, String prefix)
      Converts internal method parameter access flags into an external access description.
      Parameters:
      accessFlags - the method parameter access flags.
      prefix - a prefix that is added to each access modifier.
      Returns:
      the external method parameter access description, e.g. "final mandated ".
    • externalMethodReturnType

      public static String externalMethodReturnType(String internalMethodDescriptor)
      Converts an internal method descriptor into an external method return type.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(II)Z".
      Returns:
      the external method return type, e.g. "boolean".
    • externalModuleAccessFlags

      public static String externalModuleAccessFlags(int accessFlags)
      Converts internal module access flags into an external access description.
      Parameters:
      accessFlags - the module access flags.
      Returns:
      the external module access description, e.g. "open mandated ".
    • externalModuleAccessFlags

      public static String externalModuleAccessFlags(int accessFlags, String prefix)
      Converts internal module access flags into an external access description.
      Parameters:
      accessFlags - the module access flags.
      prefix - a prefix that is added to each access modifier.
      Returns:
      the external module access description, e.g. "final mandated ".
    • externalRequiresAccessFlags

      public static String externalRequiresAccessFlags(int accessFlags)
      Converts internal module requires access flags into an external access description.
      Parameters:
      accessFlags - the module requires access flags.
      Returns:
      the external module requires access description, e.g. "static mandated ".
    • externalRequiresAccessFlags

      public static String externalRequiresAccessFlags(int accessFlags, String prefix)
      Converts internal module requires access flags into an external access description.
      Parameters:
      accessFlags - the module requires access flags.
      prefix - a prefix that is added to each access modifier.
      Returns:
      the external module requires access description, e.g. "static mandated ".
    • externalExportsAccessFlags

      public static String externalExportsAccessFlags(int accessFlags)
      Converts internal module exports access flags into an external access description.
      Parameters:
      accessFlags - the module exports access flags.
      Returns:
      the external module exports access description, e.g. "synthetic mandated ".
    • externalExportsAccessFlags

      public static String externalExportsAccessFlags(int accessFlags, String prefix)
      Converts internal module exports access flags into an external access description.
      Parameters:
      accessFlags - the module exports access flags.
      prefix - a prefix that is added to each access modifier.
      Returns:
      the external module exports access description, e.g. "static mandated ".
    • externalOpensAccessFlags

      public static String externalOpensAccessFlags(int accessFlags)
      Converts internal module opens access flags into an external access description.
      Parameters:
      accessFlags - the module opens access flags.
      Returns:
      the external module opens access description, e.g. "synthetic mandated ".
    • externalOpensAccessFlags

      public static String externalOpensAccessFlags(int accessFlags, String prefix)
      Converts internal module opens access flags into an external access description.
      Parameters:
      accessFlags - the module opens access flags.
      prefix - a prefix that is added to each access modifier.
      Returns:
      the external module opens access description, e.g. "static mandated ".
    • externalMethodArguments

      public static String externalMethodArguments(String internalMethodDescriptor, boolean quoted)
      Converts an internal method descriptor into an external method argument description.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(II)Z".
      quoted - whether result should be quoted; should be set to true if it is going to be parsed as configuration later. Uses quotedIdentifier(String) for quoting.
      Returns:
      the external method argument description, e.g. "int,int".
    • externalMethodArguments

      public static String externalMethodArguments(String internalMethodDescriptor)
      Converts an internal method descriptor into an external method argument description.
      Parameters:
      internalMethodDescriptor - the internal method descriptor, e.g. "(II)Z".
      Returns:
      the external method argument description, e.g. "int,int".
    • internalPackageName

      public static String internalPackageName(String internalClassName)
      Returns the internal package name of the given internal class name.
      Parameters:
      internalClassName - the internal class name, e.g. "java/lang/Object".
      Returns:
      the internal package name, e.g. "java/lang".
    • internalPackagePrefix

      public static String internalPackagePrefix(String internalClassName)
      Returns the internal package prefix of the given internal class name.
      Parameters:
      internalClassName - the internal class name, e.g. "java/lang/Object".
      Returns:
      the internal package prefix, e.g. "java/lang/".
    • externalPackageName

      public static String externalPackageName(String externalClassName)
      Returns the external package name of the given external class name.
      Parameters:
      externalClassName - the external class name, e.g. "java.lang.Object".
      Returns:
      the external package name, e.g. "java.lang".
    • externalPackagePrefix

      public static String externalPackagePrefix(String externalClassName)
      Returns the external package prefix of the given external class name.
      Parameters:
      externalClassName - the external class name, e.g. "java.lang.Object".
      Returns:
      the external package prefix, e.g. "java.lang.".
    • isExtendable

      public static boolean isExtendable(Clazz clazz)
      Returns `true` if a Clazz is null or if it does not represent a final class. This means that for the sake of our analysis we can consider value of this class not extendable.
    • quotedIdentifier

      public static String quotedIdentifier(String identifier)
      Wraps given identifier in quotes in case it's empty, or it contains space character. Quotes and backslashes in the input will be escaped.
      Parameters:
      identifier - unquoted input identifier
      Returns:
      quoted identifier