Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
2018-QCon-Java-11.pdf
Search
Jeanne Boyarsky
June 28, 2018
Programming
2
490
2018-QCon-Java-11.pdf
Jeanne Boyarsky
June 28, 2018
Tweet
Share
More Decks by Jeanne Boyarsky
See All by Jeanne Boyarsky
2024-java21.pdf
boyarsky
0
9
NYC FRC 2024 Kickoff Awards Presentation
boyarsky
0
50
Preparing to Apply and Speak at Conferences
boyarsky
0
34
Refactoring to Java 21
boyarsky
1
18
2023-static-analysis.pdf
boyarsky
0
29
Readable Regular Expressions in Java
boyarsky
0
78
Readable Regular Expressions
boyarsky
0
150
Java Idioms for becoming a more powerful developer
boyarsky
0
120
12 Tips for Writing Readable Code
boyarsky
0
180
Other Decks in Programming
See All in Programming
IntelliJ IDEA を知らなかった 自分に教えたい小ネタ集 / IntelliJ IDEA Hints for My Past Self
mackey0225
3
180
Dockerで始めるAWS Lambda開発
stutkhd0709
14
2.5k
ファイル先頭の use の意味、説明できますか? 〜PHP の namespace と autoloading の関係を正しく理解しよう〜 / namespace and autoloading in php
okashoi
2
470
決断するための勇気、そのためのBacklog / Courage to make decisions, Backlog for that.
seike460
PRO
4
1.9k
The Future of C++ Interoperability: Insights from Porting a Game to Swift
teamhimeh
0
290
Laravel標準バリデーションでできること
hmb_ok
2
360
オブジェクト指向のリ・オリエンテーション~歴史を振り返り、AI時代に向きなおる~
hanyudaeiiti
2
270
デザインシステムで Tailwind CSSとCSS in JSに分散投資をしたら良かった話
fsubal
14
3.5k
OpenTelemetry のサービスという概念について
azukiazusa1
1
410
PHP8の機能を使って堅牢にコードを書く
fendo181
6
2.6k
Material 3で Material 2ぽい見た目にする
numeroanddev
2
250
Ruby製社内ツールのGo移行
bgpat
2
270
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
16k
KATA
mclloyd
14
11k
Agile that works and the tools we love
rasmusluckow
323
20k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
19
1.6k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
153
14k
Bash Introduction
62gerente
604
210k
YesSQL, Process and Tooling at Scale
rocio
160
13k
The Invisible Customer
myddelton
114
12k
Clear Off the Table
cherdarchuk
82
310k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
657
120k
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
178
11k
Transcript
@jeanneboyarsky Java 11 – Keeping the Java Release Train on
the Right Track speakerdeck.com/boyarsky Jeanne Boyarsky QCon– June 28, 2018
@jeanneboyarsky So much changed since Java 9 & Jigsaw’s release!
2
@jeanneboyarsky 3
@jeanneboyarsky For more on Java 9, see: https://speakerdeck.com/ boyarsky/welcome-to- java-9?slide=1
4
@jeanneboyarsky Topics: • Ecosystem changes • Language changes 5
@jeanneboyarsky About Me 16 years as Java Developer 6
@jeanneboyarsky Memories! 7
@jeanneboyarsky Til Java 6 (1996- 2006) Hi Oracle (2010) Java
7 (2011) Java 8 (2014) Java 9 (2017) 8
@jeanneboyarsky 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 9
@jeanneboyarsky Java 9 “Release” Dates • Sept 2016 • May
2017 • July 2017 • Sept 2017 10
@jeanneboyarsky Counting lessons? • 1.0, 1.1, 1.2, 1.3, 1.4 •
5.0 • 6, 7, 8, 9, 10, 11 11
@jeanneboyarsky Advanced counting lessons • 10 = 2018.3 • 11
= 2018.9 • 12 = ? 12
@jeanneboyarsky Wait, a major version every 6 months? • +
Syntax changes • + Smaller features • - Years of features JDK 10 JDK 11 12 new features 15 new features 13
@jeanneboyarsky Java School Report Card Developer Community à A Features
à B Frequency of Release à F Predictability of Release à D 14
@jeanneboyarsky JVM College Report Card Vocabulary à B Polyglot programming
à A Frequency of Release à F Predictability of Release à D 15
@jeanneboyarsky Re-org at the train station 16
@jeanneboyarsky How many languages do you know? q One (or
zero) q Two – Five q Six or more Examples • Java • Kotlin • Groovy • Scala • SQL • HTML • JavaScript • CSS 17
@jeanneboyarsky Before Now 18
@jeanneboyarsky Before Now 19
@jeanneboyarsky Before Now Releases every Varies 6 months (or 3
years) Releases are Feature driven Date driven 20
@jeanneboyarsky More time to code while I wait for the
next train! 21
@jeanneboyarsky Arrivals Train Schedule Java Release Date Long Term Support
9 September 21, 2017 10 March 20, 2018 11 September 25, 2018 22
@jeanneboyarsky Security Patches Departure Schedule Java Public Patches Paid Patches
6 2013 Late 2018 7 2015 2022 8 January 2019 (business) December 2020 (public) 2025 23
@jeanneboyarsky Security Patches Departure Schedule Java Public patches Paid patches
9 March 2018 n/a 10 September 2018 n/a 11 March 2019 2023-2028 24
@jeanneboyarsky 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 25
@jeanneboyarsky A Tale of Two JDKs Java Oracle JDK Open
JDK New Version Every 3 years Every 6 months Cost Paid Free Upgrade Options • Security patch • Next version • OpenJDK • Interim security patch • Next version 26
@jeanneboyarsky Only bug fixes remain Only bug fixes allowed 27
@jeanneboyarsky Get ready to play 28
@jeanneboyarsky 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 29
@jeanneboyarsky LOCAL VARIABLE SYNTAX (10/11) 30
@jeanneboyarsky 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) 31
@jeanneboyarsky var name = "Jeanne"; String name2 = name; •
Compiled code same with var (10) 32
@jeanneboyarsky List<WebElement> headers = thead.findElements(By.tagName("th")); VolunteerDashboardRow headerRow = new VolunteerDashboardRow(headers);
vs var headers = thead.findElements(By.tagName("th")); var headerRow = new VolunteerDashboardRow(headers); (10) 33
@jeanneboyarsky var csvPath = createAndGetFile(CSV_DATA); try (var csvWriter = Files.newBufferedWriter(csvPath);
var csvPrinter = new CSVPrinter(csvWriter, CSVFormat.DEFAULT)); { } (10) 34
@jeanneboyarsky Map<Integer, String> productMap1 = new HashMap<Integer, String>(); Map<Integer, String>
productMap2 = new HashMap<>(); var productMap3 = new HashMap<Integer, String>(); (10) 35
@jeanneboyarsky Where can we use? var name = "Jeanne"; var
other = name + 2; var list = List.of(1, 2, 3); for (var num : list) {} (10) 36
@jeanneboyarsky Where can’t we use? class Inner { var bad
= "abc"; } var noGood; noGood = 4; • Also instance variables, etc (10) 37
@jeanneboyarsky Does this work? var var = "var"; (10) 38
@jeanneboyarsky (10) Pros Cons Less typing Loss of information Less
redundancy Variable names matter more Can scan variable names Be careful! 39 http://openjdk.java.net/projects/amber/LVTIstyle.html
@jeanneboyarsky Lambdas Predicate<String> pred1 = p -> true; Predicate<String> pred2
= (String p) -> true; Predicate<String> pred3 = (var p) -> true; (11) 40
@jeanneboyarsky Annotations BiPredicate< Map<Integer, String>, List<String>> func = (@NotNull var
map, var list) -> true; (11) 41
@jeanneboyarsky All or nothing Good (var map, var list) ->
true No good (var map, list) -> true (var map, List list) -> true (11) 42
@jeanneboyarsky GARBAGE COLLECTION (10/11) 43
@jeanneboyarsky Choose your own GC • Who cares? • Agile.
With releases every 6 months, features are smaller (10) 44
@jeanneboyarsky Faster Default GC Java 8 Parallel Garbage Collector Java
9 G1 GC Java 10 + 11 G1 GC with parallel implementation (10) For more, see https://speakerdeck.com/cguntur/garbage- collection-in-java-9 45
@jeanneboyarsky Regions & space vs speed (10) For more, see
https://speakerdeck.com/cguntur 46
@jeanneboyarsky Epsilon GC (11) • Never reclaims memory • Program
proceeds until run out of heap • GC never runs • To use: • -XX:+UseEpsilonGC • (or) -XX:+UseNoGC 47
@jeanneboyarsky Epsilon GC Good for (11) • Performance/memory stress test
• Very short programs • Last ditch performance improvements (this probably isn’t you) 48
@jeanneboyarsky Z GC (11) • Experimental • 10ms or less
pause time • Only for Linux/x64 • To use, enable both: • -XX:+UnlockExperimentalVMOptions • -XX:+UseZGC 49
@jeanneboyarsky HTTP CLIENT (11) I’m done incubating! 50
@jeanneboyarsky (11) var uri = "http://www.google.com"; var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder() .uri(URI.create(uri)) .build(); var response = client.send(request, BodyHandlers.ofString()); System.out.println(response.body()); 51
@jeanneboyarsky (11) var client = HttpClient.newHttpClient(); var requests = uris.stream()
.map(HttpRequest::newBuilder) .map(reqBuilder -> reqBuilder.build()) .collect(toList()); CompletableFuture.allOf(requests.stream() .map(r->client.sendAsync(r, ofString())) .toArray(CompletableFuture<?>[]::new)) .join(); 52
@jeanneboyarsky Other APIs • BodyHandlers – file, inputstream, string, discarding
• Request Builder Options – Header, proxy, authenticator, http protocol version • Methods – get/post/put/delete (11) 53
@jeanneboyarsky TIME BASED VERSIONING (10) 54
@jeanneboyarsky String javaVersion = System.getProperty("java.version"); Runtime.Version version = Runtime.Version.parse(javaVersion); System.out.println(javaVersion
+ ": " + version.feature() + " " + version.interim() + " " + version.update() + " " + version.patch()); (10) 55
@jeanneboyarsky (10) 10.0.1 11-ea [deprecated] major() 10 11 [deprecated] minor()
0 0 [deprecated] security() 1 0 56
@jeanneboyarsky (10) 10.0.1 11-ea feature() 10 11 interim() 0 0
update() 1 0 patch() 0 0 57
@jeanneboyarsky (10) Updates Examples feature() Every 6 months 10, 11,
12 interim() n/a for Open JDK 0 update() Within 6 months 0, 1, 2 patch() Emergencies 0, 1, 2 58
@jeanneboyarsky System.out.println( System.getProperty("java.version.date")); (10) 10.0.1 11-ea 2018-04-17 2018-09-25 Yes, the
future! 59
@jeanneboyarsky System.out.println( System.getProperty("java.version.version")); • Null for Open JDK • For
vendor use (10) Yes, version is here twice! 60
@jeanneboyarsky ODDS AND ENDS 61
@jeanneboyarsky New java launcher mode Full command Shorthand javac HelloWorld.java
java HelloWorld java HelloWorld.java Produces class file Fully in memory For any program For programs with one class (11) 62
@jeanneboyarsky Unmodifiable Collections (10) 63 Copying another Terminal operations List.copyOf
Collectors.toUnmodifiableList Set.copyOf Collectors.toUnmodifiableSet Map.copyOf Collectors.toUnmodifiableMap
@jeanneboyarsky Behind the Scenes • Nest based access control •
Remove hack for private access in nested classes • Pay off tech debt (11) 64
@jeanneboyarsky JDK Java EE/Corba Modules Java 9 Java 11 (11)
65
@jeanneboyarsky Pack200 Tools Java 11 à Use jlink to compress packages
(11) 66
@jeanneboyarsky Nashorn Java 11 • Challenging to maintain • Unclear
adoption • May be adopted • Made it into Java 11 two days before cutoff (11) 67
@jeanneboyarsky Unicode 9 and 10 Support Languages + emoji (10+11)
68
@jeanneboyarsky Tying it all together (10+11) 69 import java.nio.charset.*; public
class Unicode { public static void main(String... args) { System.out.print("Have a \uD83C\uDF7A"); System.out.println(" or a \uD83E\uDD64"); } }