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

Plastic class should exclude interface static methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.5.0, 5.6.2, 5.7.0, 5.7.1, 5.7.2, 5.7.3, 5.8.0, 5.8.1
    • 5.8.2
    • plastic
    • None

    Description

      Sample code to reproduce:

      public interface SampleService {
          static String sampleStaticMethod() {
              return "whatever";
          }
      
          String sampleMethod();
      } 
      public class SampleServiceImpl implements SampleService {
          @Override
          public String sampleMethod() {
              return "whatever";
          }
      } 
      public class AppModule {
          public static void bind(ServiceBinder binder) {
              binder.bind(SampleService.class, SampleServiceImpl.class);
          }
      
          @Match("*SampleService")
          public static void adviseSampleService(MethodAdviceReceiver receiver) {
              receiver.adviseAllMethods(MethodInvocation::proceed);
          }
          
          ...
      } 

      The code will fail with the following exception:

      ...
      Caused by: java.lang.RuntimeException: Exception constructing service 'SampleService': Unable to ... 
      at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:76) ~[tapestry-ioc-5.5.0.jar:?] 
      at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:55) ~[tapestry-ioc-5.5.0.jar:?]  
      ...
      Caused by: java.lang.IllegalArgumentException: Unable to introduce method 'public static java.lang.String sampleStaticMethod()' into class $SampleService_24850593ea4b7: introduced methods may not be static. 
      at org.apache.tapestry5.internal.plastic.PlasticClassImpl.createNewMethod(PlasticClassImpl.java:984) ~[plastic-5.5.0.jar:?] 
      at org.apache.tapestry5.internal.plastic.PlasticClassImpl.introduceMethod(PlasticClassImpl.java:938) ~[plastic-5.5.0.jar:?] 
      at org.apache.tapestry5.internal.plastic.PlasticClassImpl.introduceMethod(PlasticClassImpl.java:966) ~[plastic-5.5.0.jar:?] 
      at org.apache.tapestry5.ioc.internal.services.PlasticProxyFactoryImpl$1.transform(PlasticProxyFactoryImpl.java:138) ~[beanmodel-5.5.0.jar:?] 
      at org.apache.tapestry5.plastic.PlasticManager.createProxy(PlasticManager.java:287) ~[plastic-5.5.0.jar:?] 
      ...

       

      I guess PlasticProxyFactoryImpl#createProxy (around lines 136-138 for 5.5.0 and 5.6.2, 138-141 for 5.7.0) should exclude the static interface methods. 

       

      Attachments

        Activity

          People

            thiagohp Thiago Henrique De Paula Figueiredo
            piotr.czerwik Piotr Czerwik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: