author | lbourges |
Mon, 23 Nov 2015 15:02:19 -0800 | |
changeset 34419 | 14108cfd0823 |
parent 31879 | 03c5b4e9687e |
child 37550 | c8252b8fea3d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
31653
d88ff422c7fb
8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
serb
parents:
29922
diff
changeset
|
2 |
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.java2d; |
|
27 |
||
24520
e8afd90fcb69
8035169: Move ThreadGroupUtils from the sun.misc package
pchelko
parents:
23900
diff
changeset
|
28 |
import sun.awt.util.ThreadGroupUtils; |
31653
d88ff422c7fb
8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
serb
parents:
29922
diff
changeset
|
29 |
import sun.misc.ManagedLocalsThread; |
23900
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
23288
diff
changeset
|
30 |
|
2 | 31 |
import java.lang.ref.Reference; |
32 |
import java.lang.ref.ReferenceQueue; |
|
33 |
import java.lang.ref.PhantomReference; |
|
34 |
import java.lang.ref.WeakReference; |
|
23900
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
23288
diff
changeset
|
35 |
import java.security.AccessController; |
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
23288
diff
changeset
|
36 |
import java.security.PrivilegedAction; |
4252
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
37 |
import java.util.ArrayList; |
2 | 38 |
import java.util.Hashtable; |
39 |
||
40 |
/** |
|
41 |
* This class is used for registering and disposing the native |
|
42 |
* data associated with java objects. |
|
43 |
* |
|
44 |
* The object can register itself by calling one of the addRecord |
|
45 |
* methods and providing either the pointer to the native disposal |
|
46 |
* method or a descendant of the DisposerRecord class with overridden |
|
47 |
* dispose() method. |
|
48 |
* |
|
49 |
* When the object becomes unreachable, the dispose() method |
|
50 |
* of the associated DisposerRecord object will be called. |
|
51 |
* |
|
52 |
* @see DisposerRecord |
|
53 |
*/ |
|
54 |
public class Disposer implements Runnable { |
|
23288
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
55 |
private static final ReferenceQueue<Object> queue = new ReferenceQueue<>(); |
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
56 |
private static final Hashtable<java.lang.ref.Reference<Object>, DisposerRecord> records = |
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
57 |
new Hashtable<>(); |
2 | 58 |
|
59 |
private static Disposer disposerInstance; |
|
60 |
public static final int WEAK = 0; |
|
61 |
public static final int PHANTOM = 1; |
|
62 |
public static int refType = PHANTOM; |
|
63 |
||
64 |
static { |
|
65 |
java.security.AccessController.doPrivileged( |
|
12559
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
7668
diff
changeset
|
66 |
new java.security.PrivilegedAction<Void>() { |
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
7668
diff
changeset
|
67 |
public Void run() { |
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
7668
diff
changeset
|
68 |
System.loadLibrary("awt"); |
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
7668
diff
changeset
|
69 |
return null; |
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
7668
diff
changeset
|
70 |
} |
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
7668
diff
changeset
|
71 |
}); |
2 | 72 |
initIDs(); |
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
20811
diff
changeset
|
73 |
String type = java.security.AccessController.doPrivileged( |
2 | 74 |
new sun.security.action.GetPropertyAction("sun.java2d.reftype")); |
75 |
if (type != null) { |
|
76 |
if (type.equals("weak")) { |
|
77 |
refType = WEAK; |
|
78 |
System.err.println("Using WEAK refs"); |
|
79 |
} else { |
|
80 |
refType = PHANTOM; |
|
81 |
System.err.println("Using PHANTOM refs"); |
|
82 |
} |
|
83 |
} |
|
84 |
disposerInstance = new Disposer(); |
|
29922 | 85 |
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { |
86 |
String name = "Java2D Disposer"; |
|
31653
d88ff422c7fb
8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
serb
parents:
29922
diff
changeset
|
87 |
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); |
d88ff422c7fb
8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
serb
parents:
29922
diff
changeset
|
88 |
Thread t = new ManagedLocalsThread(rootTG, disposerInstance, name); |
29922 | 89 |
t.setContextClassLoader(null); |
90 |
t.setDaemon(true); |
|
91 |
t.setPriority(Thread.MAX_PRIORITY); |
|
92 |
t.start(); |
|
93 |
return null; |
|
94 |
}); |
|
2 | 95 |
} |
96 |
||
97 |
/** |
|
98 |
* Registers the object and the native data for later disposal. |
|
99 |
* @param target Object to be registered |
|
100 |
* @param disposeMethod pointer to the native disposal method |
|
101 |
* @param pData pointer to the data to be passed to the |
|
102 |
* native disposal method |
|
103 |
*/ |
|
104 |
public static void addRecord(Object target, |
|
105 |
long disposeMethod, long pData) |
|
106 |
{ |
|
107 |
disposerInstance.add(target, |
|
108 |
new DefaultDisposerRecord(disposeMethod, pData)); |
|
109 |
} |
|
110 |
||
111 |
/** |
|
112 |
* Registers the object and the native data for later disposal. |
|
113 |
* @param target Object to be registered |
|
114 |
* @param rec the associated DisposerRecord object |
|
115 |
* @see DisposerRecord |
|
116 |
*/ |
|
117 |
public static void addRecord(Object target, DisposerRecord rec) { |
|
118 |
disposerInstance.add(target, rec); |
|
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* Performs the actual registration of the target object to be disposed. |
|
123 |
* @param target Object to be registered, or if target is an instance |
|
124 |
* of DisposerTarget, its associated disposer referent |
|
125 |
* will be the Object that is registered |
|
126 |
* @param rec the associated DisposerRecord object |
|
127 |
* @see DisposerRecord |
|
128 |
*/ |
|
129 |
synchronized void add(Object target, DisposerRecord rec) { |
|
130 |
if (target instanceof DisposerTarget) { |
|
131 |
target = ((DisposerTarget)target).getDisposerReferent(); |
|
132 |
} |
|
23288
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
133 |
java.lang.ref.Reference<Object> ref; |
2 | 134 |
if (refType == PHANTOM) { |
23288
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
135 |
ref = new PhantomReference<>(target, queue); |
2 | 136 |
} else { |
23288
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
137 |
ref = new WeakReference<>(target, queue); |
2 | 138 |
} |
139 |
records.put(ref, rec); |
|
140 |
} |
|
141 |
||
142 |
public void run() { |
|
143 |
while (true) { |
|
144 |
try { |
|
145 |
Object obj = queue.remove(); |
|
146 |
((Reference)obj).clear(); |
|
23288
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
147 |
DisposerRecord rec = records.remove(obj); |
2 | 148 |
rec.dispose(); |
149 |
obj = null; |
|
150 |
rec = null; |
|
4252
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
151 |
clearDeferredRecords(); |
2 | 152 |
} catch (Exception e) { |
20811 | 153 |
System.out.println("Exception while removing reference."); |
2 | 154 |
} |
155 |
} |
|
156 |
} |
|
157 |
||
4252
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
158 |
/* |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
159 |
* This is a marker interface that, if implemented, means it |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
160 |
* doesn't acquire any special locks, and is safe to |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
161 |
* be disposed in the poll loop on whatever thread |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
162 |
* which happens to be the Toolkit thread, is in use. |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
163 |
*/ |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
164 |
public static interface PollDisposable { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
165 |
}; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
166 |
|
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
167 |
private static ArrayList<DisposerRecord> deferredRecords = null; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
168 |
|
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
169 |
private static void clearDeferredRecords() { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
170 |
if (deferredRecords == null || deferredRecords.isEmpty()) { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
171 |
return; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
172 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
173 |
for (int i=0;i<deferredRecords.size(); i++) { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
174 |
try { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
175 |
DisposerRecord rec = deferredRecords.get(i); |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
176 |
rec.dispose(); |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
177 |
} catch (Exception e) { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
178 |
System.out.println("Exception while disposing deferred rec."); |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
179 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
180 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
181 |
deferredRecords.clear(); |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
182 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
183 |
|
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
184 |
/* |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
185 |
* Set to indicate the queue is presently being polled. |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
186 |
*/ |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
187 |
public static volatile boolean pollingQueue = false; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
188 |
|
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
189 |
/* |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
190 |
* The pollRemove() method is called back from a dispose method |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
191 |
* that is running on the toolkit thread and wants to |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
192 |
* dispose any pending refs that are safe to be disposed |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
193 |
* on that thread. |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
194 |
*/ |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
195 |
public static void pollRemove() { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
196 |
|
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
197 |
/* This should never be called recursively, so this check |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
198 |
* is just a safeguard against the unexpected. |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
199 |
*/ |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
200 |
if (pollingQueue) { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
201 |
return; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
202 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
203 |
Object obj; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
204 |
pollingQueue = true; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
205 |
int freed = 0; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
206 |
int deferred = 0; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
207 |
try { |
31879
03c5b4e9687e
8129457: Disposer.pollRemove may fail to dispose
psadhukhan
parents:
31653
diff
changeset
|
208 |
while ( freed < 10000 && deferred < 100 && |
03c5b4e9687e
8129457: Disposer.pollRemove may fail to dispose
psadhukhan
parents:
31653
diff
changeset
|
209 |
(obj = queue.poll()) != null ) { |
4252
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
210 |
freed++; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
211 |
((Reference)obj).clear(); |
23288
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
212 |
DisposerRecord rec = records.remove(obj); |
4252
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
213 |
if (rec instanceof PollDisposable) { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
214 |
rec.dispose(); |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
215 |
obj = null; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
216 |
rec = null; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
217 |
} else { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
218 |
if (rec == null) { // shouldn't happen, but just in case. |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
219 |
continue; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
220 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
221 |
deferred++; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
222 |
if (deferredRecords == null) { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
223 |
deferredRecords = new ArrayList<DisposerRecord>(5); |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
224 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
225 |
deferredRecords.add(rec); |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
226 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
227 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
228 |
} catch (Exception e) { |
20811 | 229 |
System.out.println("Exception while removing reference."); |
4252
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
230 |
} finally { |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
231 |
pollingQueue = false; |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
232 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
233 |
} |
0e645080f74b
6899078: potential deadlock and performance issue in freeing strike resources with D3D pipeline
prr
parents:
2
diff
changeset
|
234 |
|
2 | 235 |
private static native void initIDs(); |
236 |
||
237 |
/* |
|
238 |
* This was added for use by the 2D font implementation to avoid creation |
|
239 |
* of an additional disposer thread. |
|
240 |
* WARNING: this thread class monitors a specific queue, so a reference |
|
241 |
* added here must have been created with this queue. Failure to do |
|
242 |
* so will clutter the records hashmap and no one will be cleaning up |
|
243 |
* the reference queue. |
|
244 |
*/ |
|
23288
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
245 |
@SuppressWarnings("unchecked") |
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
246 |
public static void addReference(Reference<Object> ref, DisposerRecord rec) { |
2 | 247 |
records.put(ref, rec); |
248 |
} |
|
249 |
||
250 |
public static void addObjectRecord(Object obj, DisposerRecord rec) { |
|
23288
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
251 |
records.put(new WeakReference<>(obj, queue) , rec); |
2 | 252 |
} |
253 |
||
254 |
/* This is intended for use in conjunction with addReference(..) |
|
255 |
*/ |
|
23288
b7183846db97
8033624: Fix raw and unchecked lint warnings in sun.font
darcy
parents:
22584
diff
changeset
|
256 |
public static ReferenceQueue<Object> getQueue() { |
2 | 257 |
return queue; |
258 |
} |
|
259 |
||
260 |
} |