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

Can't call Java varargs method when it's mixed in to toplevel

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.5, 1.7-beta-2
    • 1.6.6, 1.7-rc-1
    • None
    • None
    • Java 1.5, OS X Leopard.

    Description

      Take this Java class:

      Dsl.java
      public class Dsl {
          public static void novarargs(java.util.List s) {
              System.out.println("novarargs ok");
          }
      
          public static void varargs(Object... s) {
              System.out.println("varargs ok");
          }
      }
      

      Run it with Groovy:

      UseDsl.groovy
      this.metaClass.mixin(Dsl)
      
      Dsl.novarargs(["a", "b"])
      novarargs(["a", "b"])
      
      Dsl.varargs("a", "b")
      varargs("a", "b")    // fails here
      

      The last one fails:

      javac Dsl.java && groovy UseDsl.groovy 
      
      Caught: java.lang.IllegalArgumentException: wrong number of arguments
      	at UseDsl.run(UseDsl.groovy:7)
      

      Attachments

        1. TestNewDsl.groovy
          0.8 kB
          Roshan Dawrani
        2. NewDsl.java
          0.7 kB
          Roshan Dawrani
        3. groovy3878_mixin_varargs.patch
          1 kB
          paulk_asert
        4. 3678_v17x.txt
          0.6 kB
          Roshan Dawrani

        Activity

          People

            paulk Paul King
            rinkrank Aslak Hellesoy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: