This is an abuse of claims to use to validate user input. Calling IllegalArgumentException for invalid input is more rights, because it allows the calling method to catch an exception, throw an error and do whatever it needs (request input again, exit, whatever).
If this method is a private method inside one of your classes, this statement is good because you are just trying to make sure that you did not pass a null argument to it by accident. You check the statements, and when you checked all the paths and did not call this statement, you can turn them off so you don’t waste resources on them. They are also useful as comments. assert at the beginning of the method is good documentation for maintainers that they must follow certain preconditions, and assert at the end with postcondition documents what this method should do. They can be just as helpful as comments; moreso because with the statements they actually test what they document.
Claims are for testing / debugging, not error checking, so they are disabled by default: to prevent people from using claims to validate user input.
Adam Jaskiewicz Nov 18 '08 at 15:03 2008-11-18 15:03
source share