I was recently quickly writing this little function 5 minutes ago when i got the compiler error unreachable statement
private static boolean isTransientField(String name, Class beanClass) {
try {
Field field = beanClass.getDeclaredField(name);
return (field.getModifiers() & Modifier.TRANSIENT) == Modifier.TRANSIENT;
} catch (Exception e) {return false;}
return false;//unreachable statement
}
Apparently my last return false is unreachable but why if my catch block only runs in exceptional cases?
Because you have a return statement within the try.