7116890: additional warnings fixes for java.io
Reviewed-by: alanb, smarks
Contributed-by: Sebastian Sickelmann <sebastian.sickelmann@gmx.de>
--- a/jdk/src/share/classes/java/io/ExpiringCache.java Thu Dec 01 18:34:23 2011 +0000
+++ b/jdk/src/share/classes/java/io/ExpiringCache.java Thu Dec 01 16:14:41 2011 -0800
@@ -35,7 +35,7 @@
class ExpiringCache {
private long millisUntilExpiration;
- private Map map;
+ private Map<String,Entry> map;
// Clear out old entries every few queries
private int queryCount;
private int queryOverflow = 300;
@@ -61,10 +61,11 @@
this(30000);
}
+ @SuppressWarnings("serial")
ExpiringCache(long millisUntilExpiration) {
this.millisUntilExpiration = millisUntilExpiration;
- map = new LinkedHashMap() {
- protected boolean removeEldestEntry(Map.Entry eldest) {
+ map = new LinkedHashMap<String,Entry>() {
+ protected boolean removeEldestEntry(Map.Entry<String,Entry> eldest) {
return size() > MAX_ENTRIES;
}
};
@@ -99,7 +100,7 @@
}
private Entry entryFor(String key) {
- Entry entry = (Entry) map.get(key);
+ Entry entry = map.get(key);
if (entry != null) {
long delta = System.currentTimeMillis() - entry.timestamp();
if (delta < 0 || delta >= millisUntilExpiration) {
@@ -111,12 +112,11 @@
}
private void cleanup() {
- Set keySet = map.keySet();
+ Set<String> keySet = map.keySet();
// Avoid ConcurrentModificationExceptions
String[] keys = new String[keySet.size()];
int i = 0;
- for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
- String key = (String) iter.next();
+ for (String key: keySet) {
keys[i++] = key;
}
for (int j = 0; j < keys.length; j++) {
--- a/jdk/src/share/classes/java/io/LineNumberInputStream.java Thu Dec 01 18:34:23 2011 +0000
+++ b/jdk/src/share/classes/java/io/LineNumberInputStream.java Thu Dec 01 16:14:41 2011 -0800
@@ -87,6 +87,7 @@
* @see java.io.FilterInputStream#in
* @see java.io.LineNumberInputStream#getLineNumber()
*/
+ @SuppressWarnings("fallthrough")
public int read() throws IOException {
int c = pushBack;
--- a/jdk/src/share/classes/java/io/LineNumberReader.java Thu Dec 01 18:34:23 2011 +0000
+++ b/jdk/src/share/classes/java/io/LineNumberReader.java Thu Dec 01 16:14:41 2011 -0800
@@ -120,6 +120,7 @@
* @throws IOException
* If an I/O error occurs
*/
+ @SuppressWarnings("fallthrough")
public int read() throws IOException {
synchronized (lock) {
int c = super.read();
@@ -159,6 +160,7 @@
* @throws IOException
* If an I/O error occurs
*/
+ @SuppressWarnings("fallthrough")
public int read(char cbuf[], int off, int len) throws IOException {
synchronized (lock) {
int n = super.read(cbuf, off, len);
--- a/jdk/src/share/classes/java/io/ObjectOutputStream.java Thu Dec 01 18:34:23 2011 +0000
+++ b/jdk/src/share/classes/java/io/ObjectOutputStream.java Thu Dec 01 16:14:41 2011 -0800
@@ -1075,7 +1075,7 @@
} catch (NoSuchMethodException ex) {
}
try {
- cl.getDeclaredMethod("putFields", (Class[]) null);
+ cl.getDeclaredMethod("putFields", (Class<?>[]) null);
return Boolean.FALSE;
} catch (NoSuchMethodException ex) {
}
--- a/jdk/src/share/classes/java/io/RandomAccessFile.java Thu Dec 01 18:34:23 2011 +0000
+++ b/jdk/src/share/classes/java/io/RandomAccessFile.java Thu Dec 01 16:14:41 2011 -0800
@@ -1049,6 +1049,7 @@
* @param s a string of bytes to be written.
* @exception IOException if an I/O error occurs.
*/
+ @SuppressWarnings("deprecation")
public final void writeBytes(String s) throws IOException {
int len = s.length();
byte[] b = new byte[len];