the openjdk developer experience · copyright © 2018, oracle and/or its affiliates. all rights...
TRANSCRIPT
![Page 1: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/1.jpg)
![Page 2: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/2.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
The OpenJDK Developer Experience
Erik DuvebladOpenJDK Developer @ OracleFebruary, 2018
2
![Page 3: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/3.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
3
![Page 4: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/4.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Agenda
Developer Experience
Version Control
Building
Testing
Putting it all together
1
2
3
4
5
4
![Page 5: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/5.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Who am I?
• Erik Duveblad– Works at Oracle as JVM GC developer
– Worked with OpenJDK for 5 years
– Contributes to:● HotSpot● Makefiles● JTReg, jcov, jtharness
– ehelin @ #openjdk on irc.oftc.net
5
![Page 6: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/6.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Agenda
Developer Experience
Version Control
Building
Testing
Putting it all together
1
6
2
3
4
5
![Page 7: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/7.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Developer Experience
• User experience (UX)
– “… a person's emotions and attitudes about using a particular product, system or service”
• Developers are users too!
– version control, build systems, testing systems, frameworks, etc.
• Developer experience (DX)
– the experience of using all the developer tools for a project
Definition
7
![Page 8: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/8.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Developer Experience
• Applied to OpenJDK:
– The VCS tools (hg, webrev, defpath, jcheck)
– The build system (configure, make)
– The test systems (JTReg, googletest, TestNG, Junit)
– IDE support (IntelliJ, NetBeans, Eclipse, Visual Studio, Emacs, VIM)
– Services (JBS, cr, wiki, mailing lists, IRC)
• Benefit of being a developer: both producer and consumer!
Definition
8
![Page 9: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/9.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Developer Experience
• Applied to OpenJDK:
– The VCS tools (hg, webrev, defpath, jcheck)
– The build system (configure, make)
– The test systems (JTReg, googletest, TestNG, Junit)
– IDE support (IntelliJ, NetBeans, Eclipse, Visual Studio, Emacs, VIM)
– Services (JBS, cr, wiki, mailing lists, IRC)
• Benefit of being a developer: both producer and consumer!
Definition
9
![Page 10: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/10.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Agenda
Developer Experience
Version control
Building
Testing
Putting it all together
10
3
4
5
1
2
![Page 11: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/11.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Version control
• OpenJDK uses Mercurial (hg) for version control
• JEP 296: Consolidate the JDK Forest into a Single Repository– Consolidated eight repositories to one!– $ hg clone http://hg.openjdk.java.net/jdk/jdk
• Benefits– Easier to get started
– Atomic commits
– One hash describes entire state
Mercurial (hg)
11
![Page 12: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/12.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Version control
• Mercurial (hg) has also been greatly improved in 2017– Editing of local commits and history
● amend, unamend, uncommit, split, strip, histedit, rebase, shelve– Improved user interface
● ui.pagenate, ui.color, show, graphlog
– Improved performance● diff (2x faster), zstd, revlog, conflic checking, copy detection, fsmonitor
Mercurial (hg)
12
![Page 13: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/13.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Version control
• Mercurial (hg) has also been greatly improved in 2017– Editing of local commits and history
● amend, unamend, uncommit, split, strip, histedit, rebase, shelve– Improved user interface
● ui.pagenate, ui.color, show, graphlog
– Improved performance● diff (2x faster), zstd, revlog, conflic checking, copy detection, fsmonitor
Mercurial (hg)
13
![Page 14: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/14.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Version control
• Sample configuration (hg version 4.5)
Mercurial (hg)
14
[extensions]amend =uncommit =show =graphlog =sparse =strip =shelve =record =fsmonitor =split =
[ui]username = ehelinpagenate = Truecolor = True
![Page 15: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/15.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Agenda
Developer Experience
Version control
Building
Testing
Putting it all together
15
4
5
1
2
3
![Page 16: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/16.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Building
• Since around September 2016, the “new” build system is used for all code
$ bash configure$ make
• configure will help you if dependencies are missing
$ bash configure
configure: error: Could not find a C++ compiler.You might be able to fix this by running'sudo apt-get install build-essential'.
• Extensive documentation in doc/building.md
Makefiles
16
![Page 17: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/17.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Building
• OpenJDK requires a “boot JDK” for building
– e.g. OpenJDK 9 requires JDK 8
• Often hard to find suitable “boot JDK” for development
– jdk/jdk currently requires JDK 9, soon JDK 10
– few distributions package that recent JDKs
– the Oracle JDK is still proprietary
• Upstream binary builds of OpenJDK now available!
– http://jdk.java.net/9/
Makefiles
17
![Page 18: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/18.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Building
• Building from scratch on Debian 9
$ hg clone http://hg.openjdk.java.net/jdk/jdk$ cd jdk$ wget https://download.java.net/java/GA/jdk9/9.0.4/binaries/openjdk-9.0.4_linux-x64_bin.tar.gz$ bash configure –with-boot-jdk=openjdk-9.0.4_linux-x64_bin.tar.gz$ make images
• If any package is missing, configure will help you :)
Makefiles
18
![Page 19: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/19.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
BuildingMakefiles
19
• Many DX improvements in the last year
– debug symbols are no longer zipped by default
– fontconfig no longer bundled
– compiler errors are repeated at end of build output
– all compiler commands for each file in *.cmdline files
– run-test target introduced
![Page 20: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/20.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
BuildingMakefiles
20
• Many DX improvements in the last year
– debug symbols are no longer zipped by default
– fontconfig no longer bundled
– compiler errors are repeated at end of build output
– all compiler commands for each file in *.cmdline files
– run-test target introduced
![Page 21: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/21.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Buildingrun-test
21
• New top-level make target: run-test$ make run-test TEST=test/jdk/java/lang/String/Split.java
• Supports multiple test frameworks– JTReg– googletest
• Supports running test suites, directories and files$ make run-test TEST=tier1$ make run-test-tier1
$ make run-test TEST=test/hotspot/jtreg/gc
![Page 22: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/22.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Buildingrun-test
22
• Runs tests correctly– Tests from ProblemList.txt are ignored
– Uses failure handlers
– Always uses fresh, clean JTWork directory
– Uses multiple cores if possible
– Adds correct JVM flags
![Page 23: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/23.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Buildingrun-test
23
• Supports passing options$ make run-test TEST=”gtest:LogTagSet” GTEST="REPEAT=-1"
• Extensive documentation$ less doc/testing.md
• Requires jtreg$ bash configure --with-jtreg=path/to/jtreg/image
![Page 24: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/24.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Agenda
Developer Experience
Version control
Building
Testing
Putting it all together
24
5
1
2
3
4
![Page 25: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/25.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Testingjtreg
25
• run-test requires passing --with-jtreg to configure
• Building jtreg used to be problematic…– javahelp only available in ancient SVN repository– jtharness required proprietary library (!)
– Third-party dependencies not properly specified
– Use of outdated third-party dependencies
– Use of incompatible third-party dependencies
![Page 26: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/26.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Testingjtreg
26
• All this has been fixed!$ hg clone http://hg.openjdk.java.net/code-tools/jtreg$ cd jtreg$ sudo apt install openjdk-8-jdk$ bash make/build-all.sh /usr/lib/jvm/java-8-openjdk-amd64/
• Automatically downloads and verifies dependencies– http://hg.openjdk.java.net– https://repo1.maven.org/maven2
• Resulting image can be passed to configure
![Page 27: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/27.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Testingjtreg
27
• Can now build and test from scratch on Debian 9
$ hg clone http://hg.openjdk.java.net/jdk/jdk$ cd jdk$ bash configure \
--with-boot-jdk=../openjdk-9.0.4_linux-x64_bin.tar.gz \ --with-jtreg=../jtreg/build/images/jtreg
$ make run-test-tier1
![Page 28: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/28.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Testingjtreg
28
• JTReg testlibraries have converged– Available at test/lib/jdk/test/lib
– Provides asserts, process tools, platform helpers etc.
• How to get started– http://openjdk.java.net/projects/code-tools/jtreg/intro.html
![Page 29: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/29.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Testinggoogletest
29
• googletest is available for writing C++ unit tests for HotSpot
$ cat test/hotspot/gtest/gc/g1/test_g1Analytics.cpp
#include “precompiled.hpp”#include “gc/g1/g1Analytics.hpp”#include “gc/g1/g1Predictions.hpp”#include “unittest.hpp”
TEST_VM(G1Analytics, is_initialized) { G1Predictions p(0.888888); G1Analytics a(&p); ASSERT_EQ(a.recent_avg_pause_time_ratio(), 0.0); ASSERT_EQ(a.last_pause_time_ratio(), 0.0);}
![Page 30: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/30.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Testinggoogletest
30
• How to get started– https://github.com/google/googletest/blob/master/googletest/docs/Primer.md
– TEST runs test without VM– TEST_VM runs test in a shared VM
– TEST_OTHER_VM runs test in separate VM
– TEST_VM_ASSERT runs test in separate and expects failure
• Always make unittest.hpp the last include
![Page 31: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/31.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Agenda
Developer Experience
Version control
Building
Testing
Putting it all together
31
1
2
3
5
4
![Page 32: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/32.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Putting it all togetherWorkflow
32
• Clone the repository$ hg clone http://hg.openjdk.java.net/jdk/jdk && cd jdk
• Create a branch for your issue$ hg branch JDK-8012345
• Name your build profile the same as your branch$ bash configure --with-conf-name=JDK-8012345 \
--with-jtreg=../jtreg/build/images/jtreg \ --with-boot-jdk=../linux_9.0.4_x64_bin.tar.gz
• Hack, write tests, commit, run tests locally$ make CONF_NAME=JDK-8012345 run-test-tier1 run-test-tier2
![Page 33: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/33.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Putting it all togetherWorkflow
33
• Add sandbox and submit repositories as paths$ echo >> .hg/hgrc <<EOF [paths] submit = http://hg.openjdk.java.net/jdk/submit sandbox = http://hg.openjdk.java.net/jdk/sandbox EOF
• Push to the submit repository for final testing$ hg push -b JDK-8012345 --new-branch submit
• Push to the sandbox to share$ hg push -b JDK-8012345 --new-branch sandbox
![Page 34: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/34.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Putting it all togetherFuture
34
• make compile-commands
– Creates compile_commands.json
– Better integration with● clang-tools● cquery
![Page 35: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/35.jpg)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Putting it all togetherJoin us!
35
• Feedback– what can be improved?
• Contribute– start hacking on code-tools, Makefiles, test libraries
• Keep in touch– #openjdk @ irc.oftc.net– [email protected]
![Page 36: The OpenJDK Developer Experience · Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Putting it all together. Title: The OpenJDK Developer Experience Created](https://reader035.vdocuments.mx/reader035/viewer/2022071210/6021164ab0cf9a40c16dbef2/html5/thumbnails/36.jpg)