IllegalAccessError is thrown from an application if an application attempts to access or modify a field or call a method for which it does not have access to. In general, this error is caught by the compiler. In very rare cases during the run time, if the class definition is changed incompatibly we may get this error.
In short, this error is thrown to signal that an attempt has been made to use an inaccessible class, method or variable.
The structure of the IllegalAccessError class given as:
public class java.lang.IllegalAccessError extends java.lang.IncompatibleClassChangeError{
//constructor
public IllegalAccessError();
//constructs an empty IllegalAccessError object that is an object with no message specified.
public IllegalAccessError(String message);
//constructs an IllegalAccessError object with the message specified.
}
The class IllegalAccessError also inherits methods from class Object and Throwable.