groovy

Groovy fails to call varargs method signatures when an empty arg list is supplied

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0
  • Fix Version/s: 1.1-beta-2
  • Component/s: syntax
  • Labels:
    None
  • Environment:
    JDK 5.0 Apple Inc
  • Number of attachments :
    0

Description

//Java code
public class FacesMessages implements Serializable
{
   //vargars signature
   public void add(String messageTemplate, Object... params)
   {
      ...
   }
...
}

//From an other class
//This piece of code fails in Groovy, work in Java
   void invalid()
   {
      facesMessages.add("Please try again")
   }

Activity

Hide
Paul King added a comment - - edited

I have another example using Guice. The Guice class has the following methods:

public static Injector createInjector(Module... modules) { /* compiled code */ }    
public static Injector createInjector(java.lang.Iterable<Module> iterable) { /* compiled code */ }
...

I have to call Guice.createInjector([]) or Guice.createInjector({} as Module) but in Java I can call Guice.createInjector().

Show
Paul King added a comment - - edited I have another example using Guice. The Guice class has the following methods:
public static Injector createInjector(Module... modules) { /* compiled code */ }    
public static Injector createInjector(java.lang.Iterable<Module> iterable) { /* compiled code */ }
...
I have to call Guice.createInjector([]) or Guice.createInjector({} as Module) but in Java I can call Guice.createInjector().
Hide
blackdrag blackdrag added a comment -

there are two special paths in MetaClassHelper for method calls, one is for methods with no arguments and one is for methods with 1 null argument. It seems both had bugs and I fixed them. As for the original issue... I was unable to reproduce it. facesMessages.add("Please try again") is not called with one of the paths I corrected, it is no method call without arguments, and the argument is not null.

I close this bug for now, if it is still a problem please reopen it with a testcase, because I won't be able to reproduce the problem without it

Show
blackdrag blackdrag added a comment - there are two special paths in MetaClassHelper for method calls, one is for methods with no arguments and one is for methods with 1 null argument. It seems both had bugs and I fixed them. As for the original issue... I was unable to reproduce it. facesMessages.add("Please try again") is not called with one of the paths I corrected, it is no method call without arguments, and the argument is not null. I close this bug for now, if it is still a problem please reopen it with a testcase, because I won't be able to reproduce the problem without it

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: