Warnings Cleanup in java.util.<various> (more from hack day)
Michael Barker
mikeb01 at gmail.com
Fri Dec 2 12:33:34 PST 2011
> I would prefer to leave the "utf8" usage here un-changed.
>
> From performance point of view, String.getBytes("UTF8") is faster
> than String.getBytes(StandardCharsets.UTF_8).
Okay, patch updated.
Mike.
-------------- next part --------------
diff -r 43a630f11af6 src/share/classes/java/util/jar/Manifest.java
--- a/src/share/classes/java/util/jar/Manifest.java Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/java/util/jar/Manifest.java Fri Dec 02 20:31:50 2011 +0000
@@ -30,6 +30,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
@@ -51,7 +52,7 @@
private Attributes attr = new Attributes();
// manifest entries
- private Map entries = new HashMap();
+ private Map<String, Attributes> entries = new HashMap<>();
/**
* Constructs a new, empty Manifest.
@@ -148,11 +149,11 @@
// Write out the main attributes for the manifest
attr.writeMain(dos);
// Now write out the pre-entry attributes
- Iterator it = entries.entrySet().iterator();
+ Iterator<Map.Entry<String, Attributes>> it = entries.entrySet().iterator();
while (it.hasNext()) {
- Map.Entry e = (Map.Entry)it.next();
+ Map.Entry<String, Attributes> e = it.next();
StringBuffer buffer = new StringBuffer("Name: ");
- String value = (String)e.getKey();
+ String value = e.getKey();
if (value != null) {
byte[] vb = value.getBytes("UTF8");
value = new String(vb, 0, 0, vb.length);
@@ -161,7 +162,7 @@
buffer.append("\r\n");
make72Safe(buffer);
dos.writeBytes(buffer.toString());
- ((Attributes)e.getValue()).write(dos);
+ e.getValue().write(dos);
}
dos.flush();
}
More information about the jdk8-dev
mailing list