--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java Wed Jul 06 11:08:20 2011 -0400
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java Fri Jul 08 10:25:57 2011 -0700
@@ -27,7 +27,6 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
-import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
@@ -47,8 +46,8 @@
* Control block for publishing Pack200 options to the other classes.
*/
-final class PropMap implements SortedMap<Object, Object> {
- private final TreeMap<Object, Object> theMap = new TreeMap<>();;
+final class PropMap implements SortedMap<String, String> {
+ private final TreeMap<String, String> theMap = new TreeMap<>();;
private final List<PropertyChangeListener> listenerList = new ArrayList<>(1);
void addListener(PropertyChangeListener listener) {
@@ -68,12 +67,12 @@
}
// Override:
- public Object put(Object key, Object value) {
- Object oldValue = theMap.put(key, value);
+ public String put(String key, String value) {
+ String oldValue = theMap.put(key, value);
if (value != oldValue && !listenerList.isEmpty()) {
// Post the property change event.
PropertyChangeEvent event =
- new PropertyChangeEvent(this, (String) key,
+ new PropertyChangeEvent(this, key,
oldValue, value);
for (PropertyChangeListener listener : listenerList) {
listener.propertyChange(event);
@@ -85,7 +84,7 @@
// All this other stuff is private to the current package.
// Outide clients of Pack200 do not need to use it; they can
// get by with generic SortedMap functionality.
- private static Map<Object, Object> defaultProps;
+ private static Map<String, String> defaultProps;
static {
Properties props = new Properties();
@@ -141,7 +140,9 @@
}
}
- defaultProps = (new HashMap<>(props)); // shrink to fit
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ HashMap<String, String> temp = new HashMap(props); // shrink to fit
+ defaultProps = temp;
}
PropMap() {
@@ -151,7 +152,7 @@
// Return a view of this map which includes only properties
// that begin with the given prefix. This is easy because
// the map is sorted, and has a subMap accessor.
- SortedMap<Object, Object> prefixMap(String prefix) {
+ SortedMap<String, String> prefixMap(String prefix) {
int len = prefix.length();
if (len == 0)
return this;
@@ -162,7 +163,7 @@
}
String getProperty(String s) {
- return (String) get(s);
+ return get(s);
}
String getProperty(String s, String defaultVal) {
String val = getProperty(s);
@@ -171,13 +172,13 @@
return val;
}
String setProperty(String s, String val) {
- return (String) put(s, val);
+ return put(s, val);
}
// Get sequence of props for "prefix", and "prefix.*".
- List getProperties(String prefix) {
- Collection<Object> values = prefixMap(prefix).values();
- List<Object> res = new ArrayList<>(values.size());
+ List<String> getProperties(String prefix) {
+ Collection<String> values = prefixMap(prefix).values();
+ List<String> res = new ArrayList<>(values.size());
res.addAll(values);
while (res.remove(null));
return res;
@@ -241,8 +242,8 @@
}
void list(PrintWriter out) {
out.println("#"+Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT+"[");
- Set defaults = defaultProps.entrySet();
- for (Map.Entry e : theMap.entrySet()) {
+ Set<Map.Entry<String, String>> defaults = defaultProps.entrySet();
+ for (Map.Entry<String, String> e : theMap.entrySet()) {
if (defaults.contains(e)) continue;
out.println(" " + e.getKey() + " = " + e.getValue());
}
@@ -270,18 +271,17 @@
}
@Override
- public Object get(Object key) {
+ public String get(Object key) {
return theMap.get(key);
}
@Override
- public Object remove(Object key) {
+ public String remove(Object key) {
return theMap.remove(key);
}
@Override
- @SuppressWarnings("unchecked")
- public void putAll(Map m) {
+ public void putAll(Map<? extends String, ? extends String> m) {
theMap.putAll(m);
}
@@ -291,48 +291,47 @@
}
@Override
- public Set<Object> keySet() {
+ public Set<String> keySet() {
return theMap.keySet();
}
@Override
- public Collection<Object> values() {
+ public Collection<String> values() {
return theMap.values();
}
@Override
- public Set<Map.Entry<Object, Object>> entrySet() {
+ public Set<Map.Entry<String, String>> entrySet() {
return theMap.entrySet();
}
@Override
- @SuppressWarnings("unchecked")
- public Comparator<Object> comparator() {
- return (Comparator<Object>) theMap.comparator();
+ public Comparator<? super String> comparator() {
+ return theMap.comparator();
}
@Override
- public SortedMap<Object, Object> subMap(Object fromKey, Object toKey) {
+ public SortedMap<String, String> subMap(String fromKey, String toKey) {
return theMap.subMap(fromKey, toKey);
}
@Override
- public SortedMap<Object, Object> headMap(Object toKey) {
+ public SortedMap<String, String> headMap(String toKey) {
return theMap.headMap(toKey);
}
@Override
- public SortedMap<Object, Object> tailMap(Object fromKey) {
+ public SortedMap<String, String> tailMap(String fromKey) {
return theMap.tailMap(fromKey);
}
@Override
- public Object firstKey() {
+ public String firstKey() {
return theMap.firstKey();
}
@Override
- public Object lastKey() {
+ public String lastKey() {
return theMap.lastKey();
}
}