Name: yyT116575 Date: 10/23/2000
JBuilder 4, dont know wich versjon..
This is a resubmit of this error by request.
Java hotspot outputs this error message when the error is really stack-
overflow. It happends when during recursion. I've included the java source. It
should be devided into three files(Test.java, sNodeList.java and sNode.java).
The class Test.java is the main class. It sorts a linked list of sNodes (nodes
containing a double value) by recursion. The class Test includes a loop that
generates the linked list. By changing the limits in the loop you should be
able to regenerate the error. The error seam to appear only near the
stackoverflow-limit (around 13500 objects..). Good luck with the debugging..
# HotSpot Virtual Machine Error, Internal Error
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
#
# Error ID: 53484152454432554E54494D450E43505000D8
//Test.java - a class for testing this problem..
public class Test{
sNodeList liste;
public static void main(String args[]){
Test testApp = new Test();
}
public Test(){
liste = new sNodeList();
//Loop that generates a linked list of sNode's
//13500 nodes makes the hotspot crash...
for (int i=0; i<13500; i++){
double x = Math.random()*100;
liste.addElement(new sNode(x));
}
long start = System.currentTimeMillis(); //Just timing the sorting..
liste.sort(); //Sorting the list
long stop = System.currentTimeMillis();
long tot = stop - start;
System.out.println("Objects sorted in : " + tot + "ms");
}
}
//SNodeList.java
//A linked list of sNode - objects
public class sNodeList{
sNode header;
sNode tail;
public sNodeList(){
header = new sNode(0.0);
tail = new sNode(0.0);
tail.setPrev(header);
header.setNext(tail);
}
public void addElement(sNode s){
tail.getPrev().setNext(s);
s.setNext(tail);
s.setPrev(tail.getPrev());
tail.setPrev(s);
}
public String toString(){
String str = "";
sNode tmpNode = header.getNext();
while(tmpNode != tail) {
str += tmpNode.toString() + "\n";
tmpNode = tmpNode.getNext();}
return str;
}
public void sort(){
//Here is the call that makes trouble...
header.getNext().sortMe(false);
}
public sNode getHead(){ return header; }
} //end of sNodeList class
//sNode.java
public class sNode{
private double tall;
private sNode prev;
private sNode next;
public sNode(double tall){
this.tall = tall;
next = null;
prev = null;
}
public String toString() {return tall + "";}
public sNode getNext(){ return next; }
public sNode getPrev(){ return prev; }
public void setNext(sNode next){ this.next = next; }
public void setPrev(sNode prev){ this.prev = prev; }
public boolean isLast(){ return (next == null) ; }
public boolean isFirst(){ return (prev.getPrev()== null); }
//This function is recursive and object-recursive (it calls the
//same function in another object..
//It goes first to the end of the list, and then starting moving
//to the front, bubbling every object that's not sorted
//backwards (to the end of the list).
public void sortMe(boolean backward){
if (next.isLast()) { return ; }
if (! backward) {next.sortMe(false);} //Goes to the end of the list
if (rCompare()) { rSwap(); sortMe(true);} //Bubbles this element if not sorted
}
public boolean rCompare(){
if ( this.tall > next.getTall()){ return true; }
return false;
}
public void rSwap(){
next.setPrev(prev);
prev = next;
next = next.getNext();
next.setPrev(this);
prev.setNext(this);
prev.getPrev().setNext(prev);
}
public double getTall(){ return this.tall; }
}//End of sNode class
(Review ID: 111190)
======================================================================
- duplicates
-
JDK-4298656 stack yellow zone not re-enabled after a StackOverflowError
-
- Closed
-