Class NoSuchFieldError in Java

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{
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 classFrom Throwable class
wait(long, int)getLocalizedMessage()

Share and Enjoy !

Leave a Reply

Your email address will not be published. Required fields are marked *