22
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenJDKとAndroidの標準ライブラリクラスの差分をみる

Last updated at Posted at 2016-03-10

こんなスクリプトを書いた。 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};
22
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?