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

Make proxies honor Java 8 default methods

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.4
    • None
    • plastic
    • None

    Description

      MyInterface.java:

      public interface MyInterface {
        default int compute() { return 42; }
      }
      

      PlasticSpec.groovy:

      class PlasticSpec extends Specification {
        def "plastic proxy for interface with default method"() {
          def manager = PlasticManager.withClassLoader(getClass().classLoader).create()
          def proxy = manager.createProxy(MyInterface, {})
          def impl = proxy.newInstance()
      
          expect:
          impl.compute() == 42 // fails; actual: 0
        }
      
        def "manual implementation of interface with default method"() {
          def impl = new MyInterface() {}
      
          expect:
          impl.compute() == 42 // passes
        }
      }
      

      Tested with 5.4-beta-6.

      Attachments

        1. plastic_default_methods.patch
          2 kB
          Peter Niederwieser

        Activity

          People

            hlship Howard Lewis Ship
            pniederw Peter Niederwieser
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: