Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6.4
-
None
Description
I'm running into a problem with Groovy 1.6.4 that looks similar to
GROOVY-3560. I have the following java interface/classes:
public interface Foo {
}
public class AbstractFoo implements Foo{
}
public class ConcreteFoo implements Foo {
}
/**Implements Foo, but doesn't inherit from AbstractFoo **/
public class UnrelatedFoo implements Foo {
}
I also have the business java class, FooRunner:
public class FooRunner {
private final Foo[] foos;
public FooRunner(Foo... foos)
{ this.foos = foos; }public Foo[] getFoos()
{ return foos; }}
When I try to create a FooRunner from a Groovy script like so:
FooRunner runner = new FooRunner(new ConcreteFoo(), new UnrelatedFoo());
println runner.getFoos().length;
I get:
Caught: groovy.lang.GroovyRuntimeException: failed to invoke constructor:
public FooRunner(Foo[]) with arguments: [[ConcreteFoo@a9255c,
UnrelatedFoo@d3c6a3]]
reason: java.lang.IllegalArgumentException: argument type mismatch
at TestFoos.run(TestFoos.groovy:8)
This does work from Java. If I change my ConcreteFoo to implement Foo
instead of extending AbstractFoo, it works.