|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jdt.internal.compiler.ClassFile
public class ClassFile
Represents a class file wrapper on bytes, it is aware of its actual type name. Public APIs are listed below: byte[] getBytes(); Answer the actual bytes of the class file char[][] getCompoundName(); Answer the compound name of the class file. For example, {{java}, {util}, {Hashtable}}. byte[] getReducedBytes(); Answer a smaller byte format, which is only contains some structural information. Those bytes are decodable with a regular class file reader, such as DietClassFileReader
Field Summary | |
---|---|
CodeStream |
codeStream
|
ConstantPool |
constantPool
|
int |
constantPoolOffset
|
byte[] |
contents
|
int |
contentsOffset
|
protected boolean |
creatingProblemType
|
ClassFile |
enclosingClassFile
|
byte[] |
header
|
int |
headerOffset
|
static int |
INITIAL_CONTENTS_SIZE
|
static int |
INITIAL_HEADER_SIZE
|
static int |
INNER_CLASSES_SIZE
|
ReferenceBinding[] |
innerClassesBindings
|
boolean |
isShared
|
int |
methodCount
|
int |
methodCountOffset
|
int |
numberOfInnerClasses
|
int |
produceAttributes
|
SourceTypeBinding |
referenceBinding
|
long |
targetJDK
|
Constructor Summary | |
---|---|
protected |
ClassFile()
INTERNAL USE-ONLY This methods creates a new instance of the receiver. |
|
ClassFile(SourceTypeBinding typeBinding)
|
Method Summary | |
---|---|
void |
addAbstractMethod(AbstractMethodDeclaration method,
MethodBinding methodBinding)
INTERNAL USE-ONLY Generate the byte for a problem method info that correspond to a boggus method. |
void |
addAttributes()
INTERNAL USE-ONLY This methods generate all the attributes for the receiver. |
void |
addDefaultAbstractMethods()
INTERNAL USE-ONLY This methods generate all the default abstract method infos that correpond to the abstract methods inherited from superinterfaces. |
void |
addFieldInfos()
INTERNAL USE-ONLY This methods generate all the fields infos for the receiver. |
void |
addProblemClinit(CategorizedProblem[] problems)
INTERNAL USE-ONLY Generate the byte for a problem clinit method info that correspond to a boggus method. |
void |
addProblemConstructor(AbstractMethodDeclaration method,
MethodBinding methodBinding,
CategorizedProblem[] problems)
INTERNAL USE-ONLY Generate the byte for a problem method info that correspond to a boggus constructor. |
void |
addProblemConstructor(AbstractMethodDeclaration method,
MethodBinding methodBinding,
CategorizedProblem[] problems,
int savedOffset)
INTERNAL USE-ONLY Generate the byte for a problem method info that correspond to a boggus constructor. |
void |
addProblemMethod(AbstractMethodDeclaration method,
MethodBinding methodBinding,
CategorizedProblem[] problems)
INTERNAL USE-ONLY Generate the byte for a problem method info that correspond to a boggus method. |
void |
addProblemMethod(AbstractMethodDeclaration method,
MethodBinding methodBinding,
CategorizedProblem[] problems,
int savedOffset)
INTERNAL USE-ONLY Generate the byte for a problem method info that correspond to a boggus method. |
void |
addSpecialMethods()
INTERNAL USE-ONLY Generate the byte for all the special method infos. |
void |
addSyntheticConstructorAccessMethod(SyntheticMethodBinding methodBinding)
INTERNAL USE-ONLY Generate the bytes for a synthetic method that provides an access to a private constructor. |
void |
addSyntheticEnumValueOfMethod(SyntheticMethodBinding methodBinding)
INTERNAL USE-ONLY Generate the bytes for a synthetic method that implements Enum#valueOf(String) for a given enum type |
void |
addSyntheticEnumValuesMethod(SyntheticMethodBinding methodBinding)
INTERNAL USE-ONLY Generate the bytes for a synthetic method that implements Enum#values() for a given enum type |
void |
addSyntheticFieldReadAccessMethod(SyntheticMethodBinding methodBinding)
INTERNAL USE-ONLY Generate the byte for a problem method info that correspond to a synthetic method that generate an read access to a private field. |
void |
addSyntheticFieldWriteAccessMethod(SyntheticMethodBinding methodBinding)
INTERNAL USE-ONLY Generate the byte for a problem method info that correspond to a synthetic method that generate an write access to a private field. |
void |
addSyntheticMethodAccessMethod(SyntheticMethodBinding methodBinding)
INTERNAL USE-ONLY Generate the bytes for a synthetic method that provides access to a private method. |
void |
addSyntheticSwitchTable(SyntheticMethodBinding methodBinding)
|
static java.lang.String |
buildAllDirectoriesInto(java.lang.String outputPath,
java.lang.String relativeFileName)
INTERNAL USE-ONLY Build all the directories and subdirectories corresponding to the packages names into the directory specified in parameters. |
void |
completeCodeAttribute(int codeAttributeOffset)
INTERNAL USE-ONLY That method completes the creation of the code attribute by setting - the attribute_length - max_stack - max_locals - code_length - exception table - and debug attributes if necessary. |
void |
completeCodeAttributeForClinit(int codeAttributeOffset)
INTERNAL USE-ONLY That method completes the creation of the code attribute by setting - the attribute_length - max_stack - max_locals - code_length - exception table - and debug attributes if necessary. |
void |
completeCodeAttributeForClinit(int codeAttributeOffset,
int problemLine)
INTERNAL USE-ONLY That method completes the creation of the code attribute by setting - the attribute_length - max_stack - max_locals - code_length - exception table - and debug attributes if necessary. |
void |
completeCodeAttributeForMissingAbstractProblemMethod(MethodBinding binding,
int codeAttributeOffset,
int[] startLineIndexes,
int problemLine)
|
void |
completeCodeAttributeForProblemMethod(AbstractMethodDeclaration method,
MethodBinding binding,
int codeAttributeOffset,
int[] startLineIndexes,
int problemLine)
INTERNAL USE-ONLY That method completes the creation of the code attribute by setting - the attribute_length - max_stack - max_locals - code_length - exception table - and debug attributes if necessary. |
void |
completeCodeAttributeForSyntheticMethod(boolean hasExceptionHandlers,
SyntheticMethodBinding binding,
int codeAttributeOffset,
int[] startLineIndexes)
INTERNAL USE-ONLY That method completes the creation of the code attribute by setting - the attribute_length - max_stack - max_locals - code_length - exception table - and debug attributes if necessary. |
void |
completeCodeAttributeForSyntheticMethod(SyntheticMethodBinding binding,
int codeAttributeOffset,
int[] startLineIndexes)
INTERNAL USE-ONLY That method completes the creation of the code attribute by setting - the attribute_length - max_stack - max_locals - code_length - exception table - and debug attributes if necessary. |
void |
completeMethodInfo(int methodAttributeOffset,
int attributeNumber)
INTERNAL USE-ONLY Complete the creation of a method info by setting up the number of attributes at the right offset. |
static void |
createProblemType(TypeDeclaration typeDeclaration,
CompilationResult unitResult)
INTERNAL USE-ONLY Request the creation of a ClassFile compatible representation of a problematic type |
char[] |
fileName()
INTERNAL USE-ONLY This methods returns a char[] representing the file name of the receiver |
void |
generateCodeAttributeHeader()
INTERNAL USE-ONLY That method generates the header of a code attribute. |
int |
generateMethodInfoAttribute(MethodBinding methodBinding)
|
int |
generateMethodInfoAttribute(MethodBinding methodBinding,
AnnotationMethodDeclaration declaration)
|
int |
generateMethodInfoAttribute(MethodBinding methodBinding,
boolean createProblemMethod)
INTERNAL USE-ONLY That method generates the attributes of a code attribute. |
void |
generateMethodInfoHeader(MethodBinding methodBinding)
INTERNAL USE-ONLY That method generates the header of a method info: The header consists in: - the access flags - the name index of the method name inside the constant pool - the descriptor index of the signature of the method inside the constant pool. |
void |
generateMethodInfoHeader(MethodBinding methodBinding,
int accessFlags)
INTERNAL USE-ONLY That method generates the header of a method info: The header consists in: - the access flags - the name index of the method name inside the constant pool - the descriptor index of the signature of the method inside the constant pool. |
void |
generateMethodInfoHeaderForClinit()
INTERNAL USE-ONLY That method generates the method info header of a clinit: The header consists in: - the access flags (always default access + static) - the name index of the method name (always |
void |
generateMissingAbstractMethods(MethodDeclaration[] methodDeclarations,
CompilationResult compilationResult)
INTERNAL USE-ONLY Generate the byte for problem method infos that correspond to missing abstract methods. |
byte[] |
getBytes()
EXTERNAL API Answer the actual bytes of the class file This method encodes the receiver structure into a byte array which is the content of the classfile. |
char[][] |
getCompoundName()
EXTERNAL API Answer the compound name of the class file. |
static ClassFile |
getNewInstance(SourceTypeBinding typeBinding)
|
protected void |
initByteArrays()
|
void |
initialize(SourceTypeBinding aType,
ClassFile parentClassFile,
boolean createProblemType)
|
ClassFile |
outerMostEnclosingClassFile()
INTERNAL USE-ONLY Returns the most enclosing classfile of the receiver. |
void |
recordEnclosingTypeAttributes(ReferenceBinding binding)
INTERNAL USE-ONLY This is used to store a new inner class. |
void |
recordNestedLocalAttribute(ReferenceBinding binding)
INTERNAL USE-ONLY This is used to store a new inner class. |
void |
recordNestedMemberAttribute(ReferenceBinding binding)
INTERNAL USE-ONLY This is used to store a new inner class. |
void |
reset(SourceTypeBinding typeBinding)
|
static int |
searchLineNumber(int[] startLineIndexes,
int position)
INTERNAL USE-ONLY Search the line number corresponding to a specific position |
void |
setForMethodInfos()
INTERNAL USE-ONLY This methods leaves the space for method counts recording. |
static void |
writeToDisk(boolean generatePackagesStructure,
java.lang.String outputPath,
java.lang.String relativeFileName,
ClassFile classFile)
INTERNAL USE-ONLY outputPath is formed like: c:\temp\ the last character is a file separator relativeFileName is formed like: java\lang\String.class |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public CodeStream codeStream
public ConstantPool constantPool
public int constantPoolOffset
public byte[] contents
public int contentsOffset
protected boolean creatingProblemType
public ClassFile enclosingClassFile
public byte[] header
public int headerOffset
public ReferenceBinding[] innerClassesBindings
public int methodCount
public int methodCountOffset
public int numberOfInnerClasses
public boolean isShared
public int produceAttributes
public SourceTypeBinding referenceBinding
public long targetJDK
public static final int INITIAL_CONTENTS_SIZE
public static final int INITIAL_HEADER_SIZE
public static final int INNER_CLASSES_SIZE
Constructor Detail |
---|
protected ClassFile()
public ClassFile(SourceTypeBinding typeBinding)
Method Detail |
---|
public static java.lang.String buildAllDirectoriesInto(java.lang.String outputPath, java.lang.String relativeFileName) throws java.io.IOException
outputPath
- java.lang.StringrelativeFileName
- java.lang.String
java.io.IOException
public static void createProblemType(TypeDeclaration typeDeclaration, CompilationResult unitResult)
typeDeclaration
- org.eclipse.jdt.internal.compiler.ast.TypeDeclarationunitResult
- org.eclipse.jdt.internal.compiler.CompilationUnitResultpublic static ClassFile getNewInstance(SourceTypeBinding typeBinding)
public static final int searchLineNumber(int[] startLineIndexes, int position)
public static void writeToDisk(boolean generatePackagesStructure, java.lang.String outputPath, java.lang.String relativeFileName, ClassFile classFile) throws java.io.IOException
generatePackagesStructure
- a flag to know if the packages structure has to be generated.outputPath
- the given output directoryrelativeFileName
- the given relative file nameclassFile
- the given classFile to write
java.io.IOException
public void addAbstractMethod(AbstractMethodDeclaration method, MethodBinding methodBinding)
method
- org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclarationmethodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.MethodBindingpublic void addAttributes()
public void addDefaultAbstractMethods()
public void addFieldInfos()
public void addProblemClinit(CategorizedProblem[] problems)
problems
- org.eclipse.jdt.internal.compiler.problem.Problem[]public void addProblemConstructor(AbstractMethodDeclaration method, MethodBinding methodBinding, CategorizedProblem[] problems)
method
- org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclarationmethodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.MethodBindingproblems
- org.eclipse.jdt.internal.compiler.problem.Problem[]public void addProblemConstructor(AbstractMethodDeclaration method, MethodBinding methodBinding, CategorizedProblem[] problems, int savedOffset)
method
- org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclarationmethodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.MethodBindingproblems
- org.eclipse.jdt.internal.compiler.problem.Problem[]savedOffset
- int
public void addProblemMethod(AbstractMethodDeclaration method, MethodBinding methodBinding, CategorizedProblem[] problems)
method
- org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclarationmethodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.MethodBindingproblems
- org.eclipse.jdt.internal.compiler.problem.Problem[]public void addProblemMethod(AbstractMethodDeclaration method, MethodBinding methodBinding, CategorizedProblem[] problems, int savedOffset)
method
- org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclarationmethodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.MethodBindingproblems
- org.eclipse.jdt.internal.compiler.problem.Problem[]savedOffset
- int
public void addSpecialMethods()
public void addSyntheticConstructorAccessMethod(SyntheticMethodBinding methodBinding)
methodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBindingpublic void addSyntheticEnumValueOfMethod(SyntheticMethodBinding methodBinding)
methodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBindingpublic void addSyntheticEnumValuesMethod(SyntheticMethodBinding methodBinding)
methodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBindingpublic void addSyntheticFieldReadAccessMethod(SyntheticMethodBinding methodBinding)
methodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBindingpublic void addSyntheticFieldWriteAccessMethod(SyntheticMethodBinding methodBinding)
methodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBindingpublic void addSyntheticMethodAccessMethod(SyntheticMethodBinding methodBinding)
methodBinding
- org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBindingpublic void addSyntheticSwitchTable(SyntheticMethodBinding methodBinding)
public void completeCodeAttribute(int codeAttributeOffset)
codeAttributeOffset
- int
public void completeCodeAttributeForClinit(int codeAttributeOffset)
codeAttributeOffset
- int
public void completeCodeAttributeForClinit(int codeAttributeOffset, int problemLine)
public void completeCodeAttributeForMissingAbstractProblemMethod(MethodBinding binding, int codeAttributeOffset, int[] startLineIndexes, int problemLine)
public void completeCodeAttributeForProblemMethod(AbstractMethodDeclaration method, MethodBinding binding, int codeAttributeOffset, int[] startLineIndexes, int problemLine)
codeAttributeOffset
- int
public void completeCodeAttributeForSyntheticMethod(boolean hasExceptionHandlers, SyntheticMethodBinding binding, int codeAttributeOffset, int[] startLineIndexes)
binding
- org.eclipse.jdt.internal.compiler.lookup.SyntheticAccessMethodBindingcodeAttributeOffset
- int
public void completeCodeAttributeForSyntheticMethod(SyntheticMethodBinding binding, int codeAttributeOffset, int[] startLineIndexes)
binding
- org.eclipse.jdt.internal.compiler.lookup.SyntheticAccessMethodBindingcodeAttributeOffset
- int
public void completeMethodInfo(int methodAttributeOffset, int attributeNumber)
methodAttributeOffset
- int
attributeNumber
- int
public char[] fileName()
public void generateCodeAttributeHeader()
public int generateMethodInfoAttribute(MethodBinding methodBinding)
public int generateMethodInfoAttribute(MethodBinding methodBinding, AnnotationMethodDeclaration declaration)
public int generateMethodInfoAttribute(MethodBinding methodBinding, boolean createProblemMethod)
methodBinding
- org.eclipse.jdt.internal.compiler.lookup.MethodBinding
int
public void generateMethodInfoHeader(MethodBinding methodBinding)
methodBinding
- org.eclipse.jdt.internal.compiler.lookup.MethodBindingpublic void generateMethodInfoHeader(MethodBinding methodBinding, int accessFlags)
methodBinding
- org.eclipse.jdt.internal.compiler.lookup.MethodBindingaccessFlags
- the access flagspublic void generateMethodInfoHeaderForClinit()
public void generateMissingAbstractMethods(MethodDeclaration[] methodDeclarations, CompilationResult compilationResult)
methodDeclarations
- Array of all missing abstract methodspublic byte[] getBytes()
public char[][] getCompoundName()
protected void initByteArrays()
public void initialize(SourceTypeBinding aType, ClassFile parentClassFile, boolean createProblemType)
public ClassFile outerMostEnclosingClassFile()
public void recordEnclosingTypeAttributes(ReferenceBinding binding)
binding
- org.eclipse.jdt.internal.compiler.lookup.ReferenceBindingpublic void recordNestedLocalAttribute(ReferenceBinding binding)
binding
- org.eclipse.jdt.internal.compiler.lookup.ReferenceBindingpublic void recordNestedMemberAttribute(ReferenceBinding binding)
binding
- org.eclipse.jdt.internal.compiler.lookup.ReferenceBindingpublic void reset(SourceTypeBinding typeBinding)
public void setForMethodInfos()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |