Class ClassNamesUtil
- java.lang.Object
-
- net.sourceforge.pmd.lang.java.symbols.internal.asm.ClassNamesUtil
-
public final class ClassNamesUtil extends Object
When dealing with classes we have to handle a bunch of different kinds of names. From higher level to lower level:- Canonical name:
a.b.C.D
- Binary name:
a.b.C$D
- Internal name:
a/b/C$D
Canonical names are on the Java language level. They are how you type a reference to a class from an another arbitrary class. Some classes may not even have one, eg local classes cannot be referenced from outside their scope.
Binary names lift the ambiguity between inner class selection and package name that exists in canonical names. They're more convenient to work with when loading classes. They're typically the kind of name you find when using reflective APIs.
Internal names are burned into class files are they allow getting a file path to the referenced class file just by appending
.class
. They are only useful at the level of class files, eg when using ASM.Type descriptors are another class of "names" that use internal names, but are more general, as they can represent all kinds of types. Eg the type descriptor for class
a.b.C.D
isLa/b/C$D;
, the one ofboolean
isZ
, and the one ofboolean[]
is[Z
.Type signatures are a superset of type descriptors that can also represent generic types. These need to be parsed when reading info from a class file.
- Canonical name:
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
binaryToInternal(String binary)
static String
classDescriptorToBinaryName(String descriptor)
static String
classDescriptorToInternalName(String descriptor)
static String
getInternalName(Class<?> klass)
static String
getTypeDescriptor(Class<?> klass)
static String
internalToBinaryName(String internal)
-