ahmaddarawshi / powermock

Automatically exported from code.google.com/p/powermock
0 stars 0 forks source link

ExpectNew probably fails for varargs invocation when var args is not the first parameter #163

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
fix this

Original issue reported on code.google.com by johan.ha...@gmail.com on 11 Sep 2009 at 2:04

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 1 Oct 2009 at 8:47

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Class: NewInvocationControlImpl

public Object invoke(Class<?> type, Object[] args, Class<?>[] sig) throws 
Exception {
        Constructor<?> constructor = WhiteboxImpl.getConstructor(type, sig);
if (constructor.isVarArgs()) {
    /*
     * Get the first argument because this contains the actual varargs
     * arguments.
     */
    int length = constructor.getParameterTypes().length;
    args = (Object[]) args[length-1];
}

Not: args = (Object[]) args[0];

Original comment by rafael.b...@gmail.com on 16 Mar 2010 at 5:43

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 22 Jul 2010 at 9:17

GoogleCodeExporter commented 9 years ago
Class: NewInvocationControlImpl

public Object invoke(Class<?> type, Object[] args, Class<?>[] sig) throws 
Exception {
        Constructor<?> constructor = WhiteboxImpl.getConstructor(type, sig);
if (constructor.isVarArgs()) {
    /*
     * Get the "LAST" argument because this contains the actual varargs
     * arguments.
     */
    int length = constructor.getParameterTypes().length;
    args = (Object[]) args[length-1];
}

Not: args = (Object[]) args[0];

Original comment by rafael.b...@gmail.com on 19 Nov 2010 at 7:24

GoogleCodeExporter commented 9 years ago
Fixed in 1516

Original comment by johan.ha...@gmail.com on 22 Nov 2010 at 8:20

GoogleCodeExporter commented 9 years ago
It would be really helpful if you would verify in trunk

Original comment by johan.ha...@gmail.com on 22 Nov 2010 at 8:21