ER-047 Operation (method or constructor) declares subclasses of RuntimeException in throws clause

Severity2
Enabledyes
Waivable
RationaleIt is not required to list subclasses of RuntimeException in throws clause. If you listed them for documentation purposes then use @throws JavaDoc tag instead.
Violation
public void searchObject(final java.util.Iterator iter, final Object anObj) throws IllegalArgumentException {
	if (iter.hasNext()) {
		for (Object obj = iter.next(); iter.hasNext(); obj = iter.next()) {
			if (obj.equals(anObj)) {
				throw new IllegalArgumentException(obj.toString());
			}
		}
	}
}
Fix
public void searchObject(final java.util.Iterator iter,Final Object anObj) {
	if (iter.hasNext()) {
		for (Object obj = iter.next(); iter.hasNext(); obj = iter.next()) {
			if (obj.equals(anObj)) {
				throw new IllegalArgumentException(obj.toString());
			}
		}
	}
}


Hammurapi 3 Copyright © 2004 Hammurapi Group. All Rights Reserved.