40 * methods and providing either the pointer to the native disposal
41 * method or a descendant of the DisposerRecord class with overridden
42 * dispose() method.
43 *
44 * When the object becomes unreachable, the dispose() method
45 * of the associated DisposerRecord object will be called.
46 *
47 * @see DisposerRecord
48 */
49 public class Disposer implements Runnable {
50 private static final ReferenceQueue queue = new ReferenceQueue();
51 private static final Hashtable records = new Hashtable();
52
53 private static Disposer disposerInstance;
54 public static final int WEAK = 0;
55 public static final int PHANTOM = 1;
56 public static int refType = PHANTOM;
57
58 static {
59 java.security.AccessController.doPrivileged(
60 new sun.security.action.LoadLibraryAction("awt"));
61 initIDs();
62 String type = (String) java.security.AccessController.doPrivileged(
63 new sun.security.action.GetPropertyAction("sun.java2d.reftype"));
64 if (type != null) {
65 if (type.equals("weak")) {
66 refType = WEAK;
67 System.err.println("Using WEAK refs");
68 } else {
69 refType = PHANTOM;
70 System.err.println("Using PHANTOM refs");
71 }
72 }
73 disposerInstance = new Disposer();
74 java.security.AccessController.doPrivileged(
75 new java.security.PrivilegedAction() {
76 public Object run() {
77 /* The thread must be a member of a thread group
78 * which will not get GCed before VM exit.
79 * Make its parent the top-level thread group.
80 */
|
40 * methods and providing either the pointer to the native disposal
41 * method or a descendant of the DisposerRecord class with overridden
42 * dispose() method.
43 *
44 * When the object becomes unreachable, the dispose() method
45 * of the associated DisposerRecord object will be called.
46 *
47 * @see DisposerRecord
48 */
49 public class Disposer implements Runnable {
50 private static final ReferenceQueue queue = new ReferenceQueue();
51 private static final Hashtable records = new Hashtable();
52
53 private static Disposer disposerInstance;
54 public static final int WEAK = 0;
55 public static final int PHANTOM = 1;
56 public static int refType = PHANTOM;
57
58 static {
59 java.security.AccessController.doPrivileged(
60 new java.security.PrivilegedAction<Void>() {
61 public Void run() {
62 System.loadLibrary("awt");
63 return null;
64 }
65 });
66 initIDs();
67 String type = (String) java.security.AccessController.doPrivileged(
68 new sun.security.action.GetPropertyAction("sun.java2d.reftype"));
69 if (type != null) {
70 if (type.equals("weak")) {
71 refType = WEAK;
72 System.err.println("Using WEAK refs");
73 } else {
74 refType = PHANTOM;
75 System.err.println("Using PHANTOM refs");
76 }
77 }
78 disposerInstance = new Disposer();
79 java.security.AccessController.doPrivileged(
80 new java.security.PrivilegedAction() {
81 public Object run() {
82 /* The thread must be a member of a thread group
83 * which will not get GCed before VM exit.
84 * Make its parent the top-level thread group.
85 */
|