1 // Copyright 2008 The Android Open Source Project
3 import java.util.Timer;
4 import java.util.TimerTask;
7 * Throw an exception from a finalizer and make sure it's harmless. Under
8 * Dalvik this may also generate a warning in the log file.
11 static Object waiter = new Object();
12 static volatile boolean didFinal = false;
14 static void createAndForget() {
15 Main main = new Main();
18 public static void main(String[] args) {
22 System.runFinalization();
24 new Timer(true).schedule(new TimerTask() {
26 System.out.println("Timed out, exiting");
34 } catch (InterruptedException ie) {
35 System.err.println(ie);
39 /* give it a chance to cause mayhem */
42 } catch (InterruptedException ie) {
43 System.err.println(ie);
46 System.out.println("done");
49 protected void finalize() throws Throwable {
50 System.out.println("In finalizer");
54 throw new InterruptedException("whee");