author | chegar |
Mon, 17 Jun 2013 14:09:25 +0100 | |
changeset 18178 | ee71c923891d |
parent 5506 | 202f599c92aa |
child 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2005, 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 |
package sun.awt.X11; |
|
26 |
||
27 |
import sun.misc.Unsafe; |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2
diff
changeset
|
28 |
import sun.util.logging.PlatformLogger; |
2 | 29 |
|
30 |
class UnsafeXDisposerRecord implements sun.java2d.DisposerRecord { |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2
diff
changeset
|
31 |
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.UnsafeXDisposerRecord"); |
2 | 32 |
private static Unsafe unsafe = XlibWrapper.unsafe; |
33 |
final long[] unsafe_ptrs, x_ptrs; |
|
34 |
final String name; |
|
35 |
volatile boolean disposed; |
|
36 |
final Throwable place; |
|
37 |
public UnsafeXDisposerRecord(String name, long[] unsafe_ptrs, long[] x_ptrs) { |
|
38 |
this.unsafe_ptrs = unsafe_ptrs; |
|
39 |
this.x_ptrs = x_ptrs; |
|
40 |
this.name = name; |
|
41 |
if (XlibWrapper.isBuildInternal) { |
|
42 |
place = new Throwable(); |
|
43 |
} else { |
|
44 |
place = null; |
|
45 |
} |
|
46 |
} |
|
47 |
public UnsafeXDisposerRecord(String name, long ... unsafe_ptrs) { |
|
48 |
this.unsafe_ptrs = unsafe_ptrs; |
|
49 |
this.x_ptrs = null; |
|
50 |
this.name = name; |
|
51 |
if (XlibWrapper.isBuildInternal) { |
|
52 |
place = new Throwable(); |
|
53 |
} else { |
|
54 |
place = null; |
|
55 |
} |
|
56 |
} |
|
57 |
||
58 |
public void dispose() { |
|
59 |
XToolkit.awtLock(); |
|
60 |
try { |
|
61 |
if (!disposed) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
5506
diff
changeset
|
62 |
if (XlibWrapper.isBuildInternal && "Java2D Disposer".equals(Thread.currentThread().getName()) && log.isLoggable(PlatformLogger.Level.WARNING)) { |
2 | 63 |
if (place != null) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2
diff
changeset
|
64 |
log.warning(name + " object was not disposed before finalization!", place); |
2 | 65 |
} else { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
2
diff
changeset
|
66 |
log.warning(name + " object was not disposed before finalization!"); |
2 | 67 |
} |
68 |
} |
|
69 |
||
70 |
if (unsafe_ptrs != null) { |
|
71 |
for (long l : unsafe_ptrs) { |
|
72 |
if (l != 0) { |
|
73 |
unsafe.freeMemory(l); |
|
74 |
} |
|
75 |
} |
|
76 |
} |
|
77 |
if (x_ptrs != null) { |
|
78 |
for (long l : x_ptrs) { |
|
79 |
if (l != 0) { |
|
80 |
if (Native.getLong(l) != 0) { |
|
81 |
XlibWrapper.XFree(Native.getLong(l)); |
|
82 |
} |
|
83 |
unsafe.freeMemory(l); |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
disposed = true; |
|
88 |
} |
|
89 |
} finally { |
|
90 |
XToolkit.awtUnlock(); |
|
91 |
} |
|
92 |
} |
|
93 |
} |