java.lang.Object
org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile
Alle implementierten Schnittstellen:
TypeConstants, TypeIds
Bekannte direkte Unterklassen:
AjClassFile, CodeSnippetClassFile

public class ClassFile extends Object implements TypeConstants, TypeIds
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
  • Felddetails

    • codeStream

      public CodeStream codeStream
    • constantPool

      public ConstantPool constantPool
    • constantPoolOffset

      public int constantPoolOffset
    • contents

      public byte[] contents
    • contentsOffset

      public int contentsOffset
    • creatingProblemType

      protected boolean creatingProblemType
    • enclosingClassFile

      public ClassFile enclosingClassFile
    • headerOffset

      public int headerOffset
    • innerClassesBindings

      public Map<TypeBinding,Boolean> innerClassesBindings
    • nestMembers

      public Set<SourceTypeBinding> nestMembers
    • bootstrapMethods

      public List<Object> bootstrapMethods
    • methodCount

      public int methodCount
    • methodCountOffset

      public int methodCountOffset
    • produceAttributes

      public int produceAttributes
    • referenceBinding

      public SourceTypeBinding referenceBinding
    • isNestedType

      public boolean isNestedType
    • targetJDK

      public long targetJDK
    • missingTypes

      public List<TypeBinding> missingTypes
    • visitedTypes

      public Set<TypeBinding> visitedTypes
    • INITIAL_CONTENTS_SIZE

      public static final int INITIAL_CONTENTS_SIZE
      Siehe auch:
    • INITIAL_HEADER_SIZE

      public static final int INITIAL_HEADER_SIZE
      Siehe auch:
    • INNER_CLASSES_SIZE

      public static final int INNER_CLASSES_SIZE
      Siehe auch:
    • NESTED_MEMBER_SIZE

      public static final int NESTED_MEMBER_SIZE
      Siehe auch:
    • ALTMETAFACTORY_STRING

      public static final String ALTMETAFACTORY_STRING
    • METAFACTORY_STRING

      public static final String METAFACTORY_STRING
    • BOOTSTRAP_STRING

      public static final String BOOTSTRAP_STRING
    • TYPESWITCH_STRING

      public static final String TYPESWITCH_STRING
    • ENUMSWITCH_STRING

      public static final String ENUMSWITCH_STRING
    • CONCAT_CONSTANTS

      public static final String CONCAT_CONSTANTS
    • INVOKE_STRING

      public static final String INVOKE_STRING
    • ENUMDESC_OF

      public static final String ENUMDESC_OF
      Siehe auch:
    • CLASSDESC

      public static final String CLASSDESC
      Siehe auch:
    • CLASSDESC_OF

      public static final String CLASSDESC_OF
      Siehe auch:
    • BOOTSTRAP_METHODS

      public static final String[] BOOTSTRAP_METHODS
    • extraAttributes

      public List extraAttributes
  • Konstruktordetails

    • ClassFile

      protected ClassFile()
      INTERNAL USE-ONLY This methods creates a new instance of the receiver.
    • ClassFile

      public ClassFile(SourceTypeBinding typeBinding)
    • ClassFile

      public ClassFile(ModuleBinding moduleBinding, CompilerOptions options)
  • Methodendetails

    • createProblemType

      public static void createProblemType(TypeDeclaration typeDeclaration, CompilationResult unitResult)
      INTERNAL USE-ONLY Request the creation of a ClassFile compatible representation of a problematic type
      Parameter:
      typeDeclaration - org.eclipse.jdt.internal.compiler.ast.TypeDeclaration
      unitResult - org.eclipse.jdt.internal.compiler.CompilationUnitResult
    • getNewInstance

      public static ClassFile getNewInstance(SourceTypeBinding typeBinding)
    • addAbstractMethod

      public void addAbstractMethod(AbstractMethodDeclaration method, MethodBinding methodBinding)
      INTERNAL USE-ONLY Generate the byte for a problem method info that correspond to a bogus method.
      Parameter:
      method - org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
    • addAttributes

      public void addAttributes()
      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
    • addModuleAttributes

      public void addModuleAttributes(ModuleBinding module, Annotation[] annotations, CompilationUnitDeclaration cud)
      INTERNAL USE-ONLY This methods generate all the module attributes for the receiver.
    • addDefaultAbstractMethods

      public void addDefaultAbstractMethods()
      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()
      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)
      INTERNAL USE-ONLY Generate the byte for a problem clinit method info that correspond to a boggus method.
      Parameter:
      problems - org.eclipse.jdt.internal.compiler.problem.Problem[]
    • addProblemConstructor

      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.
      Parameter:
      method - org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
      problems - org.eclipse.jdt.internal.compiler.problem.Problem[]
    • addProblemConstructor

      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. Reset the position inside the contents byte array to the savedOffset.
      Parameter:
      method - org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
      problems - org.eclipse.jdt.internal.compiler.problem.Problem[]
      savedOffset - int
    • addProblemMethod

      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.
      Parameter:
      method - org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
      problems - org.eclipse.jdt.internal.compiler.problem.Problem[]
    • addProblemMethod

      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. Reset the position inside the contents byte array to the savedOffset.
      Parameter:
      method - org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
      problems - org.eclipse.jdt.internal.compiler.problem.Problem[]
      savedOffset - int
    • addSpecialMethods

      public void addSpecialMethods(TypeDeclaration typeDecl)
      INTERNAL USE-ONLY Generate the byte for all the special method infos. They are: - synthetic access methods - default abstract methods - lambda methods.
    • addSyntheticArrayConstructor

      public void addSyntheticArrayConstructor(SyntheticMethodBinding methodBinding)
    • addSyntheticArrayClone

      public void addSyntheticArrayClone(SyntheticMethodBinding methodBinding)
    • addSyntheticFactoryMethod

      public void addSyntheticFactoryMethod(SyntheticMethodBinding methodBinding)
    • addSyntheticConstructorAccessMethod

      public void addSyntheticConstructorAccessMethod(SyntheticMethodBinding methodBinding)
      INTERNAL USE-ONLY Generate the bytes for a synthetic method that provides an access to a private constructor.
      Parameter:
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
    • addSyntheticEnumValueOfMethod

      public void addSyntheticEnumValueOfMethod(SyntheticMethodBinding methodBinding)
      INTERNAL USE-ONLY Generate the bytes for a synthetic method that implements Enum#valueOf(String) for a given enum type
      Parameter:
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
    • addSyntheticEnumValuesMethod

      public void addSyntheticEnumValuesMethod(SyntheticMethodBinding methodBinding)
      INTERNAL USE-ONLY Generate the bytes for a synthetic method that implements Enum#values() for a given enum type
      Parameter:
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
    • addSyntheticEnumInitializationMethod

      public void addSyntheticEnumInitializationMethod(SyntheticMethodBinding methodBinding)
    • addSyntheticFieldReadAccessMethod

      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.
      Parameter:
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
    • addSyntheticFieldWriteAccessMethod

      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.
      Parameter:
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
    • addSyntheticMethodAccessMethod

      public void addSyntheticMethodAccessMethod(SyntheticMethodBinding methodBinding)
      INTERNAL USE-ONLY Generate the bytes for a synthetic method that provides access to a private method.
      Parameter:
      methodBinding - org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
    • addSyntheticSwitchTable

      public void addSyntheticSwitchTable(SyntheticMethodBinding methodBinding)
    • completeCodeAttribute

      public void completeCodeAttribute(int codeAttributeOffset, MethodScope scope)
      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.
      Parameter:
      codeAttributeOffset - int
    • generateTypeAnnotationsOnCodeAttribute

      public int generateTypeAnnotationsOnCodeAttribute()
    • completeCodeAttributeForClinit

      public void completeCodeAttributeForClinit(int codeAttributeOffset, Scope scope)
      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.
      Parameter:
      codeAttributeOffset - int
    • completeCodeAttributeForClinit

      public void completeCodeAttributeForClinit(int codeAttributeOffset, int problemLine, MethodScope scope)
      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)
    • completeCodeAttributeForProblemMethod

      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.
      Parameter:
      codeAttributeOffset - int
    • completeCodeAttributeForSyntheticMethod

      public void completeCodeAttributeForSyntheticMethod(boolean hasExceptionHandlers, SyntheticMethodBinding binding, int codeAttributeOffset, int[] startLineIndexes, Scope scope)
      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.
      Parameter:
      binding - org.eclipse.jdt.internal.compiler.lookup.SyntheticAccessMethodBinding
      codeAttributeOffset - int
    • completeCodeAttributeForSyntheticMethod

      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.
      Parameter:
      binding - org.eclipse.jdt.internal.compiler.lookup.SyntheticAccessMethodBinding
      codeAttributeOffset - int
    • completeMethodInfo

      public void completeMethodInfo(MethodBinding binding, int methodAttributeOffset, int attributesNumber)
      INTERNAL USE-ONLY Complete the creation of a method info by setting up the number of attributes at the right offset.
      Parameter:
      methodAttributeOffset - int
      attributesNumber - int
    • fileName

      public char[] fileName()
      INTERNAL USE-ONLY This methods returns a char[] representing the file name of the receiver
      Gibt zurück:
      char[]
    • generateCodeAttributeHeader

      public void generateCodeAttributeHeader()
      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).
    • generateMethodInfoAttributes

      public int generateMethodInfoAttributes(MethodBinding methodBinding, List extraAttributes)
      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.
      Parameter:
      methodBinding - org.eclipse.jdt.internal.compiler.lookup.MethodBinding
      Gibt zurück:
      int
    • generateMethodInfoAttributes

      public int generateMethodInfoAttributes(MethodBinding methodBinding)
    • generateMethodInfoAttributes

      public int generateMethodInfoAttributes(MethodBinding methodBinding, AnnotationMethodDeclaration declaration)
    • generateMethodInfoHeader

      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.
      Parameter:
      methodBinding - org.eclipse.jdt.internal.compiler.lookup.MethodBinding
    • generateMethodInfoHeader

      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.
      Parameter:
      methodBinding - org.eclipse.jdt.internal.compiler.lookup.MethodBinding
      accessFlags - the access flags
    • addSyntheticDeserializeLambda

      public void addSyntheticDeserializeLambda(SyntheticMethodBinding methodBinding, SyntheticMethodBinding[] syntheticMethodBindings)
    • generateMethodInfoHeaderForClinit

      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.
    • generateMissingAbstractMethods

      public void generateMissingAbstractMethods(MethodDeclaration[] methodDeclarations, CompilationResult compilationResult)
      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
      Parameter:
      methodDeclarations - Array of all missing abstract methods
    • getBytes

      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. Returns the byte array that represents the encoded structure of the receiver.
      Gibt zurück:
      byte[]
    • internalSetBytes

      public void internalSetBytes(byte[] newBytes)
      Sets the actual bytes of the class file. This method is made public only to be accessible from org.eclipse.jdt.internal.core.builder.AbstractImageBuilder during compilation post processing to store the modified byte representation of the class. Using this method for any other purpose is discouraged and may lead to unpredictable results.
      Parameter:
      newBytes - array containing new bytes, will be stored "as is", all subsequent modification on given array will be reflected and vice versa.
    • getCompoundName

      public char[][] getCompoundName()
      EXTERNAL API Answer the compound name of the class file.
      Gibt zurück:
      char[][] e.g. {{java}, {util}, {Hashtable}}.
    • initByteArrays

      protected void initByteArrays(int members)
    • initialize

      public void initialize(SourceTypeBinding aType, ClassFile parentClassFile, boolean createProblemType)
    • initializeForModule

      public void initializeForModule(ModuleBinding module)
    • outerMostEnclosingClassFile

      public ClassFile outerMostEnclosingClassFile()
      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.
      Gibt zurück:
      org.eclipse.jdt.internal.compiler.codegen.ClassFile
    • recordInnerClasses

      public void recordInnerClasses(TypeBinding binding)
    • recordInnerClasses

      public void recordInnerClasses(TypeBinding binding, boolean onBottomForBug445231)
    • recordNestMember

      public void recordNestMember(SourceTypeBinding binding)
    • getNestMembers

      public List<String> getNestMembers()
    • recordBootstrapMethod

      public int recordBootstrapMethod(FunctionalExpression expression)
    • recordBootstrapMethod

      public int recordBootstrapMethod(SwitchStatement switchStatement)
    • recordBootstrapMethod

      public int recordBootstrapMethod(CaseStatement.ResolvedCase resolvedCase)
    • recordBootstrapMethod

      public int recordBootstrapMethod(TypeBinding type)
    • recordBootstrapMethod

      public int recordBootstrapMethod(String expression)
    • reset

      public void reset(SourceTypeBinding typeBinding, CompilerOptions options)
    • setForMethodInfos

      public void setForMethodInfos()
      INTERNAL USE-ONLY This methods leaves the space for method counts recording.
    • traverse

      public List<StackMapFrame> traverse(MethodBinding methodBinding, int maxLocals, byte[] bytecodes, int codeOffset, int codeLength, Map<Integer,StackMapFrame> frames, boolean isClinit, Scope scope)
    • utf8At

      public char[] utf8At(byte[] reference, int absoluteOffset, int bytesAvailable)