# java -cacao HotSpotError
# java -cacao JavaBug
Testing 100000 iterations...
No Bugs encountered, the computation was ok
# java JavaBug
Testing 100000 iterations...
BUG encountered at run #1689. Expected value 10, got: 1

JavaBug is another class exibithing the same bug, here is the source:

import java.util.ArrayList;

public class JavaBug {

 int num = 0;

 public JavaBug(int n) {
   num = n;
 }

 public boolean more() {
   return num-- > 0;
 }

 public ArrayList test1() {
   ArrayList<Object> res = new ArrayList<Object>();
   int maxResults = Integer.MAX_VALUE;
   int n = 0;
   boolean more = more();
   while ((n++ < maxResults) && more) {
     res.add(new Object());
     more = more();
   }
   return res;
 }

 public static void main(String[] pars) {
   System.out.println("Testing 100000 iterations...");
   for (int i=0; i<100000; i++) {
     JavaBug b = new JavaBug(10);
     if (b.test1().size() != 10) {
System.out.println("BUG encountered at run #"+i+". Expected value 10, got: "+b.test1().size());
       System.exit(-1);
     }
   }
   System.out.println("No Bugs encountered, the computation was ok");
 }
}




--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to