8264485: build.tools.depend.Depend.toString(byte[]) creates malformed hex strings

Reviewed-by: jlahoda
This commit is contained in:
Adam Sotona 2021-11-30 12:56:48 +00:00
parent fecf906f0a
commit 69f56a0ea0

View File

@ -37,6 +37,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.HexFormat;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -156,13 +157,7 @@ public class Depend implements Plugin {
}
private String toString(byte[] digest) {
StringBuilder result = new StringBuilder();
for (byte b : digest) {
result.append(String.format("%X", b));
}
return result.toString();
return HexFormat.of().withUpperCase().formatHex(digest);
}
private static final class APIVisitor implements ElementVisitor<Void, Void>,