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 Details

    • BytecodeClass

      public BytecodeClass()
      Constructor. Used in tests only.
    • BytecodeClass

      public BytecodeClass(String name)
      Constructor. Used in tests only.
      Parameters:
      name - Class name.
    • BytecodeClass

      public BytecodeClass(String name, int access)
      Constructor. Used in tests only.
      Parameters:
      name - Class name.
      access - Access modifiers.
    • BytecodeClass

      public BytecodeClass(String name, BytecodeClassProperties properties)
      Constructor. Has real usages.
      Parameters:
      name - Class name.
      properties - Class properties.
    • BytecodeClass

      public BytecodeClass(String name, List<BytecodeMethod> methods, BytecodeClassProperties properties)
      Constructor.
      Parameters:
      name - Class name.
      methods - Methods.
      properties - Class properties.
    • BytecodeClass

      public BytecodeClass(String name, List<BytecodeMethod> methods, List<BytecodeField> fields, BytecodeAnnotations annotations, List<BytecodeAttribute> attributes, BytecodeClassProperties props)
      Constructor.
      Parameters:
      name - Class name.
      methods - Methods.
      fields - Fields.
      annotations - Annotations.
      attributes - Attributes.
      props - Class properties.
  • Method Details

    • name

      public String name()
      Class name.
      Returns:
      Name.
    • withConstructor

      public BytecodeMethodBuilder withConstructor(int... modifiers)
      Add constructor.
      Parameters:
      modifiers - Constructor modifiers.
      Returns:
      This object.
    • withMethod

      public BytecodeMethodBuilder withMethod(BytecodeMethodProperties properties)
      Add method.
      Parameters:
      properties - Method properties.
      Returns:
      This object.
    • withMethod

      public BytecodeMethodBuilder withMethod(BytecodeMethodProperties properties, BytecodeMaxs maxs)
      Add method.
      Parameters:
      properties - Method properties.
      maxs - Method maxs.
      Returns:
      This object.
    • 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 with opcodes' counting.
      Returns:
      Directives.
    • directives

      public DirectivesClass directives(boolean counting)
      Convert to directives.
      Parameters:
      counting - Whether to count opcodes.
      Returns:
      Directives.