Class NoSuchFieldError in Java
NoSuchFieldError is thrown from an application if an application tries to access or modify a specified field of an object, and that object no longer has the field. In general, this error is caught during compilation time but can come in run time if the definition of the class has incompatibly changed.
A NoSuchFieldError is thrown in response to an attempt to reference an instance or class variable that is not defined in the current definition of a class. Usually, this error is caught by the compiler; it can occur at run-time if the definition of a class is changed after the class that references it was last compiled.
In a nutshell, NoSuchFieldError signals that a specified field could not be found.
The structure of the class NoSuchFieldError is given as:
public class java.lang.NoSuchFieldError extends java.lang.IncompatibleClassChangeError{
//constructor
public NoSuchFieldError();
//constructs an empty NoSuchFieldError object that is an object with no message specified.
public NoSuchFieldError(String message);
//constructs an NoSuchFieldError object with the message specified.
}
The class NoSuchFieldError also inherits methods from class Object and Throwable.
From Object class | From Throwable class |
---|---|
clone() | fillInStackTrace() |
getClass() | getMessage() |
notify() | printStackTrace() |
wait() | printStackTrace(PrintWriter) |
wait(long, int) | getLocalizedMessage() |
wait(long) | printStackTrace(PrintStream) |
equals(Object) | |
toString() | |
finalize() | |
hashCode() | |
notifyAll() |