Class BytecodeClass
java.lang.Object
org.eolang.jeo.representation.bytecode.BytecodeClass
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
ConstructorsConstructorDescriptionDefault 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
Modifier and TypeMethodDescriptionConvert to directives.Hello world bytecode.methods()
Retrieve class methods.name()
Class name.Properties.withConstructor
(int... modifiers) Add constructor to the class.withConstructor
(String descriptor, int... modifiers) Add constructor.Add field.withMethod
(String mname, String descriptor, int... modifiers) Add method.withMethod
(BytecodeMethodProperties properties) Add method to the class.withMethod
(BytecodeMethodProperties properties, BytecodeMaxs maxs) Add method to the class.Without methods.
-
Constructor Details
-
BytecodeClass
public BytecodeClass()Default constructor. Creates a simple class with default settings. -
BytecodeClass
Constructor.- Parameters:
name
- The class name
-
BytecodeClass
Constructor.- Parameters:
name
- The class nameaccess
- The access modifiers
-
BytecodeClass
Constructor.- Parameters:
name
- The class nameproperties
- The class properties
-
BytecodeClass
Constructor.- Parameters:
name
- The class namemethods
- The class methodsproperties
- The class properties
-
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
-
-
Method Details
-
name
Class name.- Returns:
- Name.
-
withConstructor
Add constructor to the class.- Parameters:
modifiers
- The constructor access modifiers- Returns:
- The method builder for chaining
-
withMethod
Add method to the class.- Parameters:
properties
- The method properties- Returns:
- The method builder for chaining
-
withMethod
Add method to the class.- Parameters:
properties
- The method propertiesmaxs
- The method stack/locals maxs- Returns:
- The method builder for chaining
-
withConstructor
Add constructor.- Parameters:
descriptor
- Constructor descriptor.modifiers
- Constructor modifiers.- Returns:
- This object.
-
withField
Add field.- Parameters:
fname
- Field name.- Returns:
- This object.
-
withMethod
Add method.- Parameters:
mname
- Method name.descriptor
- Method descriptor.modifiers
- Access modifiers.- Returns:
- This object.
-
helloWorldMethod
Hello world bytecode.- Returns:
- The same class with the hello world method.
-
properties
Properties.- Returns:
- Class properties.
-
methods
Retrieve class methods.- Returns:
- Class methods.
-
withoutMethods
Without methods.- Returns:
- The same class without methods.
-
directives
Convert to directives.- Returns:
- Directives.
-