Warnings Cleanup in java.util. (more from hack day) (original) (raw)
Michael Barker mikeb01 at gmail.com
Fri Dec 2 12:02:22 PST 2011
- Previous message: Warnings Cleanup in java.util. (more from hack day)
- Next message: Warnings Cleanup in java.util. (more from hack day)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
one change to Manifest.java introduces a bug !
- byte[] vb = value.getBytes("UTF8"); - value = new String(vb, 0, 0, vb.length); + byte[] vb = value.getBytes(StandardCharsets.UTF8); + value = new String(vb, 0, 0, StandardCharsets.UTF8);
the last line should be: value = new String(vb, 0, 0, vb.length);
Cheers, good spot. I've attached an updated patch.
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 19:59:38 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,20 +149,20 @@ // 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");
byte[] vb = value.getBytes(StandardCharsets.UTF_8); value = new String(vb, 0, 0, vb.length); } buffer.append(value); buffer.append("\r\n"); make72Safe(buffer); dos.writeBytes(buffer.toString());
((Attributes)e.getValue()).write(dos);
}e.getValue().write(dos); } dos.flush();
- Previous message: Warnings Cleanup in java.util. (more from hack day)
- Next message: Warnings Cleanup in java.util. (more from hack day)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]