Note that there are some explanatory texts on larger screens.

plurals
  1. PODifference between IllegalAccessError and IllegalAccessException
    text
    copied!<p>Consider this pair of <code>Throwable</code>:</p> <blockquote> <p><a href="http://java.sun.com/javase/6/docs/api/java/lang/IllegalAccessException.html" rel="noreferrer"><code>IllegalAccessException</code></a><code>extends Exception</code></p> <p>Thrown 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.</p> <p><a href="http://java.sun.com/javase/6/docs/api/java/lang/IllegalAccessError.html" rel="noreferrer"><code>IllegalAccessError</code></a><code>ext IncompatibleClassChangeError ext LinkageError ext Error</code> </p> <p>Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.</p> <p>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. </p> </blockquote> <h3>Questions</h3> <ul> <li>Can someone give a code example where each is thrown?</li> <li>Does the similarity in name imply relationship between the two, or is it just pure coincidence?</li> <li>Are there other <code>XXXError</code> and <code>XXXException</code> combo? How are the pairs related to each other?</li> <li>If you explicitly <code>try</code> to <code>catch</code> one in an <code>Exception/Error</code> pair, should you also <code>catch</code> the other?</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload