Skip to content

Commit a743415

Browse files
committed
Merge branch 'main' of https://github.com/gwtproject/gwt into java17-emul
2 parents c5b445c + 3e515ee commit a743415

File tree

71 files changed

+651
-645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+651
-645
lines changed

.github/workflows/full-check.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ on:
1515
- 'main'
1616
- 'release/*'
1717
- '*-test'
18+
workflow_dispatch:
19+
# Allow running manually
1820
jobs:
1921
build:
2022
runs-on: ubuntu-latest
@@ -57,7 +59,7 @@ jobs:
5759
-Dtest.emma.htmlunit.disable=true
5860
5961
- name: Report test results
60-
uses: mikepenz/action-junit-report@v5.5.0
62+
uses: mikepenz/action-junit-report@v5.6.0
6163
if: always()
6264
with:
6365
report_paths: 'gwt/build/out/**/test/**/reports/TEST-*.xml'
@@ -101,7 +103,7 @@ jobs:
101103
set -eux
102104
# Set the version to deploy (it was also set in the build step above)
103105
export GWT_VERSION=HEAD-SNAPSHOT
104-
export GWT_MAVEN_REPO_URL=https://oss.sonatype.org/content/repositories/snapshots/
106+
export GWT_MAVEN_REPO_URL=https://central.sonatype.com/repository/maven-snapshots/
105107
export GWT_MAVEN_REPO_ID=sonatype-snapshots
106108
cd gwt
107109
# With no user input, run the push-gwtproject.sh script to deploy org.gwtproject artifacts

.github/workflows/quick-check.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ jobs:
77
build:
88
runs-on: ubuntu-latest
99
strategy:
10+
fail-fast: false
1011
matrix:
1112
java-version: ['11', '17', '21', '22']
1213
steps:
@@ -55,7 +56,7 @@ jobs:
5556
cd gwt
5657
for f in build/out/**/checkstyle*.xml ; do
5758
echo $f
58-
reviewdog -f=checkstyle -filter-mode=diff_context -reporter=github-pr-review -level=info < $f
59+
reviewdog -f=checkstyle -filter-mode=diff_context -reporter=github-pr-annotations -level=info < $f
5960
done
6061
- name: Upload checkstyle xml for manual review
6162
uses: actions/upload-artifact@v4

build.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
</macrodef>
3232

3333
<property name="gwt.apicheck.config"
34-
location="tools/api-checker/config/gwt211_212userapi.conf"/>
34+
location="tools/api-checker/config/gwt212_213userapi.conf"/>
3535
<property name="gwt.apicheck.referencelibs"
36-
value="${gwt.tools}/api-checker-reference/2.11.0/gwt-dev-modified.jar:${gwt.tools}/api-checker-reference/2.11.0/gwt-user-modified.jar"/>
36+
value="${gwt.tools}/api-checker-reference/2.12.0/gwt-dev-modified.jar:${gwt.tools}/api-checker-reference/2.12.0/gwt-user-modified.jar"/>
3737

3838
<target name="buildonly"
3939
description="[action] Minimal one-platform devel build, without distro packaging">

dev/codeserver/java/com/google/gwt/dev/codeserver/Recompiler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ private static class InputSummary {
639639
private final ImmutableMap<String, String> bindingProperties;
640640
private final long moduleLastModified;
641641
private final long resourcesLastModified;
642-
private final long filenameHash;
642+
private final String filenameHash;
643643

644644
InputSummary(Map<String, String> bindingProperties, ModuleDef module) {
645645
this.bindingProperties = ImmutableMap.copyOf(bindingProperties);
@@ -655,7 +655,7 @@ public boolean equals(Object obj) {
655655
return bindingProperties.equals(other.bindingProperties) &&
656656
moduleLastModified == other.moduleLastModified &&
657657
resourcesLastModified == other.resourcesLastModified &&
658-
filenameHash == other.filenameHash;
658+
filenameHash.equals(other.filenameHash);
659659
}
660660
return false;
661661
}

dev/codeserver/javatests/com/google/gwt/dev/codeserver/SourceHandlerTest.java

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

18-
import com.google.gwt.dev.util.Util;
19-
18+
import com.google.gwt.thirdparty.guava.common.hash.Hashing;
2019
import junit.framework.TestCase;
2120

21+
import java.nio.charset.StandardCharsets;
22+
import java.util.Locale;
23+
2224
/**
2325
* Tests for {@link SourceHandler}
2426
*/
2527
public class SourceHandlerTest extends TestCase {
2628

27-
private static final String VALID_STRONG_NAME = Util.computeStrongName("foo-bar".getBytes());
29+
private static final String VALID_STRONG_NAME = Hashing.murmur3_128()
30+
.hashString("foo-bar", StandardCharsets.UTF_8).toString().toUpperCase(Locale.ROOT);
2831

2932
public void testIsSourceMapRequest() {
3033
checkSourceMapRequest("/sourcemaps/myModule/");

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import com.google.gwt.core.ext.TreeLogger;
2020
import com.google.gwt.core.ext.UnableToCompleteException;
2121
import com.google.gwt.dev.util.Util;
22+
import com.google.gwt.thirdparty.guava.common.hash.Hashing;
2223

2324
import java.io.ByteArrayOutputStream;
2425
import java.io.InputStream;
26+
import java.util.Locale;
2527

2628
/**
2729
* Provides basic functions common to all Linker implementations.
@@ -132,7 +134,8 @@ protected final SyntheticArtifact emitString(TreeLogger logger, String what,
132134
protected final SyntheticArtifact emitWithStrongName(TreeLogger logger,
133135
byte[] what, String prefix, String suffix)
134136
throws UnableToCompleteException {
135-
String strongName = prefix + Util.computeStrongName(what) + suffix;
137+
String hash = Hashing.murmur3_128().hashBytes(what).toString().toUpperCase(Locale.ROOT);
138+
String strongName = prefix + hash + suffix;
136139
return emitBytes(logger, what, strongName);
137140
}
138141

@@ -152,7 +155,8 @@ protected final SyntheticArtifact emitWithStrongName(TreeLogger logger,
152155
protected final SyntheticArtifact emitWithStrongName(TreeLogger logger,
153156
byte[] what, String prefix, String suffix, long lastModified)
154157
throws UnableToCompleteException {
155-
String strongName = prefix + Util.computeStrongName(what) + suffix;
158+
String hash = Hashing.murmur3_128().hashBytes(what).toString().toUpperCase(Locale.ROOT);
159+
String strongName = prefix + hash + suffix;
156160
return emitBytes(logger, what, strongName, lastModified);
157161
}
158162
}

dev/core/src/com/google/gwt/dev/MinimalRebuildCacheManager.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
import com.google.gwt.thirdparty.guava.common.annotations.VisibleForTesting;
2020
import com.google.gwt.thirdparty.guava.common.cache.Cache;
2121
import com.google.gwt.thirdparty.guava.common.cache.CacheBuilder;
22-
import com.google.gwt.thirdparty.guava.common.io.Closeables;
22+
import com.google.gwt.thirdparty.guava.common.hash.Hashing;
2323
import com.google.gwt.thirdparty.guava.common.util.concurrent.Futures;
2424
import com.google.gwt.thirdparty.guava.common.util.concurrent.MoreExecutors;
25-
import com.google.gwt.util.tools.shared.Md5Utils;
26-
import com.google.gwt.util.tools.shared.StringUtils;
25+
import com.google.gwt.thirdparty.guava.common.io.Closeables;
2726

2827
import java.io.BufferedInputStream;
2928
import java.io.BufferedOutputStream;
@@ -33,6 +32,7 @@
3332
import java.io.IOException;
3433
import java.io.ObjectInputStream;
3534
import java.io.ObjectOutputStream;
35+
import java.nio.charset.StandardCharsets;
3636
import java.util.LinkedHashMap;
3737
import java.util.Map;
3838
import java.util.concurrent.Callable;
@@ -270,22 +270,26 @@ private String computeMinimalRebuildCacheName(String moduleName,
270270
String currentWorkingDirectory = System.getProperty("user.dir");
271271
String compilerVersionHash = CompilerVersion.getHash();
272272
String permutationDescriptionString = permutationDescription.toString();
273-
String optionsDescriptionString = " Options [";
273+
StringBuilder optionsDescriptionString = new StringBuilder(" Options [");
274274
String separator = "";
275-
for (Map.Entry entry : options.entrySet()) {
276-
optionsDescriptionString +=
277-
String.format("%s%s = %s", separator, entry.getKey(), entry.getValue());
275+
for (Map.Entry<String, String> entry : options.entrySet()) {
276+
optionsDescriptionString.append(String.format("%s%s = %s", separator, entry.getKey(), entry.getValue()));
278277
separator = ",";
279278
}
280-
optionsDescriptionString += "]";
279+
optionsDescriptionString.append("]");
281280

282-
String consistentHash = StringUtils.toHexString(Md5Utils.getMd5Digest((
283-
compilerVersionHash
284-
+ moduleName
285-
+ currentWorkingDirectory
286-
+ permutationDescriptionString
287-
+ optionsDescriptionString)
288-
.getBytes()));
281+
String consistentHash = Hashing.murmur3_128().newHasher()
282+
// Compiler hash is constant length, no need to write length
283+
.putString(compilerVersionHash, StandardCharsets.UTF_8)
284+
.putInt(moduleName.length())
285+
.putString(moduleName, StandardCharsets.UTF_8)
286+
.putInt(currentWorkingDirectory.length())
287+
.putString(currentWorkingDirectory, StandardCharsets.UTF_8)
288+
// permutationDescriptionString has start/end delimiter
289+
.putString(permutationDescriptionString, StandardCharsets.UTF_8)
290+
// optionsDescriptionString has start/end delimiter
291+
.putString(optionsDescriptionString, StandardCharsets.UTF_8)
292+
.hash().toString();
289293
return REBUILD_CACHE_PREFIX + "-" + consistentHash;
290294
}
291295

dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@
3737
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
3838
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
3939
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
40-
import com.google.gwt.thirdparty.guava.common.base.Charsets;
4140
import com.google.gwt.thirdparty.guava.common.base.Predicates;
4241
import com.google.gwt.thirdparty.guava.common.collect.ImmutableList;
4342
import com.google.gwt.thirdparty.guava.common.collect.Iterators;
4443
import com.google.gwt.thirdparty.guava.common.collect.Lists;
4544
import com.google.gwt.thirdparty.guava.common.collect.Maps;
4645
import com.google.gwt.thirdparty.guava.common.collect.Sets;
46+
import com.google.gwt.thirdparty.guava.common.hash.Hasher;
47+
import com.google.gwt.thirdparty.guava.common.hash.Hashing;
4748

4849
import java.io.File;
49-
import java.security.MessageDigest;
50-
import java.security.NoSuchAlgorithmException;
50+
import java.nio.charset.StandardCharsets;
5151
import java.util.ArrayList;
5252
import java.util.Arrays;
5353
import java.util.Collections;
@@ -455,31 +455,24 @@ public String getGwtXmlFilePath(String moduleName) {
455455
* For example, consider a glob that matches fewer files than before because a file was
456456
* deleted.
457457
*/
458-
public int getInputFilenameHash() {
459-
List<String> filenames = new ArrayList<String>();
460-
461-
filenames.addAll(gwtXmlPathByModuleName.values());
458+
public String getInputFilenameHash() {
459+
List<String> filenames = new ArrayList<>(gwtXmlPathByModuleName.values());
462460

463461
for (Resource resource : getResourcesNewerThan(Integer.MIN_VALUE)) {
464462
filenames.add(resource.getLocation());
465463
}
466464

467-
// Take the first four bytes of the SHA-1 hash.
465+
// Take the first eight bytes of the murmur3 hash.
468466

469467
Collections.sort(filenames);
470468

471-
MessageDigest digest;
472-
try {
473-
digest = MessageDigest.getInstance("SHA-1");
474-
} catch (NoSuchAlgorithmException e) {
475-
throw new RuntimeException("SHA-1 unavailable", e);
476-
}
469+
Hasher hasher = Hashing.murmur3_128().newHasher();
470+
hasher.putInt(filenames.size());
477471
for (String filename : filenames) {
478-
digest.update(filename.getBytes(Charsets.UTF_8));
472+
hasher.putInt(filename.length());
473+
hasher.putString(filename, StandardCharsets.UTF_8);
479474
}
480-
byte[] bytes = digest.digest();
481-
482-
return (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3];
475+
return hasher.hash().toString();
483476
}
484477

485478
public Class<? extends Linker> getLinker(String name) {

dev/core/src/com/google/gwt/dev/javac/BytecodeSignatureMaker.java

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

18-
import com.google.gwt.dev.util.Util;
18+
import com.google.gwt.thirdparty.guava.common.hash.Hashing;
1919

2020
import org.objectweb.asm.AnnotationVisitor;
2121
import org.objectweb.asm.Attribute;
@@ -24,6 +24,7 @@
2424
import org.objectweb.asm.FieldVisitor;
2525
import org.objectweb.asm.Opcodes;
2626

27+
import java.nio.charset.StandardCharsets;
2728
import java.util.Arrays;
2829
import java.util.HashMap;
2930
import java.util.Map;
@@ -60,7 +61,7 @@ public CompileDependencyVisitor() {
6061
}
6162

6263
public String getSignature() {
63-
return Util.computeStrongName(Util.getBytes(getRawString()));
64+
return Hashing.murmur3_128().hashString(getRawString(), StandardCharsets.UTF_8).toString();
6465
}
6566

6667
@Override
@@ -203,7 +204,7 @@ private String getRawString() {
203204
* methods in a class.
204205
*
205206
* @param byteCode byte code for class to analyze.
206-
* @return a hex string representing an MD5 digest.
207+
* @return a hex string representing a murmur3 hash.
207208
*/
208209
public static String getCompileDependencySignature(byte[] byteCode) {
209210
CompileDependencyVisitor v = visitCompileDependenciesInBytecode(byteCode);

dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.google.gwt.dev.js.ast.JsRootScope;
2828
import com.google.gwt.dev.resource.Resource;
2929
import com.google.gwt.dev.util.StringInterner;
30-
import com.google.gwt.dev.util.Util;
3130
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
3231
import com.google.gwt.dev.util.log.speedtracer.DevModeEventType;
3332
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
@@ -39,6 +38,10 @@
3938
import com.google.gwt.thirdparty.guava.common.collect.Lists;
4039
import com.google.gwt.thirdparty.guava.common.collect.Maps;
4140
import com.google.gwt.thirdparty.guava.common.collect.Sets;
41+
import com.google.gwt.thirdparty.guava.common.hash.Funnels;
42+
import com.google.gwt.thirdparty.guava.common.hash.Hasher;
43+
import com.google.gwt.thirdparty.guava.common.hash.Hashing;
44+
import com.google.gwt.thirdparty.guava.common.io.ByteStreams;
4245

4346
import org.eclipse.jdt.core.compiler.CharOperation;
4447
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
@@ -48,13 +51,13 @@
4851
import org.eclipse.jdt.internal.compiler.lookup.Binding;
4952
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
5053

51-
import java.io.ByteArrayOutputStream;
5254
import java.io.IOException;
5355
import java.io.InputStream;
5456
import java.util.Collection;
5557
import java.util.Collections;
5658
import java.util.Iterator;
5759
import java.util.List;
60+
import java.util.Locale;
5861
import java.util.Map;
5962
import java.util.Map.Entry;
6063
import java.util.Set;
@@ -553,23 +556,21 @@ private boolean verifyContentId(TreeLogger logger, Resource resource, Compilatio
553556
}
554557

555558
private ContentId getResourceContentId(Resource resource) {
556-
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
557-
try {
558-
InputStream in = resource.openContents();
559-
/**
559+
try (InputStream in = resource.openContents()) {
560+
/*
560561
* In most cases openContents() will throw an exception, however in the case of a
561562
* ZipFileResource it might return null causing an NPE in Util.copyNoClose(), see issue 4359.
562563
*/
563564
if (in == null) {
564565
throw new RuntimeException("Unexpected error reading resource '" + resource + "'");
565566
}
566-
// TODO: deprecate com.google.gwt.dev.util.Util and use Guava.
567-
Util.copy(in, out);
567+
Hasher hasher = Hashing.murmur3_128().newHasher();
568+
ByteStreams.copy(in, Funnels.asOutputStream(hasher));
569+
String hash = hasher.hash().toString().toUpperCase(Locale.ROOT);
570+
return new ContentId(Shared.getTypeName(resource), hash);
568571
} catch (IOException e) {
569572
throw new RuntimeException("Unexpected error reading resource '" + resource + "'", e);
570573
}
571-
byte[] content = out.toByteArray();
572-
return new ContentId(Shared.getTypeName(resource), Util.computeStrongName(content));
573574
}
574575

575576
/**

0 commit comments

Comments
 (0)