Class ClassFile

java.lang.Object
org.vesalainen.bcc.ClassFile
All Implemented Interfaces:
AnnotatedConstruct, Element, Parameterizable, QualifiedNameable, TypeElement, Writable
Direct Known Subclasses:
SubClass

public class ClassFile extends Object implements Writable, TypeElement
ClassFile wraps java classfile
  • Field Details

  • Constructor Details

  • Method Details

    • getConstantPoolSize

      int getConstantPoolSize()
    • getFieldIndex

      int getFieldIndex(TypeElement declaringClass, String name, TypeMirror type)
      Returns the constant map index to field
      Parameters:
      declaringClass -
      name -
      type -
      Returns:
    • getFieldIndex

      int getFieldIndex(TypeElement declaringClass, String name, String descriptor)
      Returns the constant map index to field
      Parameters:
      declaringClass -
      name -
      descriptor -
      Returns:
    • getMethodIndex

      int getMethodIndex(ExecutableElement method)
      Returns the constant map index to method
      Parameters:
      method -
      Returns:
    • getRefIndex

      protected int getRefIndex(Class<? extends ConstantInfo.Ref> refType, String fullyQualifiedname, String name, String descriptor)
      Returns the constant map index to reference
      Parameters:
      refType -
      fullyQualifiedname -
      name -
      descriptor -
      Returns:
    • getNameIndex

      public int getNameIndex(CharSequence name)
      Returns the constant map index to name
      Parameters:
      name -
      Returns:
    • getNameAndTypeIndex

      public int getNameAndTypeIndex(String name, String descriptor)
      Returns the constant map index to name and type
      Parameters:
      name -
      descriptor -
      Returns:
    • getConstantIndex

      public final int getConstantIndex(int constant)
      Returns the constant map index to integer constant
      Parameters:
      constant -
      Returns:
    • getConstantIndex

      public final int getConstantIndex(float constant)
      Returns the constant map index to constant
      Parameters:
      constant -
      Returns:
    • getConstantIndex

      public final int getConstantIndex(double constant)
      Returns the constant map index to constant
      Parameters:
      constant -
      Returns:
    • getConstantIndex

      public final int getConstantIndex(long constant)
      Returns the constant map index to constant
      Parameters:
      constant -
      Returns:
    • getConstantIndex

      public final int getConstantIndex(String constant)
      Returns the constant map index to constant
      Parameters:
      constant -
      Returns:
    • addMethodInfo

      protected void addMethodInfo(MethodInfo methodInfo)
    • addFieldInfo

      protected void addFieldInfo(FieldInfo fieldInfo)
    • getFields

      protected List<FieldInfo> getFields()
    • getMethodInfos

      protected List<MethodInfo> getMethodInfos()
    • getReferencedClassnames

      public SortedSet<String> getReferencedClassnames()
      Returns all classnames (in internal form) that this class references
      Returns:
    • addConstantInfo

      private int addConstantInfo(ConstantInfo ci)
    • addConstantInfo

      protected int addConstantInfo(ConstantInfo ci, int fromIndex)
    • addIndexedElement

      protected void addIndexedElement(int index, Object type)
    • listConstantInfo

      private List<ConstantInfo> listConstantInfo(Class<? extends ConstantInfo> cls)
    • addInterface

      public void addInterface(short intf)
    • addAttribute

      public void addAttribute(AttributeInfo ai)
      Adds a new attribute
      Parameters:
      ai -
    • getIndexedType

      Object getIndexedType(int index)
      Returns a element from constant map
      Parameters:
      index -
      Returns:
    • getFieldDescription

      public String getFieldDescription(int index)
      Returns a descriptor to fields at index.
      Parameters:
      index -
      Returns:
    • getMethodDescription

      public String getMethodDescription(int index)
      Returns a descriptor to method at index.
      Parameters:
      index -
      Returns:
    • getClassDescription

      public String getClassDescription(int index)
      Returns a descriptor to class at index.
      Parameters:
      index -
      Returns:
    • isImplemented

      public boolean isImplemented(ExecutableElement method)
    • referencesMethod

      public boolean referencesMethod(ExecutableElement method)
      Return true if class contains method ref to given method
      Parameters:
      method -
      Returns:
    • referencesClass

      public boolean referencesClass(TypeElement type)
    • getClassIndex

      protected final int getClassIndex(TypeElement type)
    • getClassIndex

      protected final int getClassIndex(ArrayType at)
    • getClassIndex

      private final int getClassIndex(String name)
    • getConstantInfo

      public final ConstantInfo getConstantInfo(int index)
      Return constantInfo at index.
      Parameters:
      index -
      Returns:
    • getString

      public final String getString(int index)
      Return a constant string at index.
      Parameters:
      index -
      Returns:
    • isSynthetic

      public boolean isSynthetic()
    • getQualifiedName

      public Name getQualifiedName()
      Specified by:
      getQualifiedName in interface QualifiedNameable
      Specified by:
      getQualifiedName in interface TypeElement
    • getAnnotationMirrors

      public List<? extends AnnotationMirror> getAnnotationMirrors()
      Specified by:
      getAnnotationMirrors in interface AnnotatedConstruct
      Specified by:
      getAnnotationMirrors in interface Element
    • getAnnotation

      public <A extends Annotation> A getAnnotation(Class<A> annotationType)
      Specified by:
      getAnnotation in interface AnnotatedConstruct
      Specified by:
      getAnnotation in interface Element
    • getSuperclass

      public TypeMirror getSuperclass()
      Specified by:
      getSuperclass in interface TypeElement
    • getEnclosedElements

      public List<? extends Element> getEnclosedElements()
      Specified by:
      getEnclosedElements in interface Element
      Specified by:
      getEnclosedElements in interface TypeElement
    • getNestingKind

      public NestingKind getNestingKind()
      Specified by:
      getNestingKind in interface TypeElement
    • getSimpleName

      public Name getSimpleName()
      Specified by:
      getSimpleName in interface Element
      Specified by:
      getSimpleName in interface TypeElement
    • getInterfaces

      public List<? extends TypeMirror> getInterfaces()
      Specified by:
      getInterfaces in interface TypeElement
    • getTypeParameters

      public List<? extends TypeParameterElement> getTypeParameters()
      Specified by:
      getTypeParameters in interface Parameterizable
      Specified by:
      getTypeParameters in interface TypeElement
    • getEnclosingElement

      public Element getEnclosingElement()
      Specified by:
      getEnclosingElement in interface Element
      Specified by:
      getEnclosingElement in interface TypeElement
    • asType

      public TypeMirror asType()
      Specified by:
      asType in interface Element
      Specified by:
      asType in interface TypeElement
    • getKind

      public ElementKind getKind()
      Specified by:
      getKind in interface Element
    • getModifiers

      public Set<Modifier> getModifiers()
      Specified by:
      getModifiers in interface Element
    • accept

      public <R,P> R accept(ElementVisitor<R,P> v, P p)
      Specified by:
      accept in interface Element
    • write

      public void write(DataOutput out) throws IOException
      Specified by:
      write in interface Writable
      Throws:
      IOException
    • getAnnotationsByType

      public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType)
      Specified by:
      getAnnotationsByType in interface AnnotatedConstruct
      Specified by:
      getAnnotationsByType in interface Element