java.lang.Object
io.github.sugarcubes.cloner.bytecode.ClassStructure

public final class ClassStructure extends Object
Structure of a class file read by a BytecodeBackend: what the cloner needs to decide about a class and to add members to it, without the code of its methods.
  • Constructor Details

    • ClassStructure

      public ClassStructure(int majorVersion, int access, String name, String superName, List<String> interfaces, List<ClassStructure.Member> fields, List<ClassStructure.Member> methods, List<ClassStructure.InnerClass> innerClasses, Map<String,Map<String,Object>> annotations)
      Creates the structure.
      Parameters:
      majorVersion - major version of the class file
      access - access flags
      name - internal name
      superName - internal name of the superclass, null for Object and modules
      interfaces - internal names of the interfaces
      fields - fields
      methods - methods and constructors
      innerClasses - entries of the InnerClasses attribute
      annotations - class annotations visible at runtime by descriptors: their elements of primitive or String values by names
  • Method Details

    • getMajorVersion

      public int getMajorVersion()
      Returns the major version of the class file.
      Returns:
      major version, e.g. 52 for Java 8
    • getAccess

      public int getAccess()
      Returns the access flags of the class file.
      Returns:
      access flags
    • getName

      public String getName()
      Returns the internal name.
      Returns:
      internal name
    • getSuperName

      public String getSuperName()
      Returns the internal name of the superclass.
      Returns:
      internal name or null
    • getInterfaces

      public List<String> getInterfaces()
      Returns the internal names of the interfaces.
      Returns:
      interfaces
    • getFields

      public List<ClassStructure.Member> getFields()
      Returns the fields.
      Returns:
      fields
    • getMethods

      public List<ClassStructure.Member> getMethods()
      Returns the methods and constructors.
      Returns:
      methods
    • getInnerClasses

      public List<ClassStructure.InnerClass> getInnerClasses()
      Returns the entries of the InnerClasses attribute.
      Returns:
      entries
    • getAnnotation

      public Map<String,Object> getAnnotation(String descriptor)
      Returns the elements of a class annotation visible at runtime.
      Parameters:
      descriptor - descriptor of the annotation type
      Returns:
      elements of primitive or String values by names, or null if the class has no such annotation
    • is

      public boolean is(int flag)
      Tells whether the class has the access flag.
      Parameters:
      flag - access flag
      Returns:
      true if the flag is set