How can I test whether a given method will throw an exception or not (depending on the passed object) without invoking it?
For example:
public static boolean isAllowed(SomeObject obj)
{
try
{
myMethod(obj);
return true;
}
catch(Exception ex)
{
return false;
}
}
but the above method will perform MyMethod()
, how can I achieve this in java?
EDIT:
Actually, I want to do this to validate a filename. see this: Validate a file name on Windows