/*
 * @test
 * @key cte_test
 * @bug 4998314
 * @summary compute_compiled_exc_handler() called with pending exception
 *          Fixed in JDK1.4.2_05 Respin b02
 * @compile Test.java
 * @run main/othervm/timeout=240 -XX:-Inline -XX:CompileOnly=Test Test
*/

public class Test extends Thread {

    void foo(String x) {
        try { x.toString(); }
        catch (Exception ee) { }
        catch (ThreadDeath td) { System.out.println("THREAD DEATH!!!"); }
    }

    void test() {
        for (int i=0; i<10000; i++) foo((i%100 == 0)? "" : null);
    }

    public static void main(String[] args) throws InterruptedException {
        Test t = new Test();
        t.start();
        Thread thisThread = Thread.currentThread();
        thisThread.sleep(20000); // 20 sec
        for (int i=0; i<100; i++) {
            System.out.println("KILL THREAD!");
            t.stop();
        }
        System.exit(95); // TEST PASS
    }

    public void run() {
        for (int i=0; i<200000; i++) test();
    }
}
