public class ClassFileReader extends ClassFileStruct implements IBinaryType
| Modifier and Type | Field and Description |
|---|---|
char[] |
moduleName |
NoField, NoInterface, NoMethod, NoNestedTypeJAR_FILE_ENTRY_SEPARATOR| Constructor and Description |
|---|
ClassFileReader(byte[] classFileBytes,
char[] fileName) |
ClassFileReader(byte[] classFileBytes,
char[] fileName,
boolean fullyInitialize) |
| Modifier and Type | Method and Description |
|---|---|
int |
accessFlags()
Answer the receiver's access flags.
|
ITypeAnnotationWalker |
enrichWithExternalAnnotationsFor(ITypeAnnotationWalker walker,
java.lang.Object member,
LookupEnvironment environment)
Conditionally add external annotations to the mix.
|
IBinaryAnnotation[] |
getAnnotations()
Answer the runtime visible and invisible annotations for this type or null if none.
|
int[] |
getConstantPoolOffsets()
Answer the int array that corresponds to all the offsets of each entry in the constant pool
|
char[] |
getEnclosingMethod()
Answer the enclosing method (including method selector and method descriptor), or
null if none.
|
char[] |
getEnclosingTypeName()
Answer the resolved name of the enclosing type in the
class file format as specified in section 4.2 of the Java 2 VM spec
or null if the receiver is a top level type.
|
BinaryTypeBinding.ExternalAnnotationStatus |
getExternalAnnotationStatus()
Answer whether a provider for external annotations is associated with this binary type.
|
IBinaryField[] |
getFields()
Answer the receiver's this.fields or null if the array is empty.
|
char[] |
getFileName()
Answer the file name which defines the type.
|
char[] |
getGenericSignature()
Answer the receiver's ClassSignature, which describes the type parameters,
super class, and super interfaces as specified in section "4.7.9.1 Signatures"
of the Java SE 8 VM spec.
|
char[] |
getInnerSourceName()
Answer the source name if the receiver is a inner type.
|
char[][] |
getInterfaceNames()
Answer the resolved names of the receiver's interfaces in the
class file format as specified in section 4.2 of the Java 2 VM spec
or null if the array is empty.
|
IBinaryNestedType[] |
getMemberTypes()
Answer the receiver's nested types or null if the array is empty.
|
IBinaryNestedType[] |
getMemberTypes(boolean keepIncorrectlyNamedInners)
Answer the receiver's nested types or null if the array is empty.
|
IBinaryMethod[] |
getMethods()
Answer the receiver's this.methods or null if the array is empty.
|
char[][][] |
getMissingTypeNames()
Answer the list of missing type names which were referenced from
the problem classfile.
|
int |
getModifiers()
Answer an int whose bits are set according the access constants
defined by the VM spec.
|
char[] |
getModule()
Answer the module to which this type belongs.
|
IBinaryModule |
getModuleDeclaration()
Returns the module declaration that this class file represents.
|
char[] |
getName()
Answer the resolved name of the type in the
class file format as specified in section 4.2 of the Java 2 VM spec.
|
char[] |
getNestHost() |
byte[] |
getReferenceBytes() |
char[] |
getSourceName()
Answer the simple name of the type in the class file.
|
char[] |
getSuperclassName()
Answer the resolved name of the receiver's superclass in the
class file format as specified in section 4.2 of the Java 2 VM spec
or null if it does not have one.
|
long |
getTagBits()
Answer the tagbits set according to the bits for annotations.
|
IBinaryTypeAnnotation[] |
getTypeAnnotations()
Answer the runtime visible and invisible type annotations for this type or null if none.
|
long |
getVersion()
Answer the major/minor version defined in this class file according to the VM spec.
|
boolean |
hasStructuralChanges(byte[] newBytes)
Check if the receiver has structural changes compare to the byte array in argument.
|
boolean |
hasStructuralChanges(byte[] newBytes,
boolean orderRequired,
boolean excludesSynthetic)
Check if the receiver has structural changes compare to the byte array in argument.
|
boolean |
isAnonymous()
Answer true if the receiver is an anonymous class.
|
boolean |
isBinaryType()
Answer whether the receiver contains the resolved binary form
or the unresolved source form of the type.
|
boolean |
isLocal()
Answer true if the receiver is a local class.
|
boolean |
isMember()
Answer true if the receiver is a member class.
|
boolean |
isNestedType()
Answer true if the receiver is a nested type, false otherwise
|
static ClassFileReader |
read(java.io.File file) |
static ClassFileReader |
read(java.io.File file,
boolean fullyInitialize) |
static ClassFileReader |
read(java.io.InputStream stream,
java.lang.String fileName) |
static ClassFileReader |
read(java.io.InputStream stream,
java.lang.String fileName,
boolean fullyInitialize) |
static ClassFileReader |
read(java.lang.String fileName) |
static ClassFileReader |
read(java.lang.String fileName,
boolean fullyInitialize) |
static ClassFileReader |
read(java.util.zip.ZipFile zip,
java.lang.String filename) |
static ClassFileReader |
read(java.util.zip.ZipFile zip,
java.lang.String filename,
boolean fullyInitialize) |
static ClassFileReader |
readFromJrt(java.io.File jrt,
IModule module,
java.lang.String filename) |
static ClassFileReader |
readFromModule(java.io.File jrt,
java.lang.String moduleName,
java.lang.String filename,
java.util.function.Predicate<java.lang.String> moduleNameFilter) |
char[] |
sourceFileName()
Answer the source file name attribute.
|
java.lang.String |
toString() |
public ClassFileReader(byte[] classFileBytes,
char[] fileName)
throws ClassFormatException
classFileBytes - Actual bytes of a .class filefileName - Actual name of the file that contains the bytes, can be nullClassFormatExceptionpublic ClassFileReader(byte[] classFileBytes,
char[] fileName,
boolean fullyInitialize)
throws ClassFormatException
classFileBytes - byte[]
Actual bytes of a .class filefileName - char[]
Actual name of the file that contains the bytes, can be nullfullyInitialize - boolean
Flag to fully initialize the new objectClassFormatExceptionpublic static ClassFileReader read(java.io.File file) throws ClassFormatException, java.io.IOException
ClassFormatExceptionjava.io.IOExceptionpublic static ClassFileReader read(java.io.File file, boolean fullyInitialize) throws ClassFormatException, java.io.IOException
ClassFormatExceptionjava.io.IOExceptionpublic static ClassFileReader read(java.io.InputStream stream, java.lang.String fileName) throws ClassFormatException, java.io.IOException
ClassFormatExceptionjava.io.IOExceptionpublic static ClassFileReader read(java.io.InputStream stream, java.lang.String fileName, boolean fullyInitialize) throws ClassFormatException, java.io.IOException
ClassFormatExceptionjava.io.IOExceptionpublic static ClassFileReader read(java.util.zip.ZipFile zip, java.lang.String filename) throws ClassFormatException, java.io.IOException
ClassFormatExceptionjava.io.IOExceptionpublic static ClassFileReader readFromJrt(java.io.File jrt, IModule module, java.lang.String filename) throws ClassFormatException, java.io.IOException
ClassFormatExceptionjava.io.IOExceptionpublic static ClassFileReader readFromModule(java.io.File jrt, java.lang.String moduleName, java.lang.String filename, java.util.function.Predicate<java.lang.String> moduleNameFilter) throws ClassFormatException, java.io.IOException
ClassFormatExceptionjava.io.IOExceptionpublic static ClassFileReader read(java.util.zip.ZipFile zip, java.lang.String filename, boolean fullyInitialize) throws ClassFormatException, java.io.IOException
ClassFormatExceptionjava.io.IOExceptionpublic static ClassFileReader read(java.lang.String fileName) throws ClassFormatException, java.io.IOException
ClassFormatExceptionjava.io.IOExceptionpublic static ClassFileReader read(java.lang.String fileName, boolean fullyInitialize) throws ClassFormatException, java.io.IOException
ClassFormatExceptionjava.io.IOExceptionpublic char[] getNestHost()
public BinaryTypeBinding.ExternalAnnotationStatus getExternalAnnotationStatus()
IBinaryTypegetExternalAnnotationStatus in interface IBinaryTypepublic ITypeAnnotationWalker enrichWithExternalAnnotationsFor(ITypeAnnotationWalker walker, java.lang.Object member, LookupEnvironment environment)
enrichWithExternalAnnotationsFor in interface IBinaryTypewalker - previous walker, may be empty, otherwise it will be returned unchangedmember - if either a IBinaryField or a IBinaryMethod is provided, answer a walker specifically for that memberenvironment - for use by the walkerpublic int accessFlags()
public IBinaryAnnotation[] getAnnotations()
IBinaryTypegetAnnotations in interface IBinaryTypepublic IBinaryTypeAnnotation[] getTypeAnnotations()
IBinaryTypegetTypeAnnotations in interface IBinaryTypepublic int[] getConstantPoolOffsets()
public char[] getEnclosingMethod()
IBinaryTypegetEnclosingMethod in interface IBinaryTypepublic char[] getEnclosingTypeName()
IBinaryTypegetEnclosingTypeName in interface IBinaryTypepublic IBinaryField[] getFields()
getFields in interface IBinaryTypepublic char[] getModule()
IBinaryTypenull if the type is associated to the unnamed module.getModule in interface IBinaryTypenullIBinaryType.getModule()public IBinaryModule getModuleDeclaration()
public char[] getFileName()
IDependentgetFileName in interface IDependentIDependent.getFileName()public char[] getGenericSignature()
IBinaryTypegetGenericSignature in interface IBinaryTypepublic char[] getInnerSourceName()
public char[][] getInterfaceNames()
IBinaryTypegetInterfaceNames in interface IBinaryTypepublic IBinaryNestedType[] getMemberTypes()
IBinaryTypegetMemberTypes in interface IBinaryTypepublic IBinaryNestedType[] getMemberTypes(boolean keepIncorrectlyNamedInners)
public IBinaryMethod[] getMethods()
getMethods in interface IBinaryTypepublic char[][][] getMissingTypeNames()
IBinaryTypegetMissingTypeNames in interface IBinaryTypepublic int getModifiers()
getModifiers in interface IGenericTypepublic char[] getName()
IBinaryTypegetName in interface IBinaryTypepublic char[] getSourceName()
IBinaryTypegetSourceName in interface IBinaryTypepublic char[] getSuperclassName()
IBinaryTypegetSuperclassName in interface IBinaryTypepublic long getTagBits()
IBinaryTypegetTagBits in interface IBinaryTypepublic long getVersion()
public boolean hasStructuralChanges(byte[] newBytes)
newBytes - the bytes of the .class file we want to compare the receiver topublic boolean hasStructuralChanges(byte[] newBytes,
boolean orderRequired,
boolean excludesSynthetic)
newBytes - the bytes of the .class file we want to compare the receiver toorderRequired - a boolean indicating whether the members should be sorted or notexcludesSynthetic - a boolean indicating whether the synthetic members should be used in the comparisonpublic boolean isAnonymous()
IBinaryTypeisAnonymous in interface IBinaryTypepublic boolean isBinaryType()
IGenericTypeisBinaryType in interface IGenericTypepublic boolean isLocal()
IBinaryTypeisLocal in interface IBinaryTypepublic boolean isMember()
IBinaryTypeisMember in interface IBinaryTypepublic boolean isNestedType()
booleanpublic char[] sourceFileName()
sourceFileName in interface IBinaryTypepublic java.lang.String toString()
toString in class java.lang.Objectpublic byte[] getReferenceBytes()