Consider this pair of Throwable:
IllegalAccessExceptionextends ExceptionThrown when an application tries to reflectively create an instance (other than an array), set or get a field, or invoke a method, but the currently executing method does not have access to the definition of the specified class, field, method or constructor.
IllegalAccessErrorext IncompatibleClassChangeError ext LinkageError ext ErrorThrown if an application attempts to access or modify a field, or to call a method that it does not have access to.
Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.
Questions
- Can someone give a code example where each is thrown?
- Does the similarity in name imply relationship between the two, or is it just pure coincidence?
- Are there other
XXXErrorandXXXExceptioncombo? How are the pairs related to each other? - If you explicitly
trytocatchone in anException/Errorpair, should you alsocatchthe other?