public class ClassFileReader extends ClassFileStruct implements IBinaryType
| Modifier and Type | Class and Description |
|---|---|
static interface |
ClassFileReader.ZipFileProducer
Auxiliary interface for
setExternalAnnotationProvider(String,String,ZipFile,ZipFileProducer). |
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.
|
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 signature which describes the parameter &
return types as specified in section 4.4.4 of the Java 2 VM spec 3rd edition.
|
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[] |
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.
|
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 |
hasAnnotationProvider() |
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 type, false otherwise
|
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 type, false otherwise
|
boolean |
isMember()
Answer true if the receiver is a member type, false otherwise
|
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) |
java.util.zip.ZipFile |
setExternalAnnotationProvider(java.lang.String basePath,
java.lang.String qualifiedBinaryTypeName,
java.util.zip.ZipFile zipFile,
ClassFileReader.ZipFileProducer producer)
Create and remember a provider for external annotations using the given basePath,
which is either a directory holding .eea text files, or a zip file of entries of the same format.
|
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 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 java.util.zip.ZipFile setExternalAnnotationProvider(java.lang.String basePath,
java.lang.String qualifiedBinaryTypeName,
java.util.zip.ZipFile zipFile,
ClassFileReader.ZipFileProducer producer)
throws java.io.IOException
basePath - resolved filesystem path of either directory or zip filequalifiedBinaryTypeName - slash-separated type namezipFile - an existing zip file for the same basePath, or null.
Output: wl be filled withproducer - an optional helper to produce the zipFile when needed.java.io.IOException - any unexpected errors during file access. File not found while
accessing an individual file if basePath is a directory is expected,
and simply answered with null. If basePath is neither a directory nor a zip file,
this is unexpected.public boolean hasAnnotationProvider()
public 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[] getFileName()
IDependentgetFileName in interface IDependentIDependent.getFileName()public char[] getGenericSignature()
IBinaryTypegetGenericSignature in interface IBinaryTypepublic char[] getInnerSourceName()
public char[][] getInterfaceNames()
getInterfaceNames 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()
getName in interface IBinaryTypepublic char[] getSourceName()
IBinaryTypegetSourceName in interface IBinaryTypepublic char[] getSuperclassName()
getSuperclassName 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()
isAnonymous in interface IBinaryTypebooleanpublic boolean isBinaryType()
isBinaryType in interface IGenericTypepublic boolean isLocal()
isLocal in interface IBinaryTypebooleanpublic boolean isMember()
isMember in interface IBinaryTypebooleanpublic boolean isNestedType()
booleanpublic char[] sourceFileName()
sourceFileName in interface IBinaryTypepublic java.lang.String toString()
toString in class java.lang.Objectpublic byte[] getReferenceBytes()