720 likes | 745 Views
Java 11 – Keeping the Java Release Train on the Right Track. Jeanne Boyarsky QCon – June 28, 2018. speakerdeck.com/boyarsky. So much changed since Java 9 & Jigsaw ’ s release!. For more on Java 9, see: https://speakerdeck.com/boyarsky/welcome-to-java-9?slide=1. Topics: Ecosystem changes
E N D
Java 11 – Keeping the Java Release Train on the Right Track Jeanne Boyarsky QCon– June 28, 2018 speakerdeck.com/boyarsky
For more on Java 9, see: https://speakerdeck.com/boyarsky/welcome-to-java-9?slide=1
Topics: • Ecosystem changes • Language changes
About Me 16 years as Java Developer
The Saga of Jigsaw • 2011 – Maybe part of Java 7. Nope Plan B • 2012 - Part of Java 8. No wait • 2014 - Part of Java 9
Java 9 “Release” Dates • Sept 2016 • May 2017 • July 2017 • Sept 2017
Counting lessons? • 1.0, 1.1, 1.2, 1.3, 1.4 • 5.0 • 6, 7, 8, 9, 10, 11
Advanced counting lessons • 10 = 2018.3 • 11 = 2018.9 • 12 = ?
Wait, a major version every 6 months? • + Syntax changes • + Smaller features • - Years of features
Frequency of Release F Predictability of Release D Java School Report Card Developer Community A Features B
Frequency of Release F Predictability of Release D JVM College Report Card Vocabulary B Polyglot programming A
How many languages do you know? Examples • Java • Kotlin • Groovy • Scala • SQL • HTML • JavaScript • CSS • One (or zero) • Two – Five • Six or more
Before Now
Before Now
Wait. So what happens next? How long will Java 12 have security patches? Answer: 6 months What is the next LTS version after Java 11? Java 11 + 3*2 = 17
Only bug fixes remain Only bug fixes allowed
Tip: Aliases alias javac11=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/javac alias java11=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/java
(10/11) Local variable syntax
(10) • String name = "Jeanne”; • var name = "Jeanne"; • List list = List.of(1, 2, 3); • var list = List.of(1, 2, 3); • Syntactical sugar/less boilerplate • Not immutable (no val)
(10) varname = "Jeanne"; String name2 = name; • Compiled code same with var
(10) List<WebElement> headers = thead.findElements(By.tagName("th")); VolunteerDashboardRowheaderRow = new VolunteerDashboardRow(headers); vs varheaders = thead.findElements(By.tagName("th")); varheaderRow = new VolunteerDashboardRow(headers);
(10) varcsvPath = createAndGetFile(CSV_DATA); try (varcsvWriter = Files.newBufferedWriter(csvPath); varcsvPrinter = new CSVPrinter(csvWriter, CSVFormat.DEFAULT));{ }
(10) Map<Integer, String> productMap1 = new HashMap<Integer, String>(); Map<Integer, String> productMap2 = new HashMap<>(); varproductMap3 = new HashMap<Integer, String>();
(10) Where can we use? • varname = "Jeanne"; • varother = name + 2; • var list = List.of(1, 2, 3); • for (var num : list) {}
(10) Where can’t we use? • class Inner { var bad = "abc"; } • var noGood; • noGood = 4; • Also instance variables, etc
(10) Does this work? varvar = "var";
(10) http://openjdk.java.net/projects/amber/LVTIstyle.html
(11) Lambdas Predicate<String> pred1 = p -> true; Predicate<String> pred2 = (String p) -> true; Predicate<String> pred3 = (varp) -> true;
(11) Annotations BiPredicate< Map<Integer, String>, List<String>> func = (@NotNullvarmap, varlist) -> true;
(11) All or nothing Good (varmap, varlist) -> true No good (varmap, list) -> true (varmap, List list) -> true
(10/11) Garbage collection
(10) Choose your own GC • Who cares? • Agile. With releases every 6 months, features are smaller
(10) Faster Default GC For more, see https://speakerdeck.com/cguntur/garbage-collection-in-java-9
(10) Regions & space vs speed For more, see https://speakerdeck.com/cguntur
(11) Epsilon GC • Never reclaims memory • Program proceeds until run out of heap • GC never runs • To use: • -XX:+UseEpsilonGC • (or) -XX:+UseNoGC
(11) Epsilon GC Good for • Performance/memory stress test • Very short programs • Last ditch performance improvements • (this probably isn’t you)
(11) Z GC • Experimental • 10ms or less pause time • Only for Linux/x64 • To use, enable both: • -XX:+UnlockExperimentalVMOptions • -XX:+UseZGC
(11) I’m done incubating! Http Client