In Java’s try statement, each and every catch block catches the thrown exception by matching the exact type which is thrown. The exact type thrown should be reifiable to get it caught using Try-Catch statement.
Reifiable type is a type which can be completely represented at run-time.
Eg, A primitive type, non-parameterized class or interface type, parameterized type of unbounded wildcard (
), raw type (List), Array whose component is reifiable (
The afore-mentioned code will result in the following error.
The user might need to write such an extension to handle it the following way.
But this will never work as the type provided in the catch clause is not at all reifiable.