summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Thierer <tobiast@google.com>2018-07-18 15:17:34 +0100
committerTobias Thierer <tobiast@google.com>2018-07-18 15:50:58 +0100
commite721c0d4023d17384203126ee367d2d16fc074ad (patch)
tree5175c95a92f44bd542b051e422a92f3ccb5c4758
parentb06b96bf884f3d0f159a535dde25440bb452a6db (diff)
Upstream comparison: Basic support for ByteBufferAs<X>Buffer.
Unlike most ojluni .java files derived from OpenJDK, the six files ByteBufferAs{Char,Double,Float,Int,Long,Short}Buffer.java do not correspond 1:1 to an upstream file; upstream instead has 24 .java files generated from a single .template file. This CL tweaks the upstream tooling to consider those six files to be derived from ByteBufferAs<X>BufferB.java (upstream's file specialized on read-write big-endian). Because of the nonexact correspondence, this is only of limited use for verification purposes; further work could potentially improve this ( http://b/111583940#comment4 ). The benefit of this CL is the upstream comparison tools will have at least *some* upstream file to compare against, rather than not being able to find any corresponding upstream file at all. Bug: 111583940 Test: Ran libcore-compare-upstream and libcore-copy-upstream-files to update snapshots and the verification tracking spreadsheet: make libcore-copy-upstream-files && rm -rf ~/ojluni-upstreams && \ java -jar out/host/linux-x86/framework/libcore-copy-upstream-files.jar \ ~/ojluni-upstreams make libcore-compare-upstreams && java -jar \ out/host/linux-x86/framework/libcore-compare-upstreams.jar \ > ~/upstreams.tsv Change-Id: Iac1f4f0fc593c2d432a2bf4ab5669eed6587c414
-rw-r--r--tools/upstream/src/main/java/libcore/Repository.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/tools/upstream/src/main/java/libcore/Repository.java b/tools/upstream/src/main/java/libcore/Repository.java
index 0591fe1859..89f64f0a7e 100644
--- a/tools/upstream/src/main/java/libcore/Repository.java
+++ b/tools/upstream/src/main/java/libcore/Repository.java
@@ -27,7 +27,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -40,9 +39,37 @@ abstract class Repository {
* Maps from a file's (current) relPath to the corresponding OpenJDK relPath from
* which it has been, and still remains, renamed.
*/
- static final Map<Path, Path> OPENJDK_REL_PATH = Collections.singletonMap(
+ static final Map<Path, Path> OPENJDK_REL_PATH = historicRenames();
+
+ static Map<Path, Path> historicRenames() {
+ Map<Path, Path> result = new HashMap<>();
// renamed in libcore commit 583eb0e4738456f0547014a4857a14456be267ee
- Paths.get("native/linux_close.cpp"), Paths.get("native/linux_close.c"));
+ result.put(Paths.get("native/linux_close.cpp"), Paths.get("native/linux_close.c"));
+ // Map ByteBufferAs*Buffer.java to an upstream file, even though there is
+ // not a 1:1 correspondence. This isn't perfect, but allows some rough
+ // comparison. See http://b/111583940
+ //
+ // More detail:
+ // The RI has four different generated files ...Buffer{B,L,RB,RL}.java
+ // for each of these six files specializing on big endian, little endian,
+ // read-only big endian, and read-only little endian, respectively. Those
+ // 6 x 4 files are generated from a single template:
+ // java/nio/ByteBufferAs-X-Buffer.java.template
+ //
+ // On Android, the four variants {B,L,RB,RL} for each of the six types
+ // are folded into a single class with behavior configured via additional
+ // constructor arguments.
+ //
+ // For now, we map to upstream's "B" variant; "B" is more similar to
+ // Android's files than "RB" or "RL"; the choice of "B" vs. "L" is arbitrary.
+ for (String s : Arrays.asList("Char", "Double", "Float", "Int", "Long", "Short")) {
+ Path ojluniPath = Paths.get("java/nio/ByteBufferAs" + s + "Buffer.java");
+ Path upstreamPath =
+ Paths.get("java/nio/ByteBufferAs" + s + "BufferB.java");
+ result.put(ojluniPath, upstreamPath);
+ }
+ return Collections.unmodifiableMap(result);
+ }
protected final Path rootPath;
protected final String name;