Class BytecodeClass
- java.lang.Object
-
- org.eolang.jeo.representation.bytecode.BytecodeClass
-
public final class BytecodeClass extends Object
Bytecode representation of a Java class.This class represents a Java class in bytecode form, containing methods, fields, annotations, attributes, and class properties. It provides functionality for building bytecode classes programmatically and converting them to various formats.
- Since:
- 0.1.0
-
-
Constructor Summary
Constructors Constructor Description BytecodeClass()Default constructor.BytecodeClass(String name)Constructor.BytecodeClass(String name, int access)Constructor.BytecodeClass(String name, List<BytecodeMethod> methods, BytecodeClassProperties properties)Constructor.BytecodeClass(String name, BytecodeClassProperties properties)Constructor.BytecodeClass(ClassName name, List<BytecodeMethod> methods, List<BytecodeField> fields, BytecodeAnnotations annotations, BytecodeAttributes attributes, BytecodeClassProperties props)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DirectivesClassdirectives()Convert to directives.DirectivesClassdirectives(Format format)Convert to directives.BytecodeClasshelloWorldMethod()Hello world bytecode.List<BytecodeMethod>methods()Retrieve class methods.ClassNamename()Class name.BytecodeClassPropertiesproperties()Properties.BytecodeMethodBuilderwithConstructor(int... modifiers)Add constructor to the class.BytecodeMethodBuilderwithConstructor(String descriptor, int... modifiers)Add constructor.BytecodeClasswithField(String fname)Add field.BytecodeMethodBuilderwithMethod(String mname, String descriptor, int... modifiers)Add method.BytecodeMethodBuilderwithMethod(BytecodeMethodProperties properties)Add method to the class.BytecodeMethodBuilderwithMethod(BytecodeMethodProperties properties, BytecodeMaxs maxs)Add method to the class.BytecodeClasswithoutMethods()Without methods.
-
-
-
Constructor Detail
-
BytecodeClass
public BytecodeClass()
Default constructor. Creates a simple class with default settings.
-
BytecodeClass
public BytecodeClass(String name)
Constructor.- Parameters:
name- The class name
-
BytecodeClass
public BytecodeClass(String name, int access)
Constructor.- Parameters:
name- The class nameaccess- The access modifiers
-
BytecodeClass
public BytecodeClass(String name, BytecodeClassProperties properties)
Constructor.- Parameters:
name- The class nameproperties- The class properties
-
BytecodeClass
public BytecodeClass(String name, List<BytecodeMethod> methods, BytecodeClassProperties properties)
Constructor.- Parameters:
name- The class namemethods- The class methodsproperties- The class properties- Suppressed Checkstyle violations:
- ParameterNumberCheck (5 lines)
-
BytecodeClass
public BytecodeClass(ClassName name, List<BytecodeMethod> methods, List<BytecodeField> fields, BytecodeAnnotations annotations, BytecodeAttributes attributes, BytecodeClassProperties props)
Constructor.- Parameters:
name- The class namemethods- The class methodsfields- The class fieldsannotations- The class annotationsattributes- The class attributesprops- The class properties- Suppressed Checkstyle violations:
- ParameterNumberCheck (5 lines)
-
-
Method Detail
-
name
public ClassName name()
Class name.- Returns:
- Name.
-
withConstructor
public BytecodeMethodBuilder withConstructor(int... modifiers)
Add constructor to the class.- Parameters:
modifiers- The constructor access modifiers- Returns:
- The method builder for chaining
-
withMethod
public BytecodeMethodBuilder withMethod(BytecodeMethodProperties properties)
Add method to the class.- Parameters:
properties- The method properties- Returns:
- The method builder for chaining
-
withMethod
public BytecodeMethodBuilder withMethod(BytecodeMethodProperties properties, BytecodeMaxs maxs)
Add method to the class.- Parameters:
properties- The method propertiesmaxs- The method stack/locals maxs- Returns:
- The method builder for chaining
-
withConstructor
public BytecodeMethodBuilder withConstructor(String descriptor, int... modifiers)
Add constructor.- Parameters:
descriptor- Constructor descriptor.modifiers- Constructor modifiers.- Returns:
- This object.
-
withField
public BytecodeClass withField(String fname)
Add field.- Parameters:
fname- Field name.- Returns:
- This object.
-
withMethod
public BytecodeMethodBuilder withMethod(String mname, String descriptor, int... modifiers)
Add method.- Parameters:
mname- Method name.descriptor- Method descriptor.modifiers- Access modifiers.- Returns:
- This object.
-
helloWorldMethod
public BytecodeClass helloWorldMethod()
Hello world bytecode.- Returns:
- The same class with the hello world method.
-
properties
public BytecodeClassProperties properties()
Properties.- Returns:
- Class properties.
-
methods
public List<BytecodeMethod> methods()
Retrieve class methods.- Returns:
- Class methods.
-
withoutMethods
public BytecodeClass withoutMethods()
Without methods.- Returns:
- The same class without methods.
-
directives
public DirectivesClass directives()
Convert to directives.- Returns:
- Directives.
-
directives
public DirectivesClass directives(Format format)
Convert to directives.- Parameters:
format- Format of the directives.- Returns:
- Directives.
-
-