Skip to content

Commit b7486d0

Browse files
committed
Unify StandardCharsets.UTF_8 imports
1 parent 2b6f856 commit b7486d0

File tree

16 files changed

+43
-60
lines changed

16 files changed

+43
-60
lines changed

dev/core/src/com/google/gwt/core/ext/linker/AbstractLinker.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
*/
1616
package com.google.gwt.core.ext.linker;
1717

18-
import static java.nio.charset.StandardCharsets.UTF_8;
19-
2018
import com.google.gwt.core.ext.Linker;
2119
import com.google.gwt.core.ext.TreeLogger;
2220
import com.google.gwt.core.ext.UnableToCompleteException;
2321
import com.google.gwt.thirdparty.guava.common.hash.Hashing;
2422

2523
import java.io.IOException;
2624
import java.io.InputStream;
25+
import java.nio.charset.StandardCharsets;
2726
import java.util.Locale;
2827

2928
/**
@@ -109,7 +108,7 @@ protected final SyntheticArtifact emitInputStream(TreeLogger logger,
109108
*/
110109
protected final SyntheticArtifact emitString(TreeLogger logger, String what,
111110
String partialPath) throws UnableToCompleteException {
112-
return emitBytes(logger, what.getBytes(UTF_8), partialPath);
111+
return emitBytes(logger, what.getBytes(StandardCharsets.UTF_8), partialPath);
113112
}
114113

115114
/**
@@ -123,7 +122,7 @@ protected final SyntheticArtifact emitString(TreeLogger logger, String what,
123122
*/
124123
protected final SyntheticArtifact emitString(TreeLogger logger, String what,
125124
String partialPath, long lastModified) throws UnableToCompleteException {
126-
return emitBytes(logger, what.getBytes(UTF_8), partialPath, lastModified);
125+
return emitBytes(logger, what.getBytes(StandardCharsets.UTF_8), partialPath, lastModified);
127126
}
128127

129128
/**

dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package com.google.gwt.core.ext.linker.impl;
1717

18-
import static java.nio.charset.StandardCharsets.UTF_8;
19-
2018
import com.google.gwt.core.ext.LinkerContext;
2119
import com.google.gwt.core.ext.TreeLogger;
2220
import com.google.gwt.core.ext.TreeLogger.Type;
@@ -38,6 +36,7 @@
3836
import java.io.InputStream;
3937
import java.net.URL;
4038
import java.net.URLConnection;
39+
import java.nio.charset.StandardCharsets;
4140
import java.util.ArrayList;
4241
import java.util.Collection;
4342
import java.util.List;
@@ -260,7 +259,7 @@ protected Collection<Artifact<?>> doEmitCompilation(TreeLogger logger,
260259
for (int i = 1; i < js.length; i++) {
261260
String s = generateDeferredFragment(logger, context, i, js[i], artifacts,
262261
result);
263-
byte[] bytes = s.getBytes(UTF_8);
262+
byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
264263
toReturn.add(emitBytes(logger, bytes, FRAGMENT_SUBDIR + File.separator
265264
+ result.getStrongName() + File.separator + i + FRAGMENT_EXTENSION));
266265
}
@@ -386,7 +385,7 @@ protected byte[] generatePrimaryFragment(TreeLogger logger,
386385
charsPerChunk(context, logger), getScriptChunkSeparator(logger, context), context);
387386
String primaryFragmentString =
388387
generatePrimaryFragmentString(logger, context, result, temp, js.length, artifacts);
389-
return primaryFragmentString.getBytes(UTF_8);
388+
return primaryFragmentString.getBytes(StandardCharsets.UTF_8);
390389
}
391390

392391
protected String generatePrimaryFragmentString(TreeLogger logger,

dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package com.google.gwt.core.ext.soyc.impl;
1717

18-
import static java.nio.charset.StandardCharsets.UTF_8;
19-
2018
import com.google.gwt.core.ext.TreeLogger;
2119
import com.google.gwt.dev.jjs.ast.JProgram;
2220
import com.google.gwt.dev.jjs.ast.JRunAsync;
@@ -26,6 +24,7 @@
2624
import java.io.OutputStream;
2725
import java.io.OutputStreamWriter;
2826
import java.io.PrintWriter;
27+
import java.nio.charset.StandardCharsets;
2928
import java.util.List;
3029
import java.util.zip.GZIPOutputStream;
3130

@@ -42,7 +41,8 @@ public static void recordSplitPoints(JProgram jprogram, OutputStream out, TreeLo
4241
logger.branch(TreeLogger.TRACE, "Creating split point map file for the compile report");
4342

4443
try {
45-
try (OutputStreamWriter writer = new OutputStreamWriter(new GZIPOutputStream(out), UTF_8);
44+
try (OutputStreamWriter writer = new OutputStreamWriter(
45+
new GZIPOutputStream(out), StandardCharsets.UTF_8);
4646
PrintWriter pw = new PrintWriter(writer)) {
4747
HtmlTextOutput htmlOut = new HtmlTextOutput(pw, false);
4848
String curLine = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

dev/core/src/com/google/gwt/dev/javac/testing/impl/MockResource.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
*/
1616
package com.google.gwt.dev.javac.testing.impl;
1717

18-
import static java.nio.charset.StandardCharsets.UTF_8;
19-
2018
import com.google.gwt.dev.resource.Resource;
2119

2220
import java.io.ByteArrayInputStream;
2321
import java.io.InputStream;
22+
import java.nio.charset.StandardCharsets;
2423
import java.util.concurrent.atomic.AtomicLong;
2524

2625
/**
@@ -73,7 +72,7 @@ public String getString() {
7372
@Override
7473
public InputStream openContents() {
7574
String s = getContent().toString();
76-
return new ByteArrayInputStream(s.getBytes(UTF_8));
75+
return new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
7776
}
7877

7978
@Override

dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*/
1414
package com.google.gwt.dev.jjs;
1515

16-
import static java.nio.charset.StandardCharsets.UTF_8;
17-
1816
import com.google.gwt.core.ext.TreeLogger;
1917
import com.google.gwt.core.ext.UnableToCompleteException;
2018
import com.google.gwt.core.ext.linker.Artifact;
@@ -197,6 +195,7 @@
197195
import java.io.ObjectOutputStream;
198196
import java.io.OutputStream;
199197
import java.lang.management.ManagementFactory;
198+
import java.nio.charset.StandardCharsets;
200199
import java.util.ArrayList;
201200
import java.util.Collection;
202201
import java.util.Collections;
@@ -1534,7 +1533,7 @@ public PermutationResultImpl(String[] jsFragments, Permutation permutation,
15341533
Hasher h = Hashing.murmur3_128().newHasher();
15351534
h.putInt(jsFragments.length);
15361535
for (int i = 0; i < jsFragments.length; ++i) {
1537-
bytes[i] = jsFragments[i].getBytes(UTF_8);
1536+
bytes[i] = jsFragments[i].getBytes(StandardCharsets.UTF_8);
15381537
h.putInt(bytes[i].length);
15391538
h.putBytes(bytes[i]);
15401539
}

dev/core/src/com/google/gwt/dev/util/DiskCache.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package com.google.gwt.dev.util;
1717

18-
import static java.nio.charset.StandardCharsets.UTF_8;
19-
2018
import java.io.ByteArrayInputStream;
2119
import java.io.ByteArrayOutputStream;
2220
import java.io.File;
@@ -26,6 +24,7 @@
2624
import java.io.ObjectOutputStream;
2725
import java.io.OutputStream;
2826
import java.io.RandomAccessFile;
27+
import java.nio.charset.StandardCharsets;
2928

3029
/**
3130
* A nifty class that lets you squirrel away data on the file system. Write
@@ -125,7 +124,7 @@ public <T> T readObject(long token, Class<T> type) {
125124
* @return the String that was written
126125
*/
127126
public String readString(long token) {
128-
return new String(readByteArray(token), UTF_8);
127+
return new String(readByteArray(token), StandardCharsets.UTF_8);
129128
}
130129

131130
/**
@@ -246,7 +245,7 @@ public long writeObject(Object object) {
246245
* @return a token to retrieve the data later
247246
*/
248247
public long writeString(String str) {
249-
return writeByteArray(str.getBytes(UTF_8));
248+
return writeByteArray(str.getBytes(StandardCharsets.UTF_8));
250249
}
251250

252251
/**

dev/core/src/com/google/gwt/dev/util/Util.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package com.google.gwt.dev.util;
1717

18-
import static java.nio.charset.StandardCharsets.UTF_8;
19-
2018
import com.google.gwt.core.ext.TreeLogger;
2119
import com.google.gwt.core.ext.UnableToCompleteException;
2220
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
@@ -808,7 +806,8 @@ public static boolean writeStringAsFile(File file, String string) {
808806
// No need to check mkdirs result because an IOException will occur anyway
809807
file.getParentFile().mkdirs();
810808
try (FileOutputStream stream = new FileOutputStream(file);
811-
BufferedWriter buffered = new BufferedWriter(new OutputStreamWriter(stream, UTF_8))) {
809+
BufferedWriter buffered = new BufferedWriter(
810+
new OutputStreamWriter(stream, StandardCharsets.UTF_8))) {
812811
buffered.write(string);
813812
} catch (IOException e) {
814813
return false;
@@ -824,7 +823,8 @@ public static void writeStringAsFile(TreeLogger logger, File file,
824823
// No need to check mkdirs result because an IOException will occur anyway
825824
file.getParentFile().mkdirs();
826825
try (FileOutputStream stream = new FileOutputStream(file);
827-
BufferedWriter buffered = new BufferedWriter(new OutputStreamWriter(stream, UTF_8))) {
826+
BufferedWriter buffered = new BufferedWriter(
827+
new OutputStreamWriter(stream, StandardCharsets.UTF_8))) {
828828
buffered.write(string);
829829
} catch (IOException e) {
830830
logger.log(TreeLogger.ERROR, "Unable to write file: " + file.getAbsolutePath(), e);

dev/core/test/com/google/gwt/dev/cfg/MockModuleDef.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
*/
1616
package com.google.gwt.dev.cfg;
1717

18-
import static java.nio.charset.StandardCharsets.UTF_8;
19-
2018
import com.google.gwt.core.ext.TreeLogger;
2119
import com.google.gwt.dev.javac.testing.impl.MockResourceOracle;
2220
import com.google.gwt.dev.resource.Resource;
2321

2422
import java.io.ByteArrayInputStream;
2523
import java.io.InputStream;
24+
import java.nio.charset.StandardCharsets;
2625

2726
/**
2827
* Mock for {@link ModuleDef}.
@@ -48,7 +47,7 @@ public String getPath() {
4847

4948
@Override
5049
public InputStream openContents() {
51-
return new ByteArrayInputStream("w00t!".getBytes(UTF_8));
50+
return new ByteArrayInputStream("w00t!".getBytes(StandardCharsets.UTF_8));
5251
}
5352

5453
@Override

dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package com.google.gwt.dev.javac;
1717

18-
import static java.nio.charset.StandardCharsets.UTF_8;
19-
2018
import com.google.gwt.dev.jjs.SourceOrigin;
2119
import com.google.gwt.dev.jjs.ast.JClassType;
2220
import com.google.gwt.dev.jjs.ast.JDeclaredType;
@@ -25,6 +23,7 @@
2523

2624
import org.eclipse.jdt.core.compiler.CategorizedProblem;
2725

26+
import java.nio.charset.StandardCharsets;
2827
import java.util.Collection;
2928
import java.util.List;
3029
import java.util.concurrent.atomic.AtomicInteger;
@@ -58,7 +57,7 @@ public MockCompilationUnit(String typeName, String source, String resourceLocati
5857
@Override
5958
public CachedCompilationUnit asCachedCompilationUnit() {
6059
DiskCache diskCache = DiskCache.INSTANCE;
61-
long astToken = diskCache.writeByteArray("Dummy AST data".getBytes(UTF_8));
60+
long astToken = diskCache.writeByteArray("Dummy AST data".getBytes(StandardCharsets.UTF_8));
6261
return new CachedCompilationUnit(this, astToken);
6362
}
6463

user/src/com/google/gwt/resources/rebind/context/MhtmlClientBundleGenerator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package com.google.gwt.resources.rebind.context;
1717

18-
import static java.nio.charset.StandardCharsets.UTF_8;
19-
2018
import com.google.gwt.core.ext.GeneratorContext;
2119
import com.google.gwt.core.ext.TreeLogger;
2220
import com.google.gwt.core.ext.UnableToCompleteException;
@@ -27,6 +25,7 @@
2725
import com.google.gwt.thirdparty.guava.common.hash.HashCode;
2826
import com.google.gwt.thirdparty.guava.common.hash.Hashing;
2927

28+
import java.nio.charset.StandardCharsets;
3029
import java.util.Locale;
3130

3231
/**
@@ -79,7 +78,8 @@ protected void doAddFieldsAndRequirements(TreeLogger logger,
7978
protected void doCreateBundleForPermutation(TreeLogger logger,
8079
GeneratorContext generatorContext, FieldsImpl fields,
8180
String generatedSimpleSourceName) throws UnableToCompleteException {
82-
HashCode hash = Hashing.murmur3_128().hashString(generatedSimpleSourceName, UTF_8);
81+
HashCode hash = Hashing.murmur3_128().hashString(generatedSimpleSourceName,
82+
StandardCharsets.UTF_8);
8383
String partialPath = hash.toString().toUpperCase(Locale.ROOT) + BUNDLE_EXTENSION;
8484
resourceContext.setPartialPath(partialPath);
8585
fields.setInitializer(bundleBaseIdent,

0 commit comments

Comments
 (0)