title: Error: java.lang.AbstractMethodError when invoking a generic method implementing an interface
body: <p>I am trying to use javassist to programatically create and compile a class (at runtime) that implements an interface. </p>
  
  <p>I get the following Error whenever I invoke an instance of that dynamic class:</p>
  
  <pre><code>java.lang.AbstractMethodError: FooImpl.test()Ljava/lang/Object;
  </code></pre>
  
  <p>Here's my interface</p>
  
  <pre><code>public class FooBarInterface&lt;T&gt; {
      public T getEntity();
  }
  </code></pre>
  
  <p>Here's a sample Entity</p>
  
  <pre><code>public class FooEntity {
  
      @Override
      public String toString() {
          return "Hello, Foo!";
      }
  }
  </code></pre>
  
  <p>Here's how I programatically implement the interface</p>
  
  <pre><code>public void test() {
      ClassPool classPool = ClassPool.getDefault();
      CtClass testInterface = classPool.get(FooBarInterface.class.getName());
  
      CtClass fooImpl = classPool.makeClass("FooImpl");
  
      fooImpl.addInterface(testInterface);
      CtMethod testMethod = CtNewMethod.make(
          "public com.test.FooEntity getEntity(){" +
              "return new com.test.FooEntity();" +
          "}",
          canImpl
      );
  
      fooImpl.addMethod(testMethod);
  
      fooImpl.writeFile();
  
      TestInterface&lt;FooEntity&gt; test = 
          (TestInterface&lt;FooEntity&gt;) fooImpl.toClass().newInstance();
  
      System.out.println(test.getEntity());
  
  }
  </code></pre>
  
  <p>If I changed the return type of the implemented method to Object, then I don't get the Error, like this: </p>
  
  <pre><code>CtMethod testMethod = CtNewMethod.make(
      "public Object getEntity(){" +
          "return new com.test.FooEntity();" +
      "}",
      canImpl
  );
  </code></pre>
  
  <p>Then I successfully get the <code>hello, Foo!</code>.  I am OK with changing the return type to Object, but I'd like to understand more why returning with type Foo produces <code>AbstractMethodError</code>. </p>