first adoption hackathon at bgjug
TRANSCRIPT
Adopt OpenJDK
Hackathon, 11 Dec. 2014
Agenda of the hackathon
Build OpenJDK
Improve OpenJDK
Write some tests
Create patch
Submit patch
Agenda of the hackathon
Build OpenJDK
Improve OpenJDK
Write some tests
Create patch
Submit patch
While building…
◦ Intro to OpenJDK
Let’s get it going
Import VM and login
Change to openjdk directory
cd $SOURCE_CODE/jdk9
Get the sources
bash get_sources.sh
Configure
bash configure
Make images
make clean images
OpenJDK overview
Free and open-source implementation of the Java Platform, Standard Edition
Base for the Oracle VM
GPL v2 for the VMs and GPL v2 + classpath exception for class libraries
Major contributors:◦ IBM
◦ Apple
◦ RedHat
◦ SAP
◦ A lot of JUGs
Why bother?
Move Java forward
Give back something to the platform
Help our JUG gain its own identity and
focus
Acquire new knowledge
Have some fun and socialize
How can we help?
Introductory level
◦ Fix compiler warnings
◦ Generify, coinify and labdify internal APIs
◦ Add new tests, convert existing tests
◦ Fix typos, add javadoc
Next level
◦ Affiliate with an existing project (Jigsaw,
Nashorn)
◦ Help with new stuff in project Valhalla
Development process
Sign OCA
Find interesting bug or enhancement
Discuss with sponsoring project
mailing list
Get together and create a patch
◦ Don’t forget the tests!
Upload the patch and contact ML
again
Be proud of yourself!
Task selection (1)
Add getStackTraceString() to Throwable
Usually people do:catch (MyException e) {
StringWriter sw = new StringWriter();e.printStackTrace(
new PrintWriter(sw));}
Look at existing solutions (Apache Commons)
https://bugs.openjdk.java.net/browse/JDK-5050783
Task selection (2)
Generic support to Collection bulk methods
addAll, containsAll, removeAll, retainAll can only receive other collections
You have to an intermediate Arrays.asList:
collection.addAll(Arrays.asList("a", "b", "c"));
Consider using default methods
https://bugs.openjdk.java.net/browse/JDK-6201180
Task selection (3)
Replace array parameters with
varargs
Look throughout all internal APIs
Supported since JDK 1.5
Discuss with Joe Darcy and team
https://bugs.openjdk.java.net/browse/J
DK-4974893
Write some tests
JTreg: the legacy◦ Java program with main method
◦ If test fails, testcase should throw an exception
◦ If it succeeds, testcase should return normally
/* @test
* @summary StringBuffer.isEmpty();
* @run main IsEmptyTest
*/
public class IsEmptyTest {
public static void main(String[] args) {
StringBuffer buffer = new StringBuffer();
if (!buffer.isEmpty()) {
throw new RuntimeException("StringBuffer isEmpty on newobject failed");
}
}
}
Test “docklets”
@test – defines a test. Mandatory.
@run – tells how to perform a test.
@summary – text description.
@library – reference library source files.
@build – compile class or library before running test
@bug – bug number reference
@key – keywords
TestNG support
TestNG is cool and nicely supported
TestNG test cases are run through jtreg
Two types of tests
Type 1◦ Describe the test in JTreg “docklets”
◦ No main method required/* @test
* @summary comments about your test;
* @run testng YourTest
*/
Type 2◦ Describe the test in TEST.ROOT or TESTS.properties
TestNG.dirs = .
othervm.dirs = tck/java/time/chronotest/java/time/chrono test/java/time/format
Create a patch
Let’s contribute
cd $SOURCE_CODE/jdk9
Commit in Mercurial
hg status
hg commit
Run webrev
ksh ../webrev.ksh
Upload to web server
$SOURCE_CODE/jdk9/webrev