Module io.github.sugarcubes.cloner
Class ClassStructure
java.lang.Object
io.github.sugarcubes.cloner.bytecode.ClassStructure
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classEntry of theInnerClassesattribute.static final classField or method. -
Constructor Summary
ConstructorsConstructorDescriptionClassStructure(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. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the access flags of the class file.getAnnotation(String descriptor) Returns the elements of a class annotation visible at runtime.Returns the fields.Returns the entries of theInnerClassesattribute.Returns the internal names of the interfaces.intReturns the major version of the class file.Returns the methods and constructors.getName()Returns the internal name.Returns the internal name of the superclass.booleanis(int flag) Tells whether the class has the access flag.
-
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 fileaccess- access flagsname- internal namesuperName- internal name of the superclass,nullforObjectand modulesinterfaces- internal names of the interfacesfields- fieldsmethods- methods and constructorsinnerClasses- entries of theInnerClassesattributeannotations- class annotations visible at runtime by descriptors: their elements of primitive orStringvalues by names
-
-
Method Details
-
getMajorVersion
public int getMajorVersion()Returns the major version of the class file.- Returns:
- major version, e.g.
52for Java 8
-
getAccess
public int getAccess()Returns the access flags of the class file.- Returns:
- access flags
-
getName
Returns the internal name.- Returns:
- internal name
-
getSuperName
Returns the internal name of the superclass.- Returns:
- internal name or
null
-
getInterfaces
Returns the internal names of the interfaces.- Returns:
- interfaces
-
getFields
Returns the fields.- Returns:
- fields
-
getMethods
Returns the methods and constructors.- Returns:
- methods
-
getInnerClasses
Returns the entries of theInnerClassesattribute.- Returns:
- entries
-
getAnnotation
Returns the elements of a class annotation visible at runtime.- Parameters:
descriptor- descriptor of the annotation type- Returns:
- elements of primitive or
Stringvalues by names, ornullif 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:
trueif the flag is set
-