title: How to define a new method inside an existing class and add a call to it in an existing method inside the same class using bytebuddy?
body: <p>I have a class which looks like below</p>
  
  <pre><code>public class HelloWorld{
    public void sayHelloWorld(){
      System.out.println("Hello World");
    }
  }
  </code></pre>
  
  <p>Now I would like to add another method to the <strong>HelloWorld</strong> class using bytebuddy and add a call to the new method in <strong>sayHelloWorld</strong>. So hypothetically the class would look like this after bytebuddy does it's magic. (I know that bytebuddy works with bytecode and not java source files. The below code is just for illustration purpose.)</p>
  
  <pre><code>public class HelloWorld{
    public void sayHelloWorld(){
      System.out.println("Hello World");
      sayHelloAgain()
    }
    public void sayHelloAgain(){
      System.out.println("Hello Again")
    }
  }
  </code></pre>
  
  <ol>
  <li>Firstly, is this possible with bytebuddy? </li>
  <li>Secondly, if it is possible, how can I do it? I have understood that bytebuddy can be used to redefine methods, but not modify the method body. Is this true?</li>
  </ol>
  
  <p>It would be great if someone could shed some light on this. TIA!</p>