Spread the love

Common Error classes in Java

Spread the love

Class IllegalAccessError in Java

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.

From Object classFrom 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()

Class ClassFormatError in Java

ClassFormatError is thrown from an application when java virtual machine attempts to read a binary format of the class file and determines that the file is malformed or can not be interpreted as a valid class file.

READ  Abstract interface ObjectInput in Java
READ  Final Modifier Simplified in Java

The structure of the ClassFormatError class is given as:

public class java.lang.ClassFormatError extends java.lang.LinkageError{
//constructor
public ClassFormatError();
//constructs an empty ClassFormatError object that is an object with no message specified.
public ClassFormatError(String message);
//constructs an ClassFormatError object with the message specified.
}

The class ClassFormatError also inherits methods from Object and Throwable class:

From Object classFrom 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()

Class ClassCircularityError in Java

ClassCircularityError is thrown from a program when a class extends to the same class or an interface extends to the same interface. This is a very rare scenario but can happen. The major reason to get this error is to have multiple versions of the same class present in the package structure(library). When JVM loads the class it can detect the circularity and throws the error.

In short, this error signals that a circular dependency or reference has been detected while performing initialization for a class.

The structure of ClassCircularityError is given below:

public class java.lang.ClassCircularityError extends java.lang.LinkageError{
//constructor
public ClassCircularityError();
//constructs an empty ClassCircularityError object that is an object with no message specified.
public ClassCircularityError(String message);
//constructs an ClassCircularityError object with the message specified.
}

The class ClassCircularityError also inherits methods from Object and Throwable class:

From Object classFrom 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()

AbstractMethodError in Java

AbstractMethodError is thrown when an application tries to call an abstract method.Normally this error is caught by the compiler.This error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.

READ  How To Bypass SSO in Automation Testing?
READ  Networking in Java Simplified

The structure of AbstractMethodError is defined as below:

public class java.lang.AbstractMethodError extends
             java.lang.IncompatibleClassChangeError{
//constructor
public AbstractMethodError();
//constructs an empty AbstractMethodError object that is an object with no 
//message specified.
public AbstractMethodError(String message);
//constructs an AbstractMethodError object with the message specified.
}

Apart from these this class also has the below inherited methods:
From Object class”

  • clone()
  • getClass()
  • equals(Object obj);
  • finalize()
  • hashCode()
  • notify()
  • notifyAll()
  • wait()
  • wait(long timeput)
  • wait(long timeout,int nanos)
  • toString()

From Throwable:

  • fillInStackTrace()
  • getMessage()
  • getLocalizedMessage()
  • printStackTrace()
  • printStackTrace(PrintWriter writer)
  • printStackTrace(PrintStream out)

Class AWTError in Java

An AWTError is thrown from an application when a serious Abstract Toolkit Error has occurred during execution. It is a runtime exception.

The class structure of the AWTError is given as:

public class java.awt.AWTError extends java.lang.Error{
//constructor
public AWTError(String message);
//constructs an AWTError with the specified detailed message.
} 




Spread the love
Animesh Chatterjeehttps://techtravelhub.com/
I am the founder and owner of the blog - TechTravelHub.com, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on ani01104@gamil.com

Related Articles

Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Recent Posts

Super Keyword in Java Simplified

Super Keyword Super Keyword in Java Simplified: Java defines a special...

Learn Object Repository in UFT in An Efficient and Fast Manner

Object Repository in UFT The post will cover the following...

Learn What Primary Tools For Test Automation

Primary Tools For Test Automation According to the Gartner report...

EDITOR PICKS


Spread the love