In the classes of the org.openmrs.validator package, the validate method casts a variable of type Object on a variable of type validator, without checking whether the variable is of type validator. The problem occurs in most classes. Several classes have this check.
In classes in which the type of the variable is not checked before casting, if the variable is of a different type, this may result in throwing an exception that is not declared in the code.
Add class check before casting.
Link to place in code without checking before casting:
Link to place in code with a check before casting: