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

IllegalArgumentException with interface typed varargs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.3
    • 1.6.4, 1.7-beta-1
    • None
    • None

    Description

      If you define a java method with an interface typed varargs parameter and call this method with at least two different subclasses from groovy, you get an IllegalArgumentException.

      Here is the interface:

      Ifc.java
      public interface Ifc {}
      

      the two classes:

      ClsA.java
      public class ClsA implements Ifc{}
      
      ClsB.java
      public class ClsB implements Ifc{}
      

      the method with varargs:

      public class TestJava {
      public static void meth(Ifc...ifcs){
      	System.out.println(ifcs.length);
      }
      }
      

      the call:

      TestJava.meth(new ClsA(),new ClsB())
      

      Works from java but throws an IllegalArgumentException from groovy.

      Interestingly, if Ifc is a class, everything works as expected.

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            dferrand Damien Ferrand
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: