© 2021 NTT DATA Corporation
Let's Start Contributing to OpenJDK from Today!
今日からOpenJDKへのコントリビュートを始めよう!
2021年11月27日 Oracle Groundbreakers APAC Virtual Tour 2021
株式会社NTTデータ
阪田 浩一
自己紹介
• Javaチャンピオン
• Oracle Groundbreakerアンバサダ
• OpenJDK Author
• 株式会社NTTデータ所属
© 2021 NTT DATA Corporation 2
Koichi Sakata
阪田 浩一
jyukutyo
今日の内容
• OpenJDKの開発プロセス
• OpenJDKへのコントリビュート手順
• OpenJDKへのパッチ投稿の追体験
© 2021 NTT DATA Corporation 3
今日伝えたいこと
© 2021 NTT DATA Corporation 4
OpenJDKへのコントリビュートは
難しくありません
一緒にやっていきましょう!!
5
© 2021 NTT DATA Corporation
【クイズ】
9月にリリースされた最新バージョン
Java 17(LTS)で解決したIssueは何件でしょうか?
※OpenJDKのJIRAでのカウント
A. 1000~2000
B. 2000~3000
C. 3000~4000
D. 4000よりも多い
6
© 2021 NTT DATA Corporation
9月にリリースされた最新バージョン
Java 17(LTS)で解決したIssueは何件でしょうか?
A. 1000~2000
B. 2000~3000
C. 3000~4000
D. 4000よりも多い
【答え】
B The arrival of Java 17! https://blogs.oracle.com/java/post/announcing-java17
(2,645)
Java 17における組織別Issue解決数
© 2021 NTT DATA Corporation 7
The arrival of Java 17! https://blogs.oracle.com/java/post/announcing-java17
© 2021 NTT DATA Corporation 8
前提知識としての
OpenJDK開発プロセス
Java 17における組織別Issue解決数
1. Oracle社
2. Red Hat社
3. 個人開発者総計 (Independent)
4. SAP社
5. Tencent社
6. Amazon社
7. NTTデータ
8. Arm社
9. Alibaba社
© 2021 NTT DATA Corporation 9
JavaとOpenJDKの関係
• OpenJDKはJavaのオープンソース実装
» 多くの企業や組織、個人がその開発に貢献
• さまざまなベンダや組織が出しているJava(JDK)は
多くがOpenJDKベース
© 2021 NTT DATA Corporation 10
OpenJDKをどのように開発しているのか
• 他のOSSと開発の流れはおおむね同じ
• 開発規模が大きいため管理単位がいくつかある
» プロジェクト
» JEP
» JBS
© 2021 NTT DATA Corporation 11
OpenJDKのプロジェクト
• OpenJDKにおける新機能開発プロジェクト
» Project Lambda(ラムダ式)
» Project Jigsaw(モジュール)
» Project Valhalla
» Project Amber
» Project Panama
» Project Metropolis
» Project Loom
など
© 2021 NTT DATA Corporation 12
開発中の
プロジェクト
Project Amber
• プログラムの生産性を向上させることを目的として
小さな機能をいくつも管理するプロジェクト
» 近年の言語構文の変化はこのAmberから
• レコード
• パターンマッチ系
• シールクラス
• テキストブロック
• switch式
• など
» プロジェクト内の細かな機能ごとに1つのJEP(後述)となる
© 2021 NTT DATA Corporation 13
JEP: JDK Enhancement Proposals
• Javaの機能変更提案
» 追加
» 拡張
» 非推奨化
» 削除
• 各提案に番号を振り管理
» 例: JEP 406
© 2021 NTT DATA Corporation 14
JEPの例
© 2021 NTT DATA Corporation 15
JEP 406: Pattern Matching for
switch (Preview)
https://openjdk.java.net/jeps/406
Java 17
© 2021 NTT DATA Corporation 16
JDK 17 https://openjdk.java.net/projects/jdk/17/
JDK 17に
含まれる
JEP
JEPにあるIssue
© 2021 NTT DATA Corporation 17
JBS: JDK Bug System
© 2021 NTT DATA Corporation 18
https://bugs.openjdk.java.net/browse/JDK-8213076
JBS: JDK Bug System
• カスタマイズしたJIRA
» Issue管理システム
• 管理対象はバグだけではない
» 新機能追加
» 機能拡張
» バックポート
• などOpenJDK開発に関するあらゆることを管理
• Issue単位で実装を進めていく
© 2021 NTT DATA Corporation 19
JBS
JEP
複雑な新機能
プロジェクト Project Amber
パターンマッチ
JEP 305,375,394
(for instanceof)
Issue
8181287
Issue
8181287
Issue
8250623
JEP 405
(Record & Array)
Issue
8260244
JEP 406
(for switch)
Issue
8213076
Draft JEPs
他機能
パターンマッチでの開発プロセス
© 2021 NTT DATA Corporation 20
• 単一機能など複雑でなければプロジェクトに属さずJEPのみ作成
• 小さな拡張やバグはJEPではなくJBSのIssueのみで管理
© 2021 NTT DATA Corporation 21
OpenJDK開発への
コントリビュート手順
OpenJDKに貢献するさまざまな方法
1. パッチを出す
2. コードをレビューする
3. アイデアを出す
4. 議論に参加する
5. イベントで登壇して話す
6. ブログに投稿する
など
© 2021 NTT DATA Corporation 22
OpenJDKに貢献するさまざまな方法
1. パッチを出す
2. コードをレビューする
3. アイデアを出す
4. 議論に参加する
5. イベントで登壇して話す
6. ブログに投稿する
など
© 2021 NTT DATA Corporation 23
今日話すこと
バグ修正を考える
• バグ修正でコントリビュートする手順
» 他のOSSにする場合とほとんど同じ一般的な手順
© 2021 NTT DATA Corporation 24
コントリビュートの手順
• バグ修正でコントリビュートする手順
» 他のOSSにする場合とほとんど同じ一般的な手順
1. バグを見つける
2. バグを修正する
3. パッチを出す
4. レビューを受ける
5. コメントに対応する
6. パッチがマージされる
© 2021 NTT DATA Corporation 25
コントリビュートの手順
• バグ修正でコントリビュートする手順
» 他のOSSにする場合とほとんど同じ一般的な手順
1. ➡バグを見つける
2. バグを修正する
3. パッチを出す
4. レビューを受ける
5. コメントに対応する
6. パッチがマージされる
© 2021 NTT DATA Corporation 26
そもそもバグを見つけられる?
• OpenJDK上アプリケーションはうまく動いている
» OpenJDK起因のバグに出会うことはそうない
• ではどうやって修正が必要なポイントを見つけられる?
© 2021 NTT DATA Corporation 27
私が実施した方法
• 修正が必要なポイントをどのように見つけるか
1. ツールの新しいバージョンを使ってビルドしてみる
© 2021 NTT DATA Corporation 28
ツールの新しいバージョンでビルドする
• OpenJDKにはJavaコードだけでなくC++コードもある
• OpenJDKは複数のプラットフォームで
それぞれ異なるツールを使ってビルドする
» GCC, Clang, Visual Studio
» Linux, macOS, Windows (+WSL)
• 新たなエラーや警告が発生する場合がある
» 見つけたら修正を試みよう!
© 2021 NTT DATA Corporation 29
OpenJDKをビルドする手順
1. GitHubからOpenJDKのリポジトリをクローンする
2. $ sh configure [--enable-debug]
3. $ make images
© 2021 NTT DATA Corporation 30
(Omitted)
OpenJDKビルドのデモ
© 2021 NTT DATA Corporation 31
私の体験談
• GCC 10でビルドしてみて?という同僚のアドバイス
» 3つの警告が新たに発生した
» コントリビュートの機会をついに得た!
© 2021 NTT DATA Corporation 32
In file included from /home/jyukutyo/code/jdk/src/hotspot/share/classfile/systemDictionary.hpp:31,
from /home/jyukutyo/code/jdk/src/hotspot/share/classfile/javaClasses.hpp:28,
from /home/jyukutyo/code/jdk/src/hotspot/share/precompiled/precompiled.hpp:35:
In member function 'void Symbol::byte_at_put(int, u1)',
inlined from 'Symbol::Symbol(const u1*, int, int)' at
/home/jyukutyo/code/jdk/src/hotspot/share/oops/symbol.cpp:55:16:
/home/jyukutyo/code/jdk/src/hotspot/share/oops/symbol.hpp:130:18: error: writing 1 byte into a region of
size 0 [-Werror=stringop-overflow=]
130 | _body[index] = value;
| ~~~~~~~~~~~~~^~~~~~~
(omitted)
GCC 10での変更点
© 2021 NTT DATA Corporation
33
GCC 10 Release Series — Changes, New Features, and Fixes https://gcc.gnu.org/gcc-10/changes.html
私が実施した方法
• 修正が必要なポイントをどのように見つけるか
1. ツールの新しいバージョンを使ってビルドしてみる
2. JDK Bug System (JBS)で課題を検索してみる
© 2021 NTT DATA Corporation 34
JDK Bug System (JBS)
• OpenJDKのバグトラッキングシステム
» https://bugs.openjdk.java.net/projects/JDK/issues/
© 2021 NTT DATA Corporation 35
ラベルでフィルターする
• OpenJDKのバグトラッキングシステム
» https://bugs.openjdk.java.net/projects/JDK/issues/
» 読み取り専用なら誰でも利用可能
» starterラベルでフィルターする
• starterラベルは初心者向け
• clean-upラベルも同様
© 2021 NTT DATA Corporation 36
私が実施した方法
• 修正が必要なポイントをどのように見つけるか
1. ツールの新しいバージョンを使ってビルドしてみる
2. JDK Bug System (JBS)で課題を検索してみる
© 2021 NTT DATA Corporation 37
コントリビュートの手順
• バグ修正でコントリビュートする手順
» 他のOSSにする場合とほとんど同じ一般的な手順
1. ✅バグを見つける
2. ➡バグを修正する
3. パッチを出す
4. レビューを受ける
5. コメントに対応する
6. パッチがマージされる
© 2021 NTT DATA Corporation 38
テストの実行も重要
• (コードの修正方法は内容に依存するので)
コードの修正が完了したと仮定します
• 対応するテストを実行する必要がある
© 2021 NTT DATA Corporation 39
テストの実行も重要
• (コードの修正方法は内容に依存するので)
コードの修正が完了したと仮定します
• 対応するテストを実行する必要がある
» Javaコードのテストツール: jtreg
• リグレッションテストハーネス
• https://openjdk.java.net/jtreg/index.html
© 2021 NTT DATA Corporation 40
jtregのテスト実行デモ
© 2021 NTT DATA Corporation 41
テストの実行も重要
• 対応するテストを実行する必要がある
» Javaコードのテストツール: jtreg
» C++コードのテストツール: gtest (GoogleTest)
• Google C++テスティングフレームワーク
© 2021 NTT DATA Corporation
テストの実行も重要
• 対応するテストを実行する必要がある
» Javaコードのテストツール: jtreg
» C++コードのテストツール: gtest (GoogleTest)
• Google C++テスティングフレームワーク
© 2021 NTT DATA Corporation
$ ./build/linux-x86_64-server-fastdebug/hotspot/variant-server/libjvm/gtest/gtestLauncher -jdk:./build/linux-
x86_64-server-fastdebug/jdk --gtest_filter=LogConfigurationTest.*
Note: Google Test filter = LogConfigurationTest.*
[==========] Running 15 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 15 tests from LogConfigurationTest
[ RUN ] LogConfigurationTest.describe_vm
[ OK ] LogConfigurationTest.describe_vm (1 ms)
(omitted)
[==========] 15 tests from 1 test case ran. (659 ms total)
[ PASSED ] 15 tests.
コントリビュートの手順
• バグ修正でコントリビュートする手順
» 他のOSSにする場合とほとんど同じ一般的な手順
1. ✅バグを見つける
2. ✅バグを修正する
3. ➡パッチを出す
4. レビューを受ける
5. コメントに対応する
6. パッチがマージされる
© 2021 NTT DATA Corporation 44
一番初めにすること
• メーリングリストにメールを送る
» 問題を詳細に説明する
» すでに修正パッチを書いているならそれも合わせて送る
© 2021 NTT DATA Corporation 45
メーリングリスト
• パッチだけでなくさまざまなことがここから始まる
» https://mail.openjdk.java.net/
© 2021 NTT DATA Corporation 46
メーリングリスト
• パッチだけでなくさまざまなことがここから始まる
» https://mail.openjdk.java.net/
• 200以上のメーリングリスト
© 2021 NTT DATA Corporation 47
メーリングリスト
• パッチだけでなくさまざまなことがここから始まる
» https://mail.openjdk.java.net/
• 200以上のメーリングリスト
» hotspot-dev - JVM
» compiler-dev - Javaコンパイラ
» core-libs-dev - Javaクラスライブラリ
» jdk-dev - 総合的なJDKに関する議論を扱う
© 2021 NTT DATA Corporation 48
私の体験談
• パブリックなメーリングリストに
英語でメールを送る!?
» 怖い...
© 2021 NTT DATA Corporation 49
私の体験談
• パブリックなメーリングリストに
英語でメールを送る!?
» 怖い...
» 大丈夫!
• 多くの人は親切で丁寧に対応してくれます
» 私たちのように英語が第2言語の人に対しても
© 2021 NTT DATA Corporation 50
私の初めてのメール
© 2021 NTT DATA Corporation 51
結果として
• JBSにイシューが登録される
» プルリクエストを作成する段階になった!
© 2021 NTT DATA Corporation 52
OpenJDKのソースコードリポジトリ
© 2021 NTT DATA Corporation 53
https://github.com/openjdk/jdk
• GitおよびGitHubを利用
» ただしプルリクエストファーストではない
• 開発者ロールがない場合は
まずメーリングリストへ投稿する
» 以前はMercurialを利用していた
• Project Skara
» Git, GitHubへの移行
» 新規開発者への敷居を低くするため
» JEP 357, 369
JBSとGitHubの関係
• JBSにすべてのイシューが登録される
» JBSのイシューNo.をプルリクエストのタイトルに含める
• PRへのコメントは関連するメーリングリストに
メールとして送られる
» 逆にメールで返信すればPRへのコメントとして投稿される
© 2021 NTT DATA Corporation 54
プルリクエストを送る
• OCAにサインする必要がある
» Oracle Contribution Agreement
» https://oca.opensource.oracle.com/
© 2021 NTT DATA Corporation 55
プルリクエストを送る
© 2021 NTT DATA Corporation 56
• いつものように作成する
コントリビュートの手順
• バグ修正でコントリビュートする手順
» 他のOSSにする場合とほとんど同じ一般的な手順
1. ✅バグを見つける
2. ✅バグを修正する
3. ✅パッチを出す
4. ➡レビューを受ける
5. コメントに対応する
6. パッチがマージされる
© 2021 NTT DATA Corporation 57
レビューを受ける
• Reviewerからレビューを受ける必要がある
» ReviewerとはOpenJDK開発でのロールの1つ
© 2021 NTT DATA Corporation 58
レビューを受ける
• Reviewerからレビューを受ける必要がある
» ReviewerとはOpenJDK開発でのロールの1つ
• OpenJDK開発のロール
» Reviewer - Committer + PRのレビュー
» Committer - Author + コミットとPRのスポンサー
» Author - JBSの編集
© 2021 NTT DATA Corporation 59
全世界で
ReviewerとCommitterは
合わせて300人強います
レビューを受ける
© 2021 NTT DATA Corporation 60
コントリビュートの手順
• バグ修正でコントリビュートする手順
» 他のOSSにする場合とほとんど同じ一般的な手順
1. ✅バグを見つける
2. ✅バグを修正する
3. ✅パッチを出す
4. ✅レビューを受ける
5. ✅コメントに対応する
6. ➡パッチがマージされる
© 2021 NTT DATA Corporation 61
スポンサーになってくれる人を見つける
• レビューが終わっても自分でPRはマージできない
» "スポンサー"が必要
• ReviewerかCommitterがスポンサーになれる
• スポンサーがPRのマージを実施する
© 2021 NTT DATA Corporation 62
© 2021 NTT DATA Corporation 63
© 2021 NTT DATA Corporation 64
(Omitted)
完了!
• バグ修正でコントリビュートする手順
1. ✅バグを見つける
2. ✅バグを修正する
3. ✅パッチを出す
4. ✅レビューを受ける
5. ✅コメントに対応する
6. ✅パッチがマージされる
© 2021 NTT DATA Corporation 65
© 2021 NTT DATA Corporation 66
実際のパッチ投稿を
追体験
バグを見つける
• GCC 10が出た後Linuxでビルドした
» 3つの警告が新たに発生した
» コントリビュート機会をついに得た!
© 2021 NTT DATA Corporation 67
In file included from /home/jyukutyo/code/jdk/src/hotspot/share/classfile/systemDictionary.hpp:31,
from /home/jyukutyo/code/jdk/src/hotspot/share/classfile/javaClasses.hpp:28,
from /home/jyukutyo/code/jdk/src/hotspot/share/precompiled/precompiled.hpp:35:
In member function 'void Symbol::byte_at_put(int, u1)',
inlined from 'Symbol::Symbol(const u1*, int, int)' at
/home/jyukutyo/code/jdk/src/hotspot/share/oops/symbol.cpp:55:16:
/home/jyukutyo/code/jdk/src/hotspot/share/oops/symbol.hpp:130:18: error: writing 1 byte into a region of
size 0 [-Werror=stringop-overflow=]
130 | _body[index] = value;
| ~~~~~~~~~~~~~^~~~~~~
(omitted)
バグを修正する
• 警告の内容を確認(抜粋)
© 2021 NTT DATA Corporation 68
/home/jyukutyo/code/jdk/src/hotspot/share/oops/symbol.hpp:130:18: error:
writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
130 | _body[index] = value;
| ~~~~~~~~~~~~~^~~~~~~
/home/jyukutyo/code/jdk/src/java.base/share/native/libfdlibm/k_standard.c:743:19:
error: 'exc.retval' may be used uninitialized in this function [-Werror=maybe-
uninitialized]
743 | return exc.retval;
| ~~~^~~~~~~
/home/jyukutyo/code/jdk/src/java.base/unix/native/libnet/NetworkInterface.c:974:13:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error:
'__builtin_strncpy' output may be truncated copying 15 bytes from a string of length 15
[-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
バグを修正する
• 以下のコードが対象
» symbol.{hpp,cpp}
» k_standard.c
» NetworkInterface.c
© 2021 NTT DATA Corporation 69
© 2021 NTT DATA Corporation 70
四苦八苦しながら
修正する
(各ファイル数行)
理解の記録:https://www.sakatakoichi.com/entry/2020/06/22/HotSpot_VMのシンボル名に関わるコード
最新リビジョンで最終確認をする
• 念のため複数のGCCバージョンで
ビルドを実行して確認した
» ビルドなので確認に時間がかかる
© 2021 NTT DATA Corporation 71
メーリングリストにパッチを送る
© 2021 NTT DATA Corporation 72
どのMLに出す??
メーリングリストにパッチを送る
• hotspot-runtime-devのMLへパッチをメールする
↓
• 一部をJBSにissue登録してもらえた
• パッチに対するコメントももらえた
© 2021 NTT DATA Corporation 73
© 2021 NTT DATA Corporation 74
ただ、ここから反応がなく
数週経ってしまう
メーリングリストにパッチを送る
• 一部をJBSへ登録してもらえた
• パッチに対するコメントももらえた
↓
• 再度メールし「この課題を進めたいです」と
主張してみる
↓
• パッチへのコメントが再開
• 最終的にレビューまで進んだ!
© 2021 NTT DATA Corporation 75
参考: MLへの英語メール
• 文章表現がとても難しく感じた
» ビジネスメールでもない
» プライベートでもない
» メールなのでGitHubでやり取りするときの感じだと
簡素すぎ!?
• 数行の英語メールを書くのにものすごく時間がかかる
» Google翻訳で英語を書き
和訳が変でないかを確認する
• (日本語を英語にするのではなく逆にする)
© 2021 NTT DATA Corporation 76
© 2021 NTT DATA Corporation 77
主要開発者の方
からも長文の
コメントをもらえた
スポンサーを見つけリポジトリへプッシュしてもらう
• パッチへのコメントから最終的にレビューまで進んだ!
↓
• レビュー者にスポンサーとしてリポジトリにプッシュし
てもらえた
© 2021 NTT DATA Corporation 78
© 2021 NTT DATA Corporation 79
ついに僕も
JVMの一部に…!
© 2021 NTT DATA Corporation 80
めでたしめでたし
(ん!?待てよ)
メーリングリストにパッチを送る
• hotspot-runtime-devのMLへパッチをメールする
↓
• 一部をJBSへ登録してもらえた
© 2021 NTT DATA Corporation 81
© 2021 NTT DATA Corporation 82
パッチの残りの部分を
新たに進めなくては!
私がやるべきこと
• メーリングリストにパッチをメールする
» 別のML(core-libs-dev)に
パッチの残りの部分をメールする
• スポンサーを見つける
• スポンサーにパッチを適用し
リポジトリへプッシュしてもらう
© 2021 NTT DATA Corporation 83
メーリングリストにパッチを送る
• 別のML(core-libs-dev)にパッチの残りの部分を
メールする
↓
• 残りの中のさらに一部をレビューしてもらえた
• 最後の1ファイルは長年更新がなくレビューできる人が
簡単に見つからない
↓
• コード修正ではない解決方法を模索し提案をメールする
» ビルドでその警告を無視する設定など
© 2021 NTT DATA Corporation 84
メーリングリストにパッチを送る
• しばらくやり取りしていると、
ここをレビューできる方からメールがあり
(つまりOpenJDK主要開発者からのメール)
レビューOKをもらえた!
• 他レビュワーからのレビューも加えて
そのままスポンサーになってもらう
© 2021 NTT DATA Corporation 85
スポンサーを見つける/パッチを適用してプッシュしてもらう
• リポジトリにプッシュしてもらえた
© 2021 NTT DATA Corporation 86
図解
© 2021 NTT DATA Corporation 87
最初に作った
パッチ
パッチ1
HotSpot系
(Symbol)
パッチ2
core-libs系
レビュー1
NetworkInterface
レビュー2
k_standard
© 2021 NTT DATA Corporation 88
このような込み入ったことに
なるケースもありますが
多くはスムーズに進みます
大事なこと
• 自分の考えを主張すること!
» 私を含め多くの日本人にとって勇気がいることの1つ
© 2021 NTT DATA Corporation 89
大事なこと
• 自分の考えを主張すること!
» 私を含め多くの日本人にとって勇気がいることの1つ
» 言わなくても伝わる 誰かが汲み取ってくれる は
日本における文化でありグローバルなコミュニティで
前提にすることはできない
© 2021 NTT DATA Corporation 90
大事なこと
• 自分の考えを主張すること!
» 私を含め多くの日本人にとって勇気がいることの1つ
» 言わなくても伝わる 誰かが汲み取ってくれる は
日本における文化でありグローバルなコミュニティで
前提にすることはできない
» 根拠や筋道が大きく誤っていなければ
主張することで物事は進む
• 一度の主張で反響がなくても諦めてはいけない
• むしろ一度で進み出す方がまれです
© 2021 NTT DATA Corporation 91
© 2021 NTT DATA Corporation 92
簡単な内容のパッチ例2つ
93
© 2021 NTT DATA Corporation
例: jcmdのバグ修正
https://bugs.openjdk.java.net/browse/JDK-8265047
94
© 2021 NTT DATA Corporation
Java 16のjcmdにおけるULログ設定バグ
95
© 2021 NTT DATA Corporation
96
© 2021 NTT DATA Corporation
Java 17のjcmdでのULログ
97
© 2021 NTT DATA Corporation
例: clhasdbのバグ修正
https://bugs.openjdk.java.net/browse/JDK-8176026
98
© 2021 NTT DATA Corporation
CLHSDBでヒストグラムを取得する
99
© 2021 NTT DATA Corporation
Java 16だとここがバグ
100
© 2021 NTT DATA Corporation
バグ修正
https://github.com/openjdk/jdk/pull/3087/files
intで扱っているから
ヒープサイズが大きいとバグが現れる
コマンドツールのバグ修正
• jcmd, jhsdbなどのコマンド関連では
Java 17に対して3つほどコントリビュートできた
» コマンドは試しやすいのでバグを見つけられるかも!
» 試すうちにJVMの知識もつき労力対効果がよい!
© 2021 NTT DATA Corporation 101
まとめ
• パッチを出すのは怖くないよ!
» OpenJDKへのコントリビュートは難しくない
• 一緒にOpenJDKをさらによくしていきましょう!
© 2021 NTT DATA Corporation 102
© 2021 NTT DATA Corporation
All other company or product names mentioned here in are trademarks or registered trademarks of their respective owners.

Let's Start Contributing to OpenJDK from Today!(Oracle Groundbreakers APAC Virtual Tour 2021 発表資料)

Editor's Notes

  • #3 Let me introduce myself I'm Koichi, Koichi Sakata I'm talking to you from Japan I show my handle name at the bottom left of this slide Follow me if you are interested I'm a Java Champion Last year I submitted some patches to OpenJDK, so I'm an OpenJDK Author now I work at NTT Data
  • #4 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #5 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #8 This chart shows issues fixed in JDK 17 per organization Our company, including me, has contributed to OpenJDK since before
  • #10 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #11 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #12 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #13 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #14 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #15 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #16 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #17 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #18 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #19 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #20 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #21 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #23 Today I will be taking about contributing to OpenJDK How many of you want to contribute to OpenJDK? Yes, I can see All people in this room want to do so As you can see, there are many ways of contributing When you hear of the contribution to open source software, the first thing that you think of is writing code But there are other ways to contribute It's good to combine some ways
  • #24 In this presentation, I will focus on the way of submitting patches Because this is the thing that most people are interested in, I think After this presentation, you will be able to submit patches to OpenJDK Duke needs you for JDK development
  • #25 Let's try to think about fixing bugs The contribution process is almost the same as developments of popular open source software, such as spring framework, Jakarta EE, etc.
  • #26 There are some steps to fix a bug First, find.., then fix..., submit..., finally the patch is merged I'll explain each step from now
  • #27 There are some steps to fix a bug First, find.., then fix..., submit..., finally the patch is merged I'll explain each step from now
  • #28 As you know, OpenJDK works well in our applications almost always Have you ever come across a new JDK bug? We try to find bugs but failing to do so What should we do? Where are points to be fixed?
  • #29 I tried some different ways. As a result, I've found points to be fixed before. I'll introduce them to you. It's effective to build OpenJDK with new versions of tools
  • #30 As you may know, OpenJDK has not only Java but also C++, especially JVM is written in C++ So we need tools for C++ to build it For example we use GCC on Linux, Clang on macOS, Visual Studio on Windows You can build it on WSL, Windows Subsystem for Linux Errors or warnings might occur during the build. If those occurs, it means you have found the point to be fixed. Then you can try to resolve it
  • #31 Have you ever built... easy. Clone the repository in GitHub, configure, I recommend to add enable debug option and make images Note that build takes time very much needs 10 mins or so
  • #32 is the movie of Op.. build increased the playback speed That's it
  • #33 I've actually tried it before I saw some warnings with GCC 10 immediately after it released Those warnings didn't happened with GCC 9 What you can see at the bottom is one of the warnings The details of the warning is out of this presentation When you build with the new versions of tools, you might be able to see some errors or warnings as well
  • #34 On the GCC website, I found those sentences in this slide The warning was enhanced in GCC 10 I examined the warning further and tried to change the code to fix the warning This is how I write a patch for warnings
  • #35 I'll introduce another way to find points to be fixed OpenJDK has the bug tracking system We simply call it JBS
  • #36 It's the bug tracking system JBS is based on Atlassian JIRA So you can operate JBS in the same way as JIRA. Look at this screenshot Each issue has detailed information
  • #37 JBS is accessible for everyone with read-only You can search issues on JBS In this screenshot I used the query language to search issues that have starter label Those are for beginners so good to address I’ve fixed some issues that had the label before Issues that have clean-up label are also good for beginners
  • #38 I'll introduce another way to find points to be fixed OpenJDK has the bug tracking system We simply call it JBS
  • #39 There are some steps to fix a bug First, find.., then fix..., submit..., finally the patch is merged I'll explain each step from now
  • #40 Assume that we've finished fixing code Of course, we should run tests before sending a patch
  • #41 Jtreg is the regression test harness I'll show you a demo
  • #42 This is the movie of running a jtreg test I increased the playback speed This code is a test class for the clhsdb tool in the jhsdb I executed the make run-test command It's running the test Just a moment What you can see here is the result of running a jtreg test
  • #43 There is also gtest test code for the C++ part Gtest is a Google C++ testing framework
  • #44 Here is the result of running a gtest test.
  • #45 There are some steps to fix a bug First, find.., then fix..., submit..., finally the patch is merged I'll explain each step from now
  • #46 Instead of creating pull requests, it's better to send a mail to the suitable mailing lists. In the mail, you write the details of the issue you found and paste the patch if you have written it already When the issue is recognized, it is filed in JBS After that, you can create the pull request to the repository
  • #47 Mailing lists are important for the OpenJDK development. I'm going to talk for a minute about them
  • #48 Don't be surprised, OpenJDK has many mailing lists. I took a count of them There are 200 mailing lists
  • #49 I'll introduce a few of them hotspot-dev, compiler-dev... Each mailing list covers of the topic as described in this slide It's good to subscribe those mailing lists to gather information All mails are archived We can read past communications on the web site
  • #50 Yes, I understand how you feel now Do we need to code to the public mailing list? Everyone will feel uneasy to do I used to be the same
  • #51 But don't be afraid People in the OpenJDK community are friendly and polite Even if English is your second language, like me So you can send the mail, too
  • #52 This is my first mail to the mailing list As you can see, it's about GCC warnings I explained before
  • #53 When the issue is recognized, OpenJDK developers filed it in JBS After that, you can create a pull request in GitHub.
  • #54 OpenJDK has a repository in GitHub. It used to use Mercurial
  • #55 There is a relationship between JBS and GitHub All issues need to be files in JBS We have to write the issue number in the title of the pull request Additionally, comments to the pull request are send to related mailing lists of OpenJDK and vice versa
  • #56 Before creating a pull request, we have to sign OCA, that is Oracle Contribution Agreement For more information see this link
  • #57 Next, we create a pull request as usual This screenshot is my pull request
  • #58 There are some steps to fix a bug First, find.., then fix..., submit..., finally the patch is merged I'll explain each step from now
  • #59 Of course the pull request need to be reviewed The only people who has a reviewer role can review and approve the code Reviewer is one of the roles in OpenJDK Community
  • #60 I'll give a short explanation of roles in OpenJDK Everyone is a contributor at first They don't have any privileges After some contributions, you will be an Author I have this role I'll touch on what sponsoring means later At present, there are over three hundred committers and reviewers When you make many significant changes, you will become a committer or reviewer
  • #61 Let's get back to the pull request In this example, my pull request were reviewed by four reviewers
  • #62 There are some steps to fix a bug First, find.., then fix..., submit..., finally the patch is merged I'll explain each step from now
  • #63 We can't merge our pull request by ourselves After the review, Reviewer or committer can sponsor the pull request The sponsor will merge it If you don’t have any role, your name will be recorded as a contributor
  • #64 In this screenshot, the sponsor run sponsor pull request command to merge this pull request
  • #65 Finally, the pull request is merged. You will see the message like this when your pull request is merged.
  • #66 We did it! I've explained all steps to fix a bug.
  • #68 I've actually tried it before I saw some warnings with GCC 10 immediately after it released Those warnings didn't happened with GCC 9 What you can see at the bottom is one of the warnings The details of the warning is out of this presentation When you build with the new versions of tools, you might be able to see some errors or warnings as well
  • #103 Let me summarize Today I talked about contributing to OpenJDK There are many steps But don't be afraid You can do it Let's move OpenJDK forward together!
  • #104 I guess that's all I wanted to say today Thank you for your attention Enjoy this conference!