title: How do I use MethodCall.invoke(someElementMatcher) to create a MethodCall representing a method I subsequently define in an instrumented type?
body: <p>I am using ByteBuddy to generate a class.</p>
  <p>Prior to working with <code>DynamicType.Builder</code>, I was going to store a <code>MethodCall</code> as an instance variable:</p>
  <pre class="lang-java prettyprint-override"><code>private final MethodCall frobCall =
    MethodCall.invoke(ElementMatchers.named(&quot;frob&quot;)); // here I invoke a method I'm going to define as part of the instrumented type
  </code></pre>
  <p>Then later in my generation logic for the instrumented type I define the <code>frob</code> method to do something:</p>
  <pre class="lang-java prettyprint-override"><code>.defineMethod(&quot;frob&quot;)
  .intercept(...etc....) // here I define frob to do something
  </code></pre>
  <p>…and I define the (let's say) <code>baz</code> method to invoke <code>frob</code>:</p>
  <pre class="lang-java prettyprint-override"><code>.defineMethod(&quot;baz&quot;)
  .withParameter(...) // etc.
  .intercept(frobCall); // invokes &quot;frob&quot;, which I've just defined above
  </code></pre>
  <p>(I am trying to keep this simple and may have mistyped something but I hope you can see the gist of what I'm trying to do.)</p>
  <p>When I <code>make()</code> my <code>DynamicType</code>, I receive an error that indicates that the dynamic type does not define <code>frob</code>.  This is mystifying to me, because of course I have defined it, as you can see above.</p>
  <p>Is there some restriction I am unaware of that prohibits <code>ElementMatchers</code> from identifying instrumented type methods that are defined later?  Do I really have to use <code>MethodDescription.Latent</code> here?</p>