title: How can I change Java method implementation of single instance?
body: <p>What is correct way to change method signature for single <em>java object</em>. Suppose I wanna change <code>toString</code> method.</p>
  
  <pre><code>myObject.metaClass.toString = { pritln "hello world" }
  </code></pre>
  
  <p>Looks like this code has problems. If I pass my object into other Java compiled object original <code>toString</code> will be called.   </p>
  
  <p>Other <a href="https://stackoverflow.com/questions/4035784/how-do-you-override-a-method-for-a-java-type-instance-with-groovy-meta-programmi">solution</a> creates wrapper <code>Object</code>. It has different class from original one so it doesn't satisfy me</p>
  
  <hr>
  
  <p><strong>Added:</strong><br>
  1. I can't control creation process<br>
  2. I don't know how object was instantiated</p>
  
  <p>So there is no <strong><em>groovy way</em></strong> to solve this problem?
  The only solution is to create Java wrapper class, wrap all methods and change one? This is a ...</p>