Class StackOverFlowError in Java
StackOverFlowError is thrown from an application when an application recursive too deep and in an uncontrollable manner. This happens when the stack section of the JVM is full and can not hold any more entry. This error happens in Java interpreter.
In general, A thread stores all its information while it executes its methods into the stack. The stack also stores primitive datatypes, objects pointers, local variables, return values. During this process, the stack becomes heavy as they occupy memory.
When the stack becomes too heavy and grows beyond the permissible allocated memory, StackOverFlowError occurs. The most prominent cause when a thread calls a function again and again recursively as the application code may have a bug.
The class StackOverFlowError is defined as :
public class java.lang.StackOverFlowError extends java.lang.VirtualMachineError{
//constructor
public StackOverFlowError();//constructs an empty StackOverFlowError object that is an object with no message specified.
public StackOverFlowError(String message);//constructs an StackOverFlowError object with the message specified.
}
The class StackOverFlowError 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() |