Class ProgramClass

All Implemented Interfaces:
Serializable, Clazz, FeatureNamed, Processable

public class ProgramClass extends SimpleFeatureNamedProcessable implements Clazz
This Clazz is a complete representation of the data in a Java class.
See Also:
  • Field Details

    • u4version

      public int u4version
    • u2constantPoolCount

      public int u2constantPoolCount
    • constantPool

      public Constant[] constantPool
    • u2accessFlags

      public int u2accessFlags
    • u2thisClass

      public int u2thisClass
    • u2superClass

      public int u2superClass
    • u2interfacesCount

      public int u2interfacesCount
    • u2interfaces

      public int[] u2interfaces
    • u2fieldsCount

      public int u2fieldsCount
    • fields

      public ProgramField[] fields
    • u2methodsCount

      public int u2methodsCount
    • methods

      public ProgramMethod[] methods
    • u2attributesCount

      public int u2attributesCount
    • attributes

      public Attribute[] attributes
    • kotlinMetadata

      public KotlinMetadata kotlinMetadata
    • subClasses

      public Clazz[] subClasses
      An extra field pointing to the subclasses of this class. This field is typically filled out by the ClassSubHierarchyInitializer.
    • subClassCount

      public int subClassCount
  • Constructor Details

    • ProgramClass

      public ProgramClass()
      Creates an uninitialized ProgramClass.
    • ProgramClass

      public ProgramClass(int u4version, int u2constantPoolCount, Constant[] constantPool, int u2accessFlags, int u2thisClass, int u2superClass)
      Creates an initialized ProgramClass without fields, methods, attributes, or subclasses.
    • ProgramClass

      public ProgramClass(int u4version, int u2constantPoolCount, Constant[] constantPool, int u2accessFlags, int u2thisClass, int u2superClass, String featureName, int processingFlags, Object processingInfo)
      Creates an initialized ProgramClass without fields, methods, attributes, or subclasses.
    • ProgramClass

      public ProgramClass(int u4version, int u2constantPoolCount, Constant[] constantPool, int u2accessFlags, int u2thisClass, int u2superClass, int u2interfacesCount, int[] u2interfaces, int u2fieldsCount, ProgramField[] fields, int u2methodsCount, ProgramMethod[] methods, int u2attributesCount, Attribute[] attributes, int subClassCount, Clazz[] subClasses)
      Creates an initialized ProgramClass.
    • ProgramClass

      public ProgramClass(int u4version, int u2constantPoolCount, Constant[] constantPool, int u2accessFlags, int u2thisClass, int u2superClass, int u2interfacesCount, int[] u2interfaces, int u2fieldsCount, ProgramField[] fields, int u2methodsCount, ProgramMethod[] methods, int u2attributesCount, Attribute[] attributes, int subClassCount, Clazz[] subClasses, String featureName, int processingFlags, Object processingInfo)
      Creates an initialized ProgramClass.
  • Method Details

    • getConstant

      public Constant getConstant(int constantIndex)
      Returns the Constant at the given index in the constant pool.
    • getAccessFlags

      public int getAccessFlags()
      Description copied from interface: Clazz
      Returns the access flags of this class.
      Specified by:
      getAccessFlags in interface Clazz
      See Also:
    • getName

      public String getName()
      Description copied from interface: Clazz
      Returns the full internal name of this class.
      Specified by:
      getName in interface Clazz
    • getSuperName

      public String getSuperName()
      Description copied from interface: Clazz
      Returns the full internal name of the super class of this class, or null if this class represents java.lang.Object.
      Specified by:
      getSuperName in interface Clazz
    • getInterfaceCount

      public int getInterfaceCount()
      Description copied from interface: Clazz
      Returns the number of interfaces that this class implements.
      Specified by:
      getInterfaceCount in interface Clazz
    • getInterfaceName

      public String getInterfaceName(int index)
      Description copied from interface: Clazz
      Returns the full internal name of the interface at the given index of this class.
      Specified by:
      getInterfaceName in interface Clazz
    • getTag

      public int getTag(int constantIndex)
      Description copied from interface: Clazz
      Returns the tag value of the Constant at the specified index.
      Specified by:
      getTag in interface Clazz
    • getString

      public String getString(int constantIndex)
      Description copied from interface: Clazz
      Returns the String value of the Utf8Constant at the specified index.
      Specified by:
      getString in interface Clazz
    • getStringString

      public String getStringString(int constantIndex)
      Description copied from interface: Clazz
      Returns the String value of the StringConstant at the specified index.
      Specified by:
      getStringString in interface Clazz
    • getClassName

      public String getClassName(int constantIndex)
      Description copied from interface: Clazz
      Returns the class name of ClassConstant at the specified index.
      Specified by:
      getClassName in interface Clazz
    • getName

      public String getName(int constantIndex)
      Description copied from interface: Clazz
      Returns the name of the NameAndTypeConstant at the specified index.
      Specified by:
      getName in interface Clazz
    • getType

      public String getType(int constantIndex)
      Description copied from interface: Clazz
      Returns the type of the NameAndTypeConstant at the specified index.
      Specified by:
      getType in interface Clazz
    • getRefClassName

      public String getRefClassName(int constantIndex)
      Description copied from interface: Clazz
      Returns the class name of the RefConstant at the specified index.
      Specified by:
      getRefClassName in interface Clazz
    • getRefName

      public String getRefName(int constantIndex)
      Description copied from interface: Clazz
      Returns the name of the RefConstant at the specified index.
      Specified by:
      getRefName in interface Clazz
    • getRefType

      public String getRefType(int constantIndex)
      Description copied from interface: Clazz
      Returns the type of the RefConstant at the specified index.
      Specified by:
      getRefType in interface Clazz
    • getModuleName

      public String getModuleName(int constantIndex)
      Description copied from interface: Clazz
      Returns the name of the ModuleConstant at the specified index.
      Specified by:
      getModuleName in interface Clazz
    • getPackageName

      public String getPackageName(int constantIndex)
      Description copied from interface: Clazz
      Returns the name of the PackageConstant at the specified index.
      Specified by:
      getPackageName in interface Clazz
    • addSubClass

      public void addSubClass(Clazz clazz)
      Description copied from interface: Clazz
      Notifies this Clazz that it is being subclassed by another class.
      Specified by:
      addSubClass in interface Clazz
    • removeSubClass

      public void removeSubClass(Clazz clazz)
      Description copied from interface: Clazz
      Notifies this Clazz that it is no longer being subclassed by another class.
      Specified by:
      removeSubClass in interface Clazz
    • getSuperClass

      public Clazz getSuperClass()
      Description copied from interface: Clazz
      Returns the super class of this class.
      Specified by:
      getSuperClass in interface Clazz
    • getInterface

      public Clazz getInterface(int index)
      Description copied from interface: Clazz
      Returns the interface at the given index.
      Specified by:
      getInterface in interface Clazz
    • extends_

      public boolean extends_(Clazz clazz)
      Description copied from interface: Clazz
      Returns whether this class extends the given class. A class is always considered to extend itself. Interfaces are considered to only extend the root Object class.
      Specified by:
      extends_ in interface Clazz
    • extends_

      public boolean extends_(String className)
      Description copied from interface: Clazz
      Returns whether this class extends the specified class. A class is always considered to extend itself. Interfaces are considered to only extend the root Object class.
      Specified by:
      extends_ in interface Clazz
    • extendsOrImplements

      public boolean extendsOrImplements(Clazz clazz)
      Description copied from interface: Clazz
      Returns whether this class implements the given class. A class is always considered to implement itself. Interfaces are considered to implement all their superinterfaces.
      Specified by:
      extendsOrImplements in interface Clazz
    • extendsOrImplements

      public boolean extendsOrImplements(String className)
      Description copied from interface: Clazz
      Returns whether this class implements the specified class. A class is always considered to implement itself. Interfaces are considered to implement all their superinterfaces.
      Specified by:
      extendsOrImplements in interface Clazz
    • findField

      public Field findField(String name, String descriptor)
      Description copied from interface: Clazz
      Returns the field with the given name and descriptor.
      Specified by:
      findField in interface Clazz
      Parameters:
      name - the field name, or null if it is irrelevant.
      descriptor - the field type, or null if it is irrelevant.
      Returns:
      the first matching field, or null there is no matching field.
    • findMethod

      public Method findMethod(String name, String descriptor)
      Description copied from interface: Clazz
      Returns the method with the given name and descriptor.
      Specified by:
      findMethod in interface Clazz
      Parameters:
      name - the method name, or null if it is irrelevant.
      descriptor - the method descriptor, or null if it is irrelevant.
      Returns:
      the first matching method, or null there is no matching method.
    • accept

      public void accept(ClassVisitor classVisitor)
      Description copied from interface: Clazz
      Accepts the given class visitor.
      Specified by:
      accept in interface Clazz
    • hierarchyAccept

      public void hierarchyAccept(boolean visitThisClass, boolean visitSuperClass, boolean visitInterfaces, boolean visitSubclasses, ClassVisitor classVisitor)
      Description copied from interface: Clazz
      Accepts the given class visitor in the class hierarchy.
      Specified by:
      hierarchyAccept in interface Clazz
      Parameters:
      visitThisClass - specifies whether to visit this class.
      visitSuperClass - specifies whether to visit the super classes.
      visitInterfaces - specifies whether to visit the interfaces.
      visitSubclasses - specifies whether to visit the subclasses.
      classVisitor - the ClassVisitor that will visit the class hierarchy.
    • subclassesAccept

      public void subclassesAccept(ClassVisitor classVisitor)
      Description copied from interface: Clazz
      Lets the given class visitor visit all known subclasses.
      Specified by:
      subclassesAccept in interface Clazz
      Parameters:
      classVisitor - the ClassVisitor that will visit the subclasses.
    • constantPoolEntriesAccept

      public void constantPoolEntriesAccept(ConstantVisitor constantVisitor)
      Description copied from interface: Clazz
      Lets the given constant pool entry visitor visit all constant pool entries of this class.
      Specified by:
      constantPoolEntriesAccept in interface Clazz
    • constantPoolEntryAccept

      public void constantPoolEntryAccept(int index, ConstantVisitor constantVisitor)
      Description copied from interface: Clazz
      Lets the given constant pool entry visitor visit the constant pool entry at the specified index.
      Specified by:
      constantPoolEntryAccept in interface Clazz
    • thisClassConstantAccept

      public void thisClassConstantAccept(ConstantVisitor constantVisitor)
      Description copied from interface: Clazz
      Lets the given constant pool entry visitor visit the class constant pool entry of this class.
      Specified by:
      thisClassConstantAccept in interface Clazz
    • superClassConstantAccept

      public void superClassConstantAccept(ConstantVisitor constantVisitor)
      Description copied from interface: Clazz
      Lets the given constant pool entry visitor visit the class constant pool entry of the super class of this class, if there is one.
      Specified by:
      superClassConstantAccept in interface Clazz
    • interfaceConstantsAccept

      public void interfaceConstantsAccept(ConstantVisitor constantVisitor)
      Description copied from interface: Clazz
      Lets the given constant pool entry visitor visit the class constant pool entries for all interfaces of this class.
      Specified by:
      interfaceConstantsAccept in interface Clazz
    • fieldsAccept

      public void fieldsAccept(MemberVisitor memberVisitor)
      Description copied from interface: Clazz
      Lets the given member info visitor visit all fields of this class.
      Specified by:
      fieldsAccept in interface Clazz
    • fieldAccept

      public void fieldAccept(String name, String descriptor, MemberVisitor memberVisitor)
      Description copied from interface: Clazz
      Lets the given member info visitor visit the specified field.
      Specified by:
      fieldAccept in interface Clazz
    • methodsAccept

      public void methodsAccept(MemberVisitor memberVisitor)
      Description copied from interface: Clazz
      Lets the given member info visitor visit all methods of this class.
      Specified by:
      methodsAccept in interface Clazz
    • methodAccept

      public void methodAccept(String name, String descriptor, MemberVisitor memberVisitor)
      Description copied from interface: Clazz
      Lets the given member info visitor visit the specified method.
      Specified by:
      methodAccept in interface Clazz
    • mayHaveImplementations

      public boolean mayHaveImplementations(Method method)
      Description copied from interface: Clazz
      Returns whether the given method may possibly have implementing or overriding methods down the class hierarchy. This can only be true if the class is not final, and the method is not private, static, or final, or a constructor.
      Specified by:
      mayHaveImplementations in interface Clazz
      Parameters:
      method - the method that may have implementations.
      Returns:
      whether it may have implementations.
    • attributesAccept

      public void attributesAccept(AttributeVisitor attributeVisitor)
      Description copied from interface: Clazz
      Lets the given attribute info visitor visit all attributes of this class.
      Specified by:
      attributesAccept in interface Clazz
    • attributeAccept

      public void attributeAccept(String name, AttributeVisitor attributeVisitor)
      Description copied from interface: Clazz
      Lets the given attribute info visitor visit the specified attribute.
      Specified by:
      attributeAccept in interface Clazz
    • kotlinMetadataAccept

      public void kotlinMetadataAccept(KotlinMetadataVisitor kotlinMetadataVisitor)
      Description copied from interface: Clazz
      Lets the given Kotlin metadata visitor visit the metadata of this class.
      Specified by:
      kotlinMetadataAccept in interface Clazz
    • toString

      public String toString()
      Overrides:
      toString in class Object