Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7160

NoSuchMethodError for varargs when type parameter extends interface

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.7, 2.4.0-beta-3
    • 2.5.6, 3.0.0-beta-1
    • Static compilation
    • None

    Description

      Java code

      public class Foo<T extends java.io.Serializable> {
          public void bar(T... args) {}
      }
      

      Groovy code

      @groovy.transform.CompileStatic
      void test() {
          new Foo<String>().bar("a")
      }
      test()
      

      Error message

      Caught: java.lang.NoSuchMethodError: Foo.bar([Ljava/lang/Object;)V
      java.lang.NoSuchMethodError: Foo.bar([Ljava/lang/Object;)V
              at test.test(test.groovy:3)
              at test.run(test.groovy:5)
      

      This happens for these two conditions.
      1. Foo is a separate class and is not an inner class of the Groovy code
      2. T extends interface

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              yukoba Yu Kobayashi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m