· Avoidcatchingthrowable: This is dangerous because it casts too wide a net; it can catch things like outofmemoryerror.
Translation avoids catch throwable objects: This is dangerous because the coverage is too wide and it can catch errors similar to outofmemoryerror.
· Signaturedeclarethrowsexception: it is unclear which exceptions that can be thrown from the methods. It might be difficult to document and understand the vague interfaces. Use either a class derived from runtimeexception or a checked exception.
An exception thrown by a specific statement: you are not sure what type of exception can be thrown in the method. It is very difficult to prove and understand a fuzzy interface. The thrown exception class either inherits from runtimeexception or throws a checked exception.
· Exceptionasflowcontrol: using exceptions as flow control leads to gotoish code and obscures true exceptions when debugging.
Translation exceptions are used as process control: using exceptions for process control will lead to goto-type code and cause real exceptions to be vague during debugging.
· Avoidcatchingnpe: Code shocould never throw NPE under normal circumstances. A Catch Block may hide the original error, causing other more subtle errors in its wake.
Translation to avoid NULL pointer capturing exceptions: under normal circumstances, the Code should not capture nullpointexception. Otherwise, the catch block may hide the original error, resulting in more subtle errors.
· Avoidthrowingrawexceptiontypes: avoid throwing certain exception types. Rather than throw a raw runtimeexception, throwable, exception, or error, use a subclassed exception or error instead.
Avoid throwing the original exception type: avoid throwing a specific exception type. Instead of throwing the original types such as runtimeexception, throwable, exception, and error, it is better to use their subexceptions or suberror classes.
· Avoidthrowingnullpointerexception: avoid throwing a nullpointerexception-it's confusing because most people will assume that the virtual machine threw it. consider using an illegalargumentexception instead; this will be clearly seen as a programmer-initiated exception.
Avoid throwing a null pointer exception: avoid throwing a null pointer exception-this can cause misunderstanding, because most people think this should be thrown by the virtual machine. Consider using illegalargumentexception instead, which is clear for developer definition exceptions.
· Avoidrethrowingexception: Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity.
Avoid repeated throwing exceptions in Translation: simply throwing a caught exception in a catch block will increase the amount of code and the complexity of program running.
· Donotextendjavalangerror: errors are system exceptions. do not extend them.
Do not inherit java. Lang. Error: error is a system exception. do not inherit it.
· Donotthrowexceptioninfinally: throwing exception in a Finally block is confusing. it may mask exception or a defect of the Code, it also render code cleanup uninstable. note: This is a pmd implementation of the lint4j rule "a throw in a Finally block"
Do not throw an exception in the Finally block: it is confusing to throw an exception in the Finally block. It can mask code exceptions or defects and cause code instability. Note: This is implemented based on the lint4j principle.
· Avoidthrowingnewinstanceofsameexception: Catch blocks that merely rethrow a caught exception wrapped inside a new instance of the same type only add to code size and runtime complexity.
Avoid throwing new instances with similar exceptions: The Catch Block only resends a new instance with the same type of caught exceptions, which only increases the code volume and operation complexity.