hello
i have constructor :
public ClassName(int...) { }
and I invoke somewhere:
ClassType.getConstructor(tab).newInstance(tab2);
where tab is "Class []" of "int []"
and tab2 is "int []"
I receive java.lang.NoSuchMethodException
why ?
if i change
public ClassName(int...){}
to
public ClassName(int, int, int, int) {}
all is ok
method getConstructors() see my constructor as:
public transient ClassName(int[]) public transient ClassName(int[])
any idea ?
Joshua Cranmer - 11 Nov 2007 18:43 GMT
> hello
>
[quoted text clipped - 20 lines]
>
> any idea ?
Can you provide a SSCCE (see <http://www.physci.org/codes/sscce.html>)?
My guess is that this is what you want to do:
ClassName.class.getConstructor(int[].class).newInstance(tab2);
But I can't see what's failing based on only what you have written--the
error is as often in what is not provided as it is in what is provided.

Signature
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
Arne Vajhøj - 12 Nov 2007 02:28 GMT
> i have constructor :
> public ClassName(int...) { }
[quoted text clipped - 18 lines]
>
> any idea ?
public class ConLkUp {
public ConLkUp(int... ia) {
for(int i : ia) {
System.out.println(i);
}
}
public static void main(String[] args) throws Exception {
ConLkUp o = ConLkUp.class.getConstructor(new Class[] {
int[].class }).newInstance(new int[] {1, 2, 3} );
}
}
Arne