Upstream tooling: Fix java{,x}.sql missing from 'expected' snapshot.
The java{,x}.sql classes were missing from the snapshot of
files in the 'expected' upstream revision because CopyUpstreamFiles
was checking for
upstream.equals(expectedUpstream)
before copying a file to the "expected/" subfolder, but
Repository.equals() was based on object identity and the
StandardRepositories constructor created two instances of the
OpenJDK 7u40 repository, which were then not considered equal.
This bug was probably introduced by http://r.android.com/640021
(commit 2af621453187a8ce05724575a2749aca890a3976).
Test: After this CL, the directory ~/ojluni-upstreams/java/sql
gets created by the following command:
make libcore-copy-upstream-files && java -jar \
out/host/linux-x86/framework/libcore-copy-upstream-files.jar \
~/ojluni-upstreams
Bug: 35910877
Change-Id: Icacedb46e6b922206aa5603ae668eb8bddf9ade2
diff --git a/tools/upstream/src/main/java/libcore/Repository.java b/tools/upstream/src/main/java/libcore/Repository.java
index 8b0e2f7..0591fe1 100644
--- a/tools/upstream/src/main/java/libcore/Repository.java
+++ b/tools/upstream/src/main/java/libcore/Repository.java
@@ -84,6 +84,16 @@
return rootPath;
}
+ @Override
+ public int hashCode() {
+ return rootPath.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return (obj instanceof Repository) && rootPath.equals(((Repository) obj).rootPath);
+ }
+
/**
* @return A human readable name to identify this repository, suitable for use as a
* directory name.