One problem I've noticed when porting reflection code from Java 8 to Java 9+ is that setAccessible()
now throws InaccessibleObjectException
in addition to SecurityException
when before in Java 8 InaccessibleObjectException
wasn't an exception type.
What is the accepted way to write code that has to catch and handle an exception that it can't know about since it's in a future Java version yet still be compatible with the current version? (In this case the only ancestor class is RuntimeException
, but that feels like a smell to me personally to write such an all-encompassing catch
.)