src/share/classes/sun/awt/FontConfiguration.java
Print this page
rev 9717 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by:
*** 62,72 ****
//static global runtime env
protected static String osVersion;
protected static String osName;
protected static String encoding; // canonical name of default nio charset
protected static Locale startupLocale = null;
! protected static Hashtable localeMap = null;
private static FontConfiguration fontConfig;
private static PlatformLogger logger;
protected static boolean isProperties = true;
protected SunFontManager fontManager;
--- 62,72 ----
//static global runtime env
protected static String osVersion;
protected static String osName;
protected static String encoding; // canonical name of default nio charset
protected static Locale startupLocale = null;
! protected static Hashtable<String, String> localeMap = null;
private static FontConfiguration fontConfig;
private static PlatformLogger logger;
protected static boolean isProperties = true;
protected SunFontManager fontManager;
*** 157,175 ****
public boolean fontFilesArePresent() {
init();
short fontNameID = compFontNameIDs[0][0][0];
short fileNameID = getComponentFileID(fontNameID);
final String fileName = mapFileName(getComponentFileName(fileNameID));
! Boolean exists = (Boolean)java.security.AccessController.doPrivileged(
! new java.security.PrivilegedAction() {
! public Object run() {
try {
File f = new File(fileName);
return Boolean.valueOf(f.exists());
}
catch (Exception e) {
! return false;
}
}
});
return exists.booleanValue();
}
--- 157,175 ----
public boolean fontFilesArePresent() {
init();
short fontNameID = compFontNameIDs[0][0][0];
short fileNameID = getComponentFileID(fontNameID);
final String fileName = mapFileName(getComponentFileName(fileNameID));
! Boolean exists = java.security.AccessController.doPrivileged(
! new java.security.PrivilegedAction<Boolean>() {
! public Boolean run() {
try {
File f = new File(fileName);
return Boolean.valueOf(f.exists());
}
catch (Exception e) {
! return Boolean.FALSE;
}
}
});
return exists.booleanValue();
}
*** 532,546 ****
}
private short remapLocaleMap(int fontIndex, int styleIndex, short scriptID, short fontID) {
String scriptName = getString(table_scriptIDs[scriptID]);
! String value = (String)localeMap.get(scriptName);
if (value == null) {
String fontName = fontNames[fontIndex];
String styleName = styleNames[styleIndex];
! value = (String)localeMap.get(fontName + "." + styleName + "." + scriptName);
}
if (value == null) {
return fontID;
}
--- 532,546 ----
}
private short remapLocaleMap(int fontIndex, int styleIndex, short scriptID, short fontID) {
String scriptName = getString(table_scriptIDs[scriptID]);
! String value = localeMap.get(scriptName);
if (value == null) {
String fontName = fontNames[fontIndex];
String styleName = styleNames[styleIndex];
! value = localeMap.get(fontName + "." + styleName + "." + scriptName);
}
if (value == null) {
return fontID;
}
*** 744,754 ****
//////////////////////////////////////////////////////////////////////
/* Mappings from file encoding to font config name for font supporting
* the corresponding language. This is filled in by initReorderMap()
*/
! protected HashMap reorderMap = null;
/* Platform-specific mappings */
protected abstract void initReorderMap();
/* Move item at index "src" to "dst", shuffling all values in
--- 744,754 ----
//////////////////////////////////////////////////////////////////////
/* Mappings from file encoding to font config name for font supporting
* the corresponding language. This is filled in by initReorderMap()
*/
! protected HashMap<String, Object> reorderMap = null;
/* Platform-specific mappings */
protected abstract void initReorderMap();
/* Move item at index "src" to "dst", shuffling all values in
*** 775,785 ****
private static Object getReorderSequence() {
if (fontConfig.reorderMap == null) {
fontConfig.initReorderMap();
}
! HashMap reorderMap = fontConfig.reorderMap;
/* Find the most specific mapping */
String language = startupLocale.getLanguage();
String country = startupLocale.getCountry();
Object val = reorderMap.get(encoding + "." + language + "." + country);
--- 775,785 ----
private static Object getReorderSequence() {
if (fontConfig.reorderMap == null) {
fontConfig.initReorderMap();
}
! HashMap<String, Object> reorderMap = fontConfig.reorderMap;
/* Find the most specific mapping */
String language = startupLocale.getLanguage();
String country = startupLocale.getCountry();
Object val = reorderMap.get(encoding + "." + language + "." + country);
*** 815,827 ****
}
}
}
}
! private static Vector splitSequence(String sequence) {
//String.split would be more convenient, but incurs big performance penalty
! Vector parts = new Vector();
int start = 0;
int end;
while ((end = sequence.indexOf(',', start)) >= 0) {
parts.add(sequence.substring(start, end));
start = end + 1;
--- 815,827 ----
}
}
}
}
! private static Vector<String> splitSequence(String sequence) {
//String.split would be more convenient, but incurs big performance penalty
! Vector<String> parts = new Vector<>();
int start = 0;
int end;
while ((end = sequence.indexOf(',', start)) >= 0) {
parts.add(sequence.substring(start, end));
start = end + 1;
*** 831,848 ****
}
return parts;
}
protected String[] split(String sequence) {
! Vector v = splitSequence(sequence);
! return (String[])v.toArray(new String[0]);
}
////////////////////////////////////////////////////////////////////////
// Methods for extracting information from the fontconfig data for AWT//
////////////////////////////////////////////////////////////////////////
! private Hashtable charsetRegistry = new Hashtable(5);
/**
* Returns FontDescriptors describing the physical fonts used for the
* given logical font name and style. The font name is interpreted
* in a case insensitive way.
--- 831,848 ----
}
return parts;
}
protected String[] split(String sequence) {
! Vector<String> v = splitSequence(sequence);
! return v.toArray(new String[0]);
}
////////////////////////////////////////////////////////////////////////
// Methods for extracting information from the fontconfig data for AWT//
////////////////////////////////////////////////////////////////////////
! private Hashtable<String, Charset> charsetRegistry = new Hashtable<>(5);
/**
* Returns FontDescriptors describing the physical fonts used for the
* given logical font name and style. The font name is interpreted
* in a case insensitive way.
*** 930,952 ****
private CharsetEncoder getFontCharsetEncoder(final String charsetName,
String fontName) {
Charset fc = null;
if (charsetName.equals("default")) {
! fc = (Charset) charsetRegistry.get(fontName);
} else {
! fc = (Charset) charsetRegistry.get(charsetName);
}
if (fc != null) {
return fc.newEncoder();
}
if (!charsetName.startsWith("sun.awt.") && !charsetName.equals("default")) {
fc = Charset.forName(charsetName);
} else {
! Class fcc = (Class) AccessController.doPrivileged(new PrivilegedAction() {
! public Object run() {
try {
return Class.forName(charsetName, true,
ClassLoader.getSystemClassLoader());
} catch (ClassNotFoundException e) {
}
--- 930,952 ----
private CharsetEncoder getFontCharsetEncoder(final String charsetName,
String fontName) {
Charset fc = null;
if (charsetName.equals("default")) {
! fc = charsetRegistry.get(fontName);
} else {
! fc = charsetRegistry.get(charsetName);
}
if (fc != null) {
return fc.newEncoder();
}
if (!charsetName.startsWith("sun.awt.") && !charsetName.equals("default")) {
fc = Charset.forName(charsetName);
} else {
! Class<?> fcc = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
! public Class<?> run() {
try {
return Class.forName(charsetName, true,
ClassLoader.getSystemClassLoader());
} catch (ClassNotFoundException e) {
}
*** 1375,1387 ****
private static void sanityCheck() {
int errors = 0;
//This method will only be called during build time, do we
//need do PrivilegedAction?
! String osName = (String)java.security.AccessController.doPrivileged(
! new java.security.PrivilegedAction() {
! public Object run() {
return System.getProperty("os.name");
}
});
//componentFontNameID starts from "1"
--- 1375,1387 ----
private static void sanityCheck() {
int errors = 0;
//This method will only be called during build time, do we
//need do PrivilegedAction?
! String osName = java.security.AccessController.doPrivileged(
! new java.security.PrivilegedAction<String>() {
! public String run() {
return System.getProperty("os.name");
}
});
//componentFontNameID starts from "1"
*** 2137,2147 ****
key = key.substring(9);
boolean hasDefault = false;
boolean has1252 = false;
//get the scriptID list
! String[] ss = (String[])splitSequence(value).toArray(EMPTY_STRING_ARRAY);
short [] sa = new short[ss.length];
for (int i = 0; i < ss.length; i++) {
if ("alphabetic/default".equals(ss[i])) {
//System.out.println(key + " -> " + ss[i]);
ss[i] = "alphabetic";
--- 2137,2147 ----
key = key.substring(9);
boolean hasDefault = false;
boolean has1252 = false;
//get the scriptID list
! String[] ss = splitSequence(value).toArray(EMPTY_STRING_ARRAY);
short [] sa = new short[ss.length];
for (int i = 0; i < ss.length; i++) {
if ("alphabetic/default".equals(ss[i])) {
//System.out.println(key + " -> " + ss[i]);
ss[i] = "alphabetic";