Class BytecodeClass
- java.lang.Object
-
- org.eolang.jeo.representation.bytecode.BytecodeClass
-
public final class BytecodeClass extends Object
Class useful for generating bytecode for testing purposes.- Since:
- 0.1.0
-
-
Constructor Summary
Constructors Constructor Description BytecodeClass()Constructor.BytecodeClass(String name)Constructor.BytecodeClass(String name, int access)Constructor.BytecodeClass(String name, BytecodeClassProperties properties)Constructor.BytecodeClass(String name, org.objectweb.asm.ClassWriter writer, Collection<BytecodeMethod> methods, BytecodeClassProperties properties)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bytecodebytecode()Generate bytecode.BytecodeClasshelloWorldMethod()Hello world bytecode.BytecodeClasswithAnnotations(XmlAnnotations annotations)Add annotations.BytecodeMethodwithConstructor(int... modifiers)Add constructor.BytecodeMethodwithConstructor(String descriptor, int... modifiers)Add constructor.BytecodeClasswithField(String fname)Add field.org.objectweb.asm.FieldVisitorwithField(String fname, String descriptor, String signature, Object value, int... modifiers)Add field.BytecodeMethodwithMethod(String mname, String descriptor, int... modifiers)Add method.BytecodeMethodwithMethod(BytecodeMethodProperties properties)Add method.com.jcabi.xml.XMLxml()Converts bytecode into XML.
-
-
-
Constructor Detail
-
BytecodeClass
public BytecodeClass()
Constructor.
-
BytecodeClass
public BytecodeClass(String name)
Constructor.- Parameters:
name- Class name.
-
BytecodeClass
public BytecodeClass(String name, int access)
Constructor.- Parameters:
name- Class name.access- Access modifiers.
-
BytecodeClass
public BytecodeClass(String name, BytecodeClassProperties properties)
Constructor.- Parameters:
name- Class name.properties- Class properties.
-
BytecodeClass
public BytecodeClass(String name, org.objectweb.asm.ClassWriter writer, Collection<BytecodeMethod> methods, BytecodeClassProperties properties)
Constructor.- Parameters:
name- Class name.writer- ASM class writer.methods- Methods.properties- Class properties.
-
-
Method Detail
-
xml
public com.jcabi.xml.XML xml()
Converts bytecode into XML.- Returns:
- XML representation of bytecode.
-
bytecode
public Bytecode bytecode()
Generate bytecode.- Returns:
- Bytecode.
-
withConstructor
public BytecodeMethod withConstructor(int... modifiers)
Add constructor.- Parameters:
modifiers- Constructor modifiers.- Returns:
- This object.
-
withMethod
public BytecodeMethod withMethod(BytecodeMethodProperties properties)
Add method.- Parameters:
properties- Method properties.- Returns:
- This object.
-
withConstructor
public BytecodeMethod withConstructor(String descriptor, int... modifiers)
Add constructor.- Parameters:
descriptor- Constructor descriptor.modifiers- Constructor modifiers.- Returns:
- This object.
-
withMethod
public BytecodeMethod withMethod(String mname, String descriptor, int... modifiers)
Add method.- Parameters:
mname- Method name.descriptor- Method descriptor.modifiers- Access modifiers.- Returns:
- This object.
-
withField
public BytecodeClass withField(String fname)
Add field.- Parameters:
fname- Field name.- Returns:
- This object.
-
withField
public org.objectweb.asm.FieldVisitor withField(String fname, String descriptor, String signature, Object value, int... modifiers)
Add field.- Parameters:
fname- Field name.descriptor- Field descriptor.signature- Field signature.value- Field value.modifiers- Access modifiers.- Returns:
- This object.
-
withAnnotations
public BytecodeClass withAnnotations(XmlAnnotations annotations)
Add annotations.- Parameters:
annotations- Annotations.- Returns:
- This object.
-
helloWorldMethod
public BytecodeClass helloWorldMethod()
Hello world bytecode.- Returns:
- The same class with the hello world method.
-
-