java - Understanding conditions for precise rethrow -


static class firstexception extends exception { } static class secondexception extends exception { }  public void rethrowexception(string exceptionname) throws firstexception, secondexception {   try {     if (exceptionname.equals("first")) {       throw new firstexception();     } else {       throw new secondexception();     }   } catch (exception e) {     throw e;   } } 

in detail, in java se 7 , later, when declare 1 or more exception types in catch clause, , rethrow exception handled catch block, compiler verifies type of rethrown exception meets following conditions:

the try block able throw it.

there no other preceding catch blocks can handle it.

it subtype or supertype of 1 of catch clause's exception parameters.

can explain meaning of these conditions?(examples counter these conditions)

also in last condition, it refers , catch clause's exception parameters in above code?


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -