#324 Debug fails if called method argument is null

open
nobody
General (151)
5
2009-02-04
2009-02-04
Anonymous
No

In bsh.Reflect.java the below code fails if debug is turned on and one of method arguments is null.

Since args[i] is null, args[i].getClass() throws NullPointerException.

This makes debuging impossible in some cases.

Line:
+" type = "+args[i].getClass() );

Should be:
+" type = "+(args[i] == null ? "void" : args[i].getClass()) );

private static void logInvokeMethod(
String msg, Method method, Object[] args )
{
if ( Interpreter.DEBUG )
{
Interpreter.debug( msg +method+" with args:" );
for(int i=0; i<args.length; i++)
Interpreter.debug(
"args["+i+"] = "+args[i]
+" type = "+args[i].getClass() );
}
}

Discussion