こんなスクリプトを書いた。 chmod -x
で実行パーミッションを与えて以下のコマンドで実行できるはず。
./openjdk-android-diff java.lang.String
すると openjdk7.java.lang.String.java.diff
のようなファイルができあがります。
#!/usr/bin/env perl
# usage: openjdk-android-diff java.lang.String
use strict;
use warnings;
use HTTP::Tiny;
use File::Temp;
use MIME::Base64;
my $name = shift(@ARGV) or die "$0 fully-qualified-class-name\n";
my $path = ($name =~ s{\.}{/}gr) . ".java";
my $branch = "master"; # may be "android-n-preview-1";
my $openjdk7_url = "http://hg.openjdk.java.net/jdk7/jdk7/jdk/raw-file/default/src/share/classes/$path";
my $openjdk8_url = ($openjdk7_url =~ s/jdk7/jdk8/gr);
my $android_url = "https://android.googlesource.com/platform/libcore/+/$branch/ojluni/src/main/java/$path?format=TEXT";
my $openjdk7 = File::Temp->new(SUFFIX => '.java');
my $openjdk8 = File::Temp->new(SUFFIX => '.java');
my $android= File::Temp->new(SUFFIX => '.java');
my $http = HTTP::Tiny->new;
my $ok = 0;
for my $url($android_url, $android_url =~ s/ojluni/luni/r) {
my $r = `curl -L -f "$url"`;
if ($? == 0) {
$android->print(decode_base64($r));
$android->flush();
$ok = 1;
last;
}
}
if (!$ok) {
die "No $android_url found.\n";
}
system qq{curl -L "$openjdk7_url" > "$openjdk7"};
system qq{curl -L "$openjdk8_url" > "$openjdk8"};
system qq{git diff -b "$openjdk7" "$android" > openjdk7.$name.java.diff};
system qq{git diff -b "$openjdk8" "$android" > openjdk8.$name.java.diff};