| java.lang.Object org.eclipse.jdt.internal.compiler.ClassFile
All known Subclasses: org.eclipse.jdt.internal.eval.CodeSnippetClassFile,
ClassFile | public class ClassFile implements TypeConstants,TypeIds(Code) | | 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
|
Method Summary | |
public void | addAbstractMethod(AbstractMethodDeclaration method, MethodBinding methodBinding) INTERNAL USE-ONLY
Generate the byte for a problem method info that correspond to a boggus method. | public void | addAttributes() INTERNAL USE-ONLY
This methods generate all the attributes for the receiver. | public void | addDefaultAbstractMethods() INTERNAL USE-ONLY
This methods generate all the default abstract method infos that correpond to
the abstract methods inherited from superinterfaces. | public void | addFieldInfos() INTERNAL USE-ONLY
This methods generate all the fields infos for the receiver.
This includes:
- a field info for each defined field of that class
- a field info for each synthetic field (e.g. | public void | addProblemClinit(CategorizedProblem[] problems) INTERNAL USE-ONLY
Generate the byte for a problem clinit method info that correspond to a boggus method. | public 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. | public 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. | public 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. | public 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. | public void | addSpecialMethods() INTERNAL USE-ONLY
Generate the byte for all the special method infos. | public void | addSyntheticConstructorAccessMethod(SyntheticMethodBinding methodBinding) INTERNAL USE-ONLY
Generate the bytes for a synthetic method that provides an access to a private constructor. | public void | addSyntheticEnumValueOfMethod(SyntheticMethodBinding methodBinding) | public void | addSyntheticEnumValuesMethod(SyntheticMethodBinding methodBinding) | public 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. | public 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. | public void | addSyntheticMethodAccessMethod(SyntheticMethodBinding methodBinding) INTERNAL USE-ONLY
Generate the bytes for a synthetic method that provides access to a private method. | public void | addSyntheticSwitchTable(SyntheticMethodBinding methodBinding) | public static String | buildAllDirectoriesInto(String outputPath, String relativeFileName) INTERNAL USE-ONLY
Build all the directories and subdirectories corresponding to the packages names
into the directory specified in parameters. | public 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. | public 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. | public 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. | public void | completeCodeAttributeForMissingAbstractProblemMethod(MethodBinding binding, int codeAttributeOffset, int[] startLineIndexes, int problemLine) | public 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. | public 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. | public 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. | public 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. | public static void | createProblemType(TypeDeclaration typeDeclaration, CompilationResult unitResult) | public char[] | fileName() | public void | generateCodeAttributeHeader() INTERNAL USE-ONLY
That method generates the header of a code attribute. | public int | generateMethodInfoAttribute(MethodBinding methodBinding) | public int | generateMethodInfoAttribute(MethodBinding methodBinding, AnnotationMethodDeclaration declaration) | public int | generateMethodInfoAttribute(MethodBinding methodBinding, boolean createProblemMethod) INTERNAL USE-ONLY
That method generates the attributes of a code attribute. | public 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. | public 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. | public 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 ) inside the constant pool
- the descriptor index of the signature (always ()V) of the method inside the constant pool. | public void | generateMissingAbstractMethods(MethodDeclaration[] methodDeclarations, CompilationResult compilationResult) INTERNAL USE-ONLY
Generate the byte for problem method infos that correspond to missing abstract methods. | public 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. | public char[][] | getCompoundName() EXTERNAL API
Answer the compound name of the class file.
char[][]e.g. | public static ClassFile | getNewInstance(SourceTypeBinding typeBinding) | protected void | initByteArrays() | public void | initialize(SourceTypeBinding aType, ClassFile parentClassFile, boolean createProblemType) | public ClassFile | outerMostEnclosingClassFile() INTERNAL USE-ONLY
Returns the most enclosing classfile of the receiver. | public void | recordInnerClasses(TypeBinding binding) | public void | reset(SourceTypeBinding typeBinding) | public void | setForMethodInfos() INTERNAL USE-ONLY
This methods leaves the space for method counts recording. | public void | traverse(MethodBinding methodBinding, int maxLocals, byte[] bytecodes, int codeOffset, int codeLength, ArrayList frames, boolean isClinit) | public char[] | utf8At(byte[] reference, int absoluteOffset, int bytesAvailable) | public static void | writeToDisk(boolean generatePackagesStructure, String outputPath, String relativeFileName, ClassFile classFile) |
INITIAL_CONTENTS_SIZE | final public static int INITIAL_CONTENTS_SIZE(Code) | | |
INITIAL_HEADER_SIZE | final public static int INITIAL_HEADER_SIZE(Code) | | |
INNER_CLASSES_SIZE | final public static int INNER_CLASSES_SIZE(Code) | | |
constantPoolOffset | public int constantPoolOffset(Code) | | |
contents | public byte[] contents(Code) | | |
contentsOffset | public int contentsOffset(Code) | | |
creatingProblemType | protected boolean creatingProblemType(Code) | | |
header | public byte[] header(Code) | | |
headerOffset | public int headerOffset(Code) | | |
innerClassesBindings | public Set innerClassesBindings(Code) | | |
isShared | public boolean isShared(Code) | | |
methodCount | public int methodCount(Code) | | |
methodCountOffset | public int methodCountOffset(Code) | | |
produceAttributes | public int produceAttributes(Code) | | |
targetJDK | public long targetJDK(Code) | | |
ClassFile | protected ClassFile()(Code) | | INTERNAL USE-ONLY
This methods creates a new instance of the receiver.
|
addAbstractMethod | public void addAbstractMethod(AbstractMethodDeclaration method, MethodBinding methodBinding)(Code) | | INTERNAL USE-ONLY
Generate the byte for a problem method info that correspond to a boggus method.
Parameters: method - org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding |
addAttributes | public void addAttributes()(Code) | | INTERNAL USE-ONLY
This methods generate all the attributes for the receiver.
For a class they could be:
- source file attribute
- inner classes attribute
- deprecated attribute
|
addDefaultAbstractMethods | public void addDefaultAbstractMethods()(Code) | | INTERNAL USE-ONLY
This methods generate all the default abstract method infos that correpond to
the abstract methods inherited from superinterfaces.
|
addFieldInfos | public void addFieldInfos()(Code) | | INTERNAL USE-ONLY
This methods generate all the fields infos for the receiver.
This includes:
- a field info for each defined field of that class
- a field info for each synthetic field (e.g. this$0)
|
addProblemClinit | public void addProblemClinit(CategorizedProblem[] problems)(Code) | | INTERNAL USE-ONLY
Generate the byte for a problem clinit method info that correspond to a boggus method.
Parameters: problems - org.eclipse.jdt.internal.compiler.problem.Problem[] |
addProblemConstructor | public void addProblemConstructor(AbstractMethodDeclaration method, MethodBinding methodBinding, CategorizedProblem[] problems)(Code) | | INTERNAL USE-ONLY
Generate the byte for a problem method info that correspond to a boggus constructor.
Parameters: method - org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding Parameters: problems - org.eclipse.jdt.internal.compiler.problem.Problem[] |
addProblemConstructor | public void addProblemConstructor(AbstractMethodDeclaration method, MethodBinding methodBinding, CategorizedProblem[] problems, int savedOffset)(Code) | | INTERNAL USE-ONLY
Generate the byte for a problem method info that correspond to a boggus constructor.
Reset the position inside the contents byte array to the savedOffset.
Parameters: method - org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding Parameters: problems - org.eclipse.jdt.internal.compiler.problem.Problem[] Parameters: savedOffset - int |
addProblemMethod | public void addProblemMethod(AbstractMethodDeclaration method, MethodBinding methodBinding, CategorizedProblem[] problems)(Code) | | INTERNAL USE-ONLY
Generate the byte for a problem method info that correspond to a boggus method.
Parameters: method - org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding Parameters: problems - org.eclipse.jdt.internal.compiler.problem.Problem[] |
addProblemMethod | public void addProblemMethod(AbstractMethodDeclaration method, MethodBinding methodBinding, CategorizedProblem[] problems, int savedOffset)(Code) | | INTERNAL USE-ONLY
Generate the byte for a problem method info that correspond to a boggus method.
Reset the position inside the contents byte array to the savedOffset.
Parameters: method - org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding Parameters: problems - org.eclipse.jdt.internal.compiler.problem.Problem[] Parameters: savedOffset - int |
addSpecialMethods | public void addSpecialMethods()(Code) | | INTERNAL USE-ONLY
Generate the byte for all the special method infos.
They are:
- synthetic access methods
- default abstract methods
|
addSyntheticConstructorAccessMethod | public void addSyntheticConstructorAccessMethod(SyntheticMethodBinding methodBinding)(Code) | | INTERNAL USE-ONLY
Generate the bytes for a synthetic method that provides an access to a private constructor.
Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding |
addSyntheticEnumValueOfMethod | public void addSyntheticEnumValueOfMethod(SyntheticMethodBinding methodBinding)(Code) | | INTERNAL USE-ONLY
Generate the bytes for a synthetic method that implements Enum#valueOf(String) for a given enum type
Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding |
addSyntheticEnumValuesMethod | public void addSyntheticEnumValuesMethod(SyntheticMethodBinding methodBinding)(Code) | | INTERNAL USE-ONLY
Generate the bytes for a synthetic method that implements Enum#values() for a given enum type
Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding |
addSyntheticFieldReadAccessMethod | public void addSyntheticFieldReadAccessMethod(SyntheticMethodBinding methodBinding)(Code) | | 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.
Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding |
addSyntheticFieldWriteAccessMethod | public void addSyntheticFieldWriteAccessMethod(SyntheticMethodBinding methodBinding)(Code) | | 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.
Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding |
addSyntheticMethodAccessMethod | public void addSyntheticMethodAccessMethod(SyntheticMethodBinding methodBinding)(Code) | | INTERNAL USE-ONLY
Generate the bytes for a synthetic method that provides access to a private method.
Parameters: methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding |
buildAllDirectoriesInto | public static String buildAllDirectoriesInto(String outputPath, String relativeFileName) throws IOException(Code) | | INTERNAL USE-ONLY
Build all the directories and subdirectories corresponding to the packages names
into the directory specified in parameters.
outputPath is formed like:
c:\temp\ the last character is a file separator
relativeFileName is formed like:
java\lang\String.class *
Parameters: outputPath - java.lang.String Parameters: relativeFileName - java.lang.String java.lang.String |
completeCodeAttribute | public void completeCodeAttribute(int codeAttributeOffset)(Code) | | 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.
Parameters: codeAttributeOffset - int |
completeCodeAttributeForClinit | public void completeCodeAttributeForClinit(int codeAttributeOffset)(Code) | | 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.
Parameters: codeAttributeOffset - int |
completeCodeAttributeForClinit | public void completeCodeAttributeForClinit(int codeAttributeOffset, int problemLine)(Code) | | 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.
|
completeCodeAttributeForMissingAbstractProblemMethod | public void completeCodeAttributeForMissingAbstractProblemMethod(MethodBinding binding, int codeAttributeOffset, int[] startLineIndexes, int problemLine)(Code) | | |
completeCodeAttributeForProblemMethod | public void completeCodeAttributeForProblemMethod(AbstractMethodDeclaration method, MethodBinding binding, int codeAttributeOffset, int[] startLineIndexes, int problemLine)(Code) | | 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.
Parameters: codeAttributeOffset - int |
completeCodeAttributeForSyntheticMethod | public void completeCodeAttributeForSyntheticMethod(boolean hasExceptionHandlers, SyntheticMethodBinding binding, int codeAttributeOffset, int[] startLineIndexes)(Code) | | 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.
Parameters: binding - org.eclipse.jdt.internal.compiler.lookup.SyntheticAccessMethodBinding Parameters: codeAttributeOffset - int |
completeCodeAttributeForSyntheticMethod | public void completeCodeAttributeForSyntheticMethod(SyntheticMethodBinding binding, int codeAttributeOffset, int[] startLineIndexes)(Code) | | 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.
Parameters: binding - org.eclipse.jdt.internal.compiler.lookup.SyntheticAccessMethodBinding Parameters: codeAttributeOffset - int |
completeMethodInfo | public void completeMethodInfo(int methodAttributeOffset, int attributeNumber)(Code) | | INTERNAL USE-ONLY
Complete the creation of a method info by setting up the number of attributes at the right offset.
Parameters: methodAttributeOffset - int Parameters: attributeNumber - int |
createProblemType | public static void createProblemType(TypeDeclaration typeDeclaration, CompilationResult unitResult)(Code) | | INTERNAL USE-ONLY
Request the creation of a ClassFile compatible representation of a problematic type
Parameters: typeDeclaration - org.eclipse.jdt.internal.compiler.ast.TypeDeclaration Parameters: unitResult - org.eclipse.jdt.internal.compiler.CompilationUnitResult |
fileName | public char[] fileName()(Code) | | INTERNAL USE-ONLY
This methods returns a char[] representing the file name of the receiver
char[] |
generateCodeAttributeHeader | public void generateCodeAttributeHeader()(Code) | | INTERNAL USE-ONLY
That method generates the header of a code attribute.
- the index inside the constant pool for the attribute name ("Code")
- leave some space for attribute_length(4), max_stack(2), max_locals(2), code_length(4).
|
generateMethodInfoAttribute | public int generateMethodInfoAttribute(MethodBinding methodBinding)(Code) | | |
generateMethodInfoAttribute | public int generateMethodInfoAttribute(MethodBinding methodBinding, boolean createProblemMethod)(Code) | | INTERNAL USE-ONLY
That method generates the attributes of a code attribute.
They could be:
- an exception attribute for each try/catch found inside the method
- a deprecated attribute
- a synthetic attribute for synthetic access methods
It returns the number of attributes created for the code attribute.
Parameters: methodBinding - org.eclipse.jdt.internal.compiler.lookup.MethodBinding int |
generateMethodInfoHeader | public void generateMethodInfoHeader(MethodBinding methodBinding)(Code) | | 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.
Parameters: methodBinding - org.eclipse.jdt.internal.compiler.lookup.MethodBinding |
generateMethodInfoHeader | public void generateMethodInfoHeader(MethodBinding methodBinding, int accessFlags)(Code) | | 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.
Parameters: methodBinding - org.eclipse.jdt.internal.compiler.lookup.MethodBinding Parameters: accessFlags - the access flags |
generateMethodInfoHeaderForClinit | public void generateMethodInfoHeaderForClinit()(Code) | | 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 ) inside the constant pool
- the descriptor index of the signature (always ()V) of the method inside the constant pool.
|
generateMissingAbstractMethods | public void generateMissingAbstractMethods(MethodDeclaration[] methodDeclarations, CompilationResult compilationResult)(Code) | | INTERNAL USE-ONLY
Generate the byte for problem method infos that correspond to missing abstract methods.
http://dev.eclipse.org/bugs/show_bug.cgi?id=3179
Parameters: methodDeclarations - Array of all missing abstract methods |
getBytes | public byte[] getBytes()(Code) | | 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.
Returns the byte array that represents the encoded structure of the receiver.
byte[] |
getCompoundName | public char[][] getCompoundName()(Code) | | EXTERNAL API
Answer the compound name of the class file.
char[][]e.g. {{java}, {util}, {Hashtable}}. |
initByteArrays | protected void initByteArrays()(Code) | | |
outerMostEnclosingClassFile | public ClassFile outerMostEnclosingClassFile()(Code) | | INTERNAL USE-ONLY
Returns the most enclosing classfile of the receiver. This is used know to store the constant pool name
for all inner types of the receiver.
org.eclipse.jdt.internal.compiler.codegen.ClassFile |
setForMethodInfos | public void setForMethodInfos()(Code) | | INTERNAL USE-ONLY
This methods leaves the space for method counts recording.
|
traverse | public void traverse(MethodBinding methodBinding, int maxLocals, byte[] bytecodes, int codeOffset, int codeLength, ArrayList frames, boolean isClinit)(Code) | | |
utf8At | public char[] utf8At(byte[] reference, int absoluteOffset, int bytesAvailable)(Code) | | |
writeToDisk | public static void writeToDisk(boolean generatePackagesStructure, String outputPath, String relativeFileName, ClassFile classFile) throws IOException(Code) | | INTERNAL USE-ONLY
outputPath is formed like:
c:\temp\ the last character is a file separator
relativeFileName is formed like:
java\lang\String.class
Parameters: generatePackagesStructure - a flag to know if the packages structure has to be generated. Parameters: outputPath - the given output directory Parameters: relativeFileName - the given relative file name Parameters: classFile - the given classFile to write |
|
|