mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8234147: Avoid looking up standard charsets in core libraries
Reviewed-by: alanb
This commit is contained in:
parent
4e64af81a2
commit
cd589d8469
36 changed files with 200 additions and 237 deletions
|
@ -36,9 +36,9 @@ import java.util.Set;
|
|||
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import sun.nio.cs.UTF_8;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
/**
|
||||
* The Attributes class maps Manifest attribute names to associated string
|
||||
|
@ -337,7 +337,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
buffer.append(vername);
|
||||
buffer.append(": ");
|
||||
buffer.append(version);
|
||||
out.write(buffer.toString().getBytes(UTF_8));
|
||||
out.write(buffer.toString().getBytes(UTF_8.INSTANCE));
|
||||
Manifest.println(out);
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
lastline = buf;
|
||||
continue;
|
||||
}
|
||||
value = new String(buf, 0, buf.length, UTF_8);
|
||||
value = new String(buf, 0, buf.length, UTF_8.INSTANCE);
|
||||
lastline = null;
|
||||
} else {
|
||||
while (lbuf[i++] != ':') {
|
||||
|
@ -412,13 +412,13 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
throw new IOException("invalid header field ("
|
||||
+ Manifest.getErrorPosition(filename, lineNumber) + ")");
|
||||
}
|
||||
name = new String(lbuf, 0, i - 2, UTF_8);
|
||||
name = new String(lbuf, 0, i - 2, UTF_8.INSTANCE);
|
||||
if (is.peek() == ' ') {
|
||||
lastline = new byte[len - i];
|
||||
System.arraycopy(lbuf, i, lastline, 0, len - i);
|
||||
continue;
|
||||
}
|
||||
value = new String(lbuf, i, len - i, UTF_8);
|
||||
value = new String(lbuf, i, len - i, UTF_8.INSTANCE);
|
||||
}
|
||||
try {
|
||||
if ((putValue(name, value) != null) && (!lineContinued)) {
|
||||
|
|
|
@ -33,10 +33,9 @@ import java.io.OutputStream;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import sun.nio.cs.UTF_8;
|
||||
import sun.security.util.SecurityProperties;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
/**
|
||||
* The Manifest class is used to maintain Manifest entry names and their
|
||||
* associated Attributes. There are main Manifest Attributes as well as
|
||||
|
@ -237,7 +236,7 @@ public class Manifest implements Cloneable {
|
|||
*/
|
||||
static void println72(OutputStream out, String line) throws IOException {
|
||||
if (!line.isEmpty()) {
|
||||
byte[] lineBytes = line.getBytes(UTF_8);
|
||||
byte[] lineBytes = line.getBytes(UTF_8.INSTANCE);
|
||||
int length = lineBytes.length;
|
||||
// first line can hold one byte more than subsequent lines which
|
||||
// start with a continuation line break space
|
||||
|
@ -337,7 +336,7 @@ public class Manifest implements Cloneable {
|
|||
lastline = buf;
|
||||
continue;
|
||||
}
|
||||
name = new String(buf, 0, buf.length, UTF_8);
|
||||
name = new String(buf, 0, buf.length, UTF_8.INSTANCE);
|
||||
lastline = null;
|
||||
}
|
||||
Attributes attr = getAttributes(name);
|
||||
|
@ -362,11 +361,7 @@ public class Manifest implements Cloneable {
|
|||
if (toLower(lbuf[0]) == 'n' && toLower(lbuf[1]) == 'a' &&
|
||||
toLower(lbuf[2]) == 'm' && toLower(lbuf[3]) == 'e' &&
|
||||
lbuf[4] == ':' && lbuf[5] == ' ') {
|
||||
try {
|
||||
return new String(lbuf, 6, len - 6, UTF_8);
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
return new String(lbuf, 6, len - 6, UTF_8.INSTANCE);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue