src/share/classes/sun/awt/FontConfiguration.java
Print this page
rev 9830 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr
@@ -62,11 +62,11 @@
//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;
+ protected static Hashtable<String, String> localeMap = null;
private static FontConfiguration fontConfig;
private static PlatformLogger logger;
protected static boolean isProperties = true;
protected SunFontManager fontManager;
@@ -157,19 +157,19 @@
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() {
+ 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 false;
+ return Boolean.FALSE;
}
}
});
return exists.booleanValue();
}
@@ -532,15 +532,15 @@
}
private short remapLocaleMap(int fontIndex, int styleIndex, short scriptID, short fontID) {
String scriptName = getString(table_scriptIDs[scriptID]);
- String value = (String)localeMap.get(scriptName);
+ String value = localeMap.get(scriptName);
if (value == null) {
String fontName = fontNames[fontIndex];
String styleName = styleNames[styleIndex];
- value = (String)localeMap.get(fontName + "." + styleName + "." + scriptName);
+ value = localeMap.get(fontName + "." + styleName + "." + scriptName);
}
if (value == null) {
return fontID;
}
@@ -744,11 +744,11 @@
//////////////////////////////////////////////////////////////////////
/* Mappings from file encoding to font config name for font supporting
* the corresponding language. This is filled in by initReorderMap()
*/
- protected HashMap reorderMap = null;
+ 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,11 +775,11 @@
private static Object getReorderSequence() {
if (fontConfig.reorderMap == null) {
fontConfig.initReorderMap();
}
- HashMap reorderMap = fontConfig.reorderMap;
+ 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,13 +815,13 @@
}
}
}
}
- private static Vector splitSequence(String sequence) {
+ private static Vector<String> splitSequence(String sequence) {
//String.split would be more convenient, but incurs big performance penalty
- Vector parts = new Vector();
+ 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,18 +831,18 @@
}
return parts;
}
protected String[] split(String sequence) {
- Vector v = splitSequence(sequence);
- return (String[])v.toArray(new String[0]);
+ Vector<String> v = splitSequence(sequence);
+ return v.toArray(new String[0]);
}
////////////////////////////////////////////////////////////////////////
// Methods for extracting information from the fontconfig data for AWT//
////////////////////////////////////////////////////////////////////////
- private Hashtable charsetRegistry = new Hashtable(5);
+ 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,23 +930,23 @@
private CharsetEncoder getFontCharsetEncoder(final String charsetName,
String fontName) {
Charset fc = null;
if (charsetName.equals("default")) {
- fc = (Charset) charsetRegistry.get(fontName);
+ fc = charsetRegistry.get(fontName);
} else {
- fc = (Charset) charsetRegistry.get(charsetName);
+ 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 = (Class) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ Class<?> fcc = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
+ public Class<?> run() {
try {
return Class.forName(charsetName, true,
ClassLoader.getSystemClassLoader());
} catch (ClassNotFoundException e) {
}
@@ -1375,13 +1375,13 @@
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() {
+ String osName = java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<String>() {
+ public String run() {
return System.getProperty("os.name");
}
});
//componentFontNameID starts from "1"
@@ -2137,11 +2137,11 @@
key = key.substring(9);
boolean hasDefault = false;
boolean has1252 = false;
//get the scriptID list
- String[] ss = (String[])splitSequence(value).toArray(EMPTY_STRING_ARRAY);
+ 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";