Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
22
Help us understand the problem. What is going on with this article?
@gfx

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

More than 5 years have passed since last update.

こんなスクリプトを書いた。 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
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
gfx
#Android #Java #Kotlin #Ruby #RubyOnRails #Elasticsearch

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
22
Help us understand the problem. What is going on with this article?