Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Geektastic Connect: Neues von Java und dem JDK

Geektastic Connect: Neues von Java und dem JDK

Durch die Verkürzung des Release-Zyklus von Java und dem JDK auf nur noch sechs Monate erscheinen nun zwei Major-Releases pro Jahr. Hierdurch ist es schwer geworden den Überblick über all die neuen Features, Diskussionen und Ideen zu behalten. Im Fokus dieses Vortags stehen deswegen die Entwicklungen und Neuerungen des letzten Jahres, also Java 11 und 12. Daneben werden auch die Planungen für Java 13 und weitere relevante Themen und Diskussionen rund um das JDK vorgestellt.

Michael Vitz

July 17, 2019
Tweet

More Decks by Michael Vitz

Other Decks in Programming

Transcript

  1. 2019-07-17
 Düsseldorf / Geektastic Connect Neues von Java
 und dem

    JDK Michael Vitz https://pixabay.com/en/coffee-beans-blue-red-caffeine-1599262/ @michaelvitz
  2. Michael Vitz
 Senior Consultant at INNOQ • Build, run, and

    maintain JVM applications • JavaSPEKTRUM column owner • ❤ Clojure
  3. www.innoq.com OFFICES Monheim Berlin Hamburg Offenbach Munich Zurich FACTS ~125

    employees Privately owned Vendor-independent SERVICES Strategy & technology consulting Digital business models Software architecture & development Digital platforms & infrastructures Knowledge transfer, coaching & trainings CLIENTS Finance Telecommunications Logistics E-commerce Fortune 500 SMBs Startups
  4. JEP 286: Local-Variable Type Inference var Cheat Sheet: https://snyk.io/blog/local-type-inference-java-cheat-sheet/ Style

    Guidelines: http://openjdk.java.net/projects/amber/LVTIstyle.html http://openjdk.java.net/jeps/286
  5. More small enhancements • @summary • • List#copyOf, Map#copyOf, Set#copyOf

    • Collectors#toUnmodifiableList/Set/Map • Optional::orElseThrow https://bugs.openjdk.java.net/browse/JDK-8173425 https://bugs.openjdk.java.net/browse/JDK-8146115 https://bugs.openjdk.java.net/browse/JDK-8177290 https://bugs.openjdk.java.net/browse/JDK-8184690 https://bugs.openjdk.java.net/browse/JDK-8140281
  6. JEP 321: HTTP Client http://openjdk.java.net/jeps/321 HttpClient client = HttpClient.newHttpClient(); HttpRequest

    request = HttpRequest.newBuilder() .uri(URI.create("http://openjdk.java.net/")) .build(); client.sendAsync(request, ofString()) .thenApply(HttpResponse::body) .thenAccept(System.out::println) .join(); http://openjdk.java.net/groups/net/httpclient/intro.html
  7. (var x) -> process(x) JEP 323: Local-Variable Syntax for Lambda

    Parameters http://openjdk.java.net/jeps/323 (@Nonnull
  8. java.lang.String • String::repeat(int) • String::lines • String::strip, String::stripLeading, String::stripTrailing •

    String::isBlank https://bugs.openjdk.java.net/browse/JDK-8197594 https://bugs.openjdk.java.net/browse/JDK-8200380 https://bugs.openjdk.java.net/browse/JDK-8200377 https://bugs.openjdk.java.net/browse/JDK-8200436
  9. java.nio.file.Files/Path • Files#isSameContent • Files#readString, Files#writeString • Path#of(URI), Path#of(String, String…)

    https://bugs.openjdk.java.net/browse/JDK-8202302 https://bugs.openjdk.java.net/browse/JDK-8202055 https://bugs.openjdk.java.net/browse/JDK-8199485
  10. JEP 325: Switch Expressions (Preview) http://openjdk.java.net/jeps/325 int numLetters = switch

    (day) { case MONDAY, FRIDAY, SUNDAY -> { System.out.println("Whoop"); break 6; } case TUESDAY -> 7; case THURSDAY, SATURDAY -> 8; case WEDNESDAY -> 9; }; Preview-Features article: https://blog.codefx.org/java/enable-preview-features/
  11. API Changes • {@systemProperty} • Files#mismatch(Path, Path) • Collectors#teeing(Collector, Collector,

    BiFunction) https://bugs.openjdk.java.net/browse/JDK-5076751 https://bugs.openjdk.java.net/browse/JDK-8202302 https://bugs.openjdk.java.net/browse/JDK-8209685
  12. JEP 354: Switch Expressions (Preview) http://openjdk.java.net/jeps/354 int numLetters = switch

    (day) { case MONDAY, FRIDAY, SUNDAY -> { System.out.println("Whoop"); yield 6; } case TUESDAY -> 7; case THURSDAY, SATURDAY -> 8; case WEDNESDAY -> 9; };
  13. JEP 355: Text Blocks (Preview) https://openjdk.java.net/jeps/355 String html = """

    <html> <body> <p>Hello, world</p> </body> </html> """; Detailed article: https://blog.codefx.org/java/text-blocks/
  14. More small enhancements • Deprecate -Xverify:none option • String::formatted •

    String::stripIndent • String::translateEscapes • Provide VM.events diagnostic command https://bugs.openjdk.java.net/browse/JDK-8214719 https://bugs.openjdk.java.net/browse/JDK-8203444 https://bugs.openjdk.java.net/browse/JDK-8223775 https://bugs.openjdk.java.net/browse/JDK-8223780 https://bugs.openjdk.java.net/browse/JDK-8224601
  15. JEP 305: Pattern Matching for instanceof (Preview) http://openjdk.java.net/jeps/305 if (obj

    instanceof String s) { // can use s here } else { // can't use s here } @Override public boolean equals(Object o) { return (o instanceof CaseInsensitiveString cis) && cis.s.equalsIgnoreCase(s); }
  16. JEP draft 8213076: Pattern matching for switch (Preview) https://openjdk.java.net/jeps/8213076 String

    formatted; switch (obj) { case Integer i: formatted = String.format("int %d", i); break; case Byte b: formatted = String.format("byte %d", b); break; case Long l: formatted = String.format("long %d", l); break; case Double d: formatted = String.format("double %f", l); break; case String s: formatted = String.format("String %s", s); break; default: formatted = obj.toString(); }
  17. JEP draft 8209434: Concise Method Bodies http://openjdk.java.net/jeps/8209434 // -> is

    "single expression form" int length(String s) -> s.length(); // = is "method reference form" int length(String s) = String::length;
  18. www.innoq.com innoQ Deutschland GmbH Krischerstr. 100 40789 Monheim am Rhein

    Germany +49 2173 3366-0 Ohlauer Str. 43 10999 Berlin Germany +49 2173 3366-0 Ludwigstr. 180E 63067 Offenbach Germany +49 2173 3366-0 Kreuzstr. 16 80331 München Germany +49 2173 3366-0 innoQ Schweiz GmbH Gewerbestr. 11 CH-6330 Cham Switzerland +41 41 743 0116 Thanks! Questions? Michael Vitz [email protected] michaelvitz +49 151 19116015 https://www.innoq.com/en/talks/2019/07/geektastic-düsseldorf-juli-2019-neues-von-java-und-jdk/