author | lana |
Thu, 26 Dec 2013 12:04:16 -0800 | |
changeset 23010 | 6dadb192ad81 |
parent 12047 | 320a714614e9 |
child 23328 | 4c53a6ebc779 |
permissions | -rw-r--r-- |
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
12047
diff
changeset
|
2 |
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. |
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
4 |
* |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
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 |
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
10 |
* |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
15 |
* accompanied this code). |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
16 |
* |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
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. |
|
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
24 |
*/ |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
25 |
|
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
26 |
package sun.font; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
27 |
|
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
28 |
import java.awt.AWTError; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
29 |
import java.awt.Font; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
30 |
import java.awt.GraphicsEnvironment; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
31 |
import java.awt.Toolkit; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
32 |
import java.security.AccessController; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
33 |
import java.security.PrivilegedAction; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
34 |
|
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
35 |
import sun.security.action.GetPropertyAction; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
36 |
|
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
37 |
|
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
38 |
/** |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
39 |
* Factory class used to retrieve a valid FontManager instance for the current |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
40 |
* platform. |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
41 |
* |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
42 |
* A default implementation is given for Linux, Solaris and Windows. |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
43 |
* You can alter the behaviour of the {@link #getInstance()} method by setting |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
44 |
* the {@code sun.font.fontmanager} property. For example: |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
45 |
* {@code sun.font.fontmanager=sun.awt.X11FontManager} |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
46 |
*/ |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
47 |
public final class FontManagerFactory { |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
48 |
|
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
49 |
/** Our singleton instance. */ |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
50 |
private static FontManager instance = null; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
51 |
|
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
52 |
private static final String DEFAULT_CLASS; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
53 |
static { |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10355
diff
changeset
|
54 |
if (FontUtilities.isWindows) { |
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
55 |
DEFAULT_CLASS = "sun.awt.Win32FontManager"; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10355
diff
changeset
|
56 |
} else if (FontUtilities.isMacOSX) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10355
diff
changeset
|
57 |
DEFAULT_CLASS = "sun.font.CFontManager"; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10355
diff
changeset
|
58 |
} else { |
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
59 |
DEFAULT_CLASS = "sun.awt.X11FontManager"; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10355
diff
changeset
|
60 |
} |
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
61 |
} |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
62 |
|
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
63 |
/** |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
64 |
* Get a valid FontManager implementation for the current platform. |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
65 |
* |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
66 |
* @return a valid FontManager instance for the current platform |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
67 |
*/ |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
68 |
public static synchronized FontManager getInstance() { |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
69 |
|
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
70 |
if (instance != null) { |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
71 |
return instance; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
72 |
} |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
73 |
|
4824
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
74 |
AccessController.doPrivileged(new PrivilegedAction() { |
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
75 |
|
4824
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
76 |
public Object run() { |
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
77 |
try { |
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
78 |
String fmClassName = |
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
79 |
System.getProperty("sun.font.fontmanager", |
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
80 |
DEFAULT_CLASS); |
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
81 |
ClassLoader cl = ClassLoader.getSystemClassLoader(); |
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
82 |
Class fmClass = Class.forName(fmClassName, true, cl); |
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
83 |
instance = (FontManager) fmClass.newInstance(); |
10355
a976ff46116b
7080020: Add conventional constructors to InternalError and VirtualMachineError
darcy
parents:
7668
diff
changeset
|
84 |
} catch (ClassNotFoundException | |
a976ff46116b
7080020: Add conventional constructors to InternalError and VirtualMachineError
darcy
parents:
7668
diff
changeset
|
85 |
InstantiationException | |
a976ff46116b
7080020: Add conventional constructors to InternalError and VirtualMachineError
darcy
parents:
7668
diff
changeset
|
86 |
IllegalAccessException ex) { |
a976ff46116b
7080020: Add conventional constructors to InternalError and VirtualMachineError
darcy
parents:
7668
diff
changeset
|
87 |
throw new InternalError(ex); |
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
88 |
|
4824
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
89 |
} |
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
90 |
return null; |
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
91 |
} |
791405fa20ff
6888734: PIT: regression test fails when java.security.manager is enabled
rkennke
parents:
3929
diff
changeset
|
92 |
}); |
3929
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
93 |
|
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
94 |
return instance; |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
95 |
} |
de1a48b7aa41
6869705: Missing files of CR6795908, FontManager refactoring
rkennke
parents:
diff
changeset
|
96 |
} |