Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-729

Tapestry IOC proxies have incorrect implementation when interface method uses a covariant return type (causes AbstractMethodError)

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 5.1.0.5
    • Fix Version/s: None
    • Component/s: tapestry-ioc
    • Labels:

      Description

      Here's a Junit 3 test case to demonstrate:

      import junit.framework.TestCase;

      import org.apache.tapestry5.ioc.Registry;
      import org.apache.tapestry5.ioc.RegistryBuilder;
      import org.apache.tapestry5.ioc.ServiceBinder;

      public class ProxyText extends TestCase {

      private Registry registry;

      @Override
      protected void setUp() throws Exception

      { RegistryBuilder builder = new RegistryBuilder(); builder.add(AppModule.class); registry = builder.build(); registry.performRegistryStartup(); }

      public void testRegistryWorks()

      { assertEquals(new Integer(1), registry.getService(SuperIFace.class).get()); }

      public static class AppModule {
      public static void bind(ServiceBinder binder)

      { binder.bind(IFace.class, Impl.class); }

      }

      public interface SuperIFace

      { Number get(); }

      public interface IFace extends SuperIFace

      { Integer get(); }


      public static class Impl implements IFace {
      public Integer get() { return 1; }
      }
      }



      -----
      The result is:
      java.lang.AbstractMethodError: $IFace_1218d10684a.get()Ljava/lang/Number;

      Note that if you change SuperIFace to:
      public interface SuperIFace { Integer get(); }

      the test works - demonstrating that the problem is to do with the use of a covariant return type in IFace.

      BTW, this has turned up in code for testing where I want to create sub-interfaces that provide additional testing facilities for fake services and I need to control the particular types that are returned by the fake implementation.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              paulfield Paul Field
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: