public class MethodToolkit extends Object
IMCType
and IMCMethod
implementations and to handle
conversion of reference types and field descriptors according to The Java Virtual Machine
Specification, Section 4.4.1 and Section 4.3.2, respectively, into Java type formats
according to The Java Language Specification, Sections 6.7 and 13.1.Modifier and Type | Method and Description |
---|---|
static String |
binaryNameToCanonical(String binaryName)
Convert a binary name to a canonical name, as defined in The Java Language
Specification, Sections 6.7 and 13.1, respectively.
|
static int |
fieldDescToBinaryJLS(CharSequence desc,
int start,
Appendable out)
Convert the field descriptor, according to The Java Virtual Machine Specification,
Section 4.3.2, starting at position
start in desc , into a binary Java type
name according to The Java Language Specification, Section 13.1. |
static String |
fieldDescToBinaryJLS(String fieldDesc)
Convert a field descriptor according to The Java Virtual Machine Specification,
Section 4.3.2, into a binary Java type name according to The Java Language
Specification, Section 13.1.
|
static String |
formatQualifiedName(IMCPackage mcPackage,
String className)
Create a fully qualified class name based on a package.
|
static Boolean |
hasNestedTypes(String className)
Check if a class name denotes a nested class.
|
static Boolean |
isArray(String typeName)
Check if a type name denotes an array.
|
static boolean |
isDescOrRefArray(String fieldDesc)
Check if a field descriptor or a reference type according to The Java Virtual Machine
Specification, Sections 4.3.2 and 4.4.1 respectively, designates an array.
|
static boolean |
isDescPrimitive(String fieldDesc)
Check if a field descriptor according to The Java Virtual Machine Specification,
Section 4.3.2, designates a primitive type.
|
static boolean |
isPrimitive(String typeName)
Check if a type name denotes a primitive type.
|
static String |
nestedTypes(String className)
Get the nested type name of a class.
|
static String |
refTypeToBinaryJLS(String refType)
Convert a reference type according to The Java Virtual Machine Specification, Section
4.4.1, into a binary Java type name according to The Java Language Specification,
Section 13.1.
|
static String |
refTypeToFieldDescriptor(String refType)
Convert a reference type according to The Java Virtual Machine Specification, Section
4.4.1, into a field descriptor according to The Java Virtual Machine Specification,
Section 4.3.2.
|
static String |
topLevelType(String className)
Get the top level type of a class.
|
static IMCType |
typeFromBinaryJLS(String jlsType)
Convert a binary Java type name according to The Java Language Specification, Section
13.1, into an
IMCType . |
static IMCType |
typeFromReference(String refType)
Convert a reference type according to The Java Virtual Machine Specification, Section
4.4.1, into an
IMCType . |
public static boolean isPrimitive(String typeName)
typeName
- type name to checktrue
if the type is primitive, false
if notpublic static String formatQualifiedName(IMCPackage mcPackage, String className)
mcPackage
- package for the classclassName
- class namepublic static Boolean hasNestedTypes(String className)
className
- class name to checktrue
if the class is nested, false
if notpublic static String topLevelType(String className)
className
- class name with possible nested componentspublic static String nestedTypes(String className)
className
- class name with possible nested componentsnull
if there is no nested classpublic static Boolean isArray(String typeName)
typeName
- type name to checktrue
if the type is an array, false
if notpublic static String refTypeToFieldDescriptor(String refType)
refType
- the reference type to convertpublic static String binaryNameToCanonical(String binaryName)
binaryName
- the binary name to convertpublic static String refTypeToBinaryJLS(String refType) throws IllegalArgumentException
refType
- the reference type to convertIllegalArgumentException
- if refType
is not a valid reference typepublic static IMCType typeFromReference(String refType) throws IllegalArgumentException
IMCType
.refType
- the reference type to convertIllegalArgumentException
- if refType
is not a valid reference typepublic static IMCType typeFromBinaryJLS(String jlsType) throws IllegalArgumentException
IMCType
.jlsType
- the JLS type name to convertIllegalArgumentException
- if refType
is not a valid reference typepublic static String fieldDescToBinaryJLS(String fieldDesc) throws IllegalArgumentException
fieldDesc
- the field descriptor (according to the JVM Specification) to convertIllegalArgumentException
- if fieldDesc
is not a valid field descriptorpublic static int fieldDescToBinaryJLS(CharSequence desc, int start, Appendable out) throws IllegalArgumentException, IOException
start
in desc
, into a binary Java type
name according to The Java Language Specification, Section 13.1. and appends it to
out
.desc
- a CharSequence
containing the field descriptor (according to the JVM
Specification) to convertstart
- the position in desc
where the descriptor to convert startsout
- an Appendable
to which the result will be appendeddesc
not convertedIllegalArgumentException
- if desc
is not a valid field descriptorIOException
- If an I/O error occurs when appending to out
. Note that this cannot
happen when using StringBuilder
or StringBuffer
.public static boolean isDescOrRefArray(String fieldDesc)
fieldDesc
- a non-null field descriptor or reference type (according to the JVM Specification)public static boolean isDescPrimitive(String fieldDesc)
fieldDesc
- a non-null field descriptor (according to the JVM Specification)Copyright © 2020. All rights reserved.