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
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -33,7 +33,7 @@ import java.nio.charset.CharsetEncoder;
|
|||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.CodingErrorAction;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import sun.nio.cs.UTF_8;
|
||||
|
||||
/**
|
||||
* Utility class for zipfile name and comment decoding and encoding
|
||||
|
@ -67,10 +67,10 @@ class ZipCoder {
|
|||
}
|
||||
|
||||
// UTF_8.ArrayEn/Decoder is stateless, so make it singleton.
|
||||
private static ZipCoder utf8 = new UTF8(UTF_8);
|
||||
private static ZipCoder utf8 = new UTF8(UTF_8.INSTANCE);
|
||||
|
||||
public static ZipCoder get(Charset charset) {
|
||||
if (charset == UTF_8)
|
||||
if (charset == UTF_8.INSTANCE)
|
||||
return utf8;
|
||||
return new ZipCoder(charset);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import java.io.RandomAccessFile;
|
|||
import java.io.UncheckedIOException;
|
||||
import java.lang.ref.Cleaner.Cleanable;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.Files;
|
||||
|
@ -65,6 +64,7 @@ import jdk.internal.misc.VM;
|
|||
import jdk.internal.perf.PerfCounter;
|
||||
import jdk.internal.ref.CleanerFactory;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
import sun.nio.cs.UTF_8;
|
||||
|
||||
import static java.util.zip.ZipConstants64.*;
|
||||
import static java.util.zip.ZipUtils.*;
|
||||
|
@ -165,7 +165,7 @@ public class ZipFile implements ZipConstants, Closeable {
|
|||
* @since 1.3
|
||||
*/
|
||||
public ZipFile(File file, int mode) throws IOException {
|
||||
this(file, mode, StandardCharsets.UTF_8);
|
||||
this(file, mode, UTF_8.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1042,7 +1042,7 @@ public class ZipFile implements ZipConstants, Closeable {
|
|||
for (int i = 0; i < names.length; i++) {
|
||||
int pos = zsrc.metanames[i];
|
||||
names[i] = new String(cen, pos + CENHDR, CENNAM(cen, pos),
|
||||
StandardCharsets.UTF_8);
|
||||
UTF_8.INSTANCE);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,9 @@ import java.io.IOException;
|
|||
import java.io.EOFException;
|
||||
import java.io.PushbackInputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import sun.nio.cs.UTF_8;
|
||||
|
||||
import static java.util.zip.ZipConstants64.*;
|
||||
import static java.util.zip.ZipUtils.*;
|
||||
|
||||
|
@ -77,7 +79,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
|
|||
* @param in the actual input stream
|
||||
*/
|
||||
public ZipInputStream(InputStream in) {
|
||||
this(in, StandardCharsets.UTF_8);
|
||||
this(in, UTF_8.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,11 +28,11 @@ package java.util.zip;
|
|||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Vector;
|
||||
import java.util.HashSet;
|
||||
import static java.util.zip.ZipConstants64.*;
|
||||
import static java.util.zip.ZipUtils.*;
|
||||
import sun.nio.cs.UTF_8;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
/**
|
||||
|
@ -116,7 +116,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
|
|||
* @param out the actual output stream
|
||||
*/
|
||||
public ZipOutputStream(OutputStream out) {
|
||||
this(out, StandardCharsets.UTF_8);
|
||||
this(out, UTF_8.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue