FULL PRODUCT VERSION :
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]
A DESCRIPTION OF THE PROBLEM :
If a class overrides a method with varargs then jdi is unable to invoke such method, see source sample.
We look for
foo(Object a, Object... args)
as it is declared in Base class.
concreteMethodByName returns the bridge method in Child class,
but it is not marked as vararg in class file.
And invocation of such method with one parameter produce:
java.lang.IllegalArgumentException : Invalid argument count: expected 2, received 1
If we invoke the "real" method foo(String a, String... args) everything works fine.
I'm not sure if it is the compiler that should mark such bridge as vararg or jdi should handle this.
This affects evaluation in IDEs (Netbeans, IDEA),
see https://youtrack.jetbrains.com/issue/IDEA-129869 for example.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Varargs {
public static void main(String[] args) {
Base b = new Child();
b.foo("dd"); // stop here and try to evaluate b.foo("dd")
}
public static class Base<T> {
CharSequence foo(T a, T... args) {
return a.toString();
}
}
public static class Child extends Base<String> {
String foo(String a, String... args) {
return a.toString();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
In the provided test sample you can evaluate ((Child)b).foo("dd");