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

2018-Philly-Jug-Java-11.pdf

Jeanne Boyarsky
December 11, 2018
450

 2018-Philly-Jug-Java-11.pdf

Jeanne Boyarsky

December 11, 2018
Tweet

Transcript

  1. @jeanneboyarsky
    Java 11 – Keeping the Java Release
    Train on the Right Track
    speakerdeck.com/boyarsky
    Jeanne Boyarsky
    Philly JUG – December 11, 2018

    View full-size slide

  2. @jeanneboyarsky
    Martijn Verberg (JClarity)
    Simon Ritter (Azul)
    Steve Poole & Tim Ellison (IBM)
    Simon Maple (LJC)
    Trisha Gee (JetBrains)
    Roman Kennke (Red Hat)
    Thank you to…

    View full-size slide

  3. @jeanneboyarsky
    So much
    changed
    since Java 9
    & Jigsaw’s
    release!
    3

    View full-size slide

  4. @jeanneboyarsky 4

    View full-size slide

  5. @jeanneboyarsky
    For more on Java 9, see:
    https://speakerdeck.com/
    boyarsky
    5

    View full-size slide

  6. @jeanneboyarsky
    Topics:
    •  Ecosystem
    changes
    •  VMs
    •  Language
    changes
    6

    View full-size slide

  7. @jeanneboyarsky
    About Me
    16 years as
    Java Developer
    Note where
    I don’t work!
    7

    View full-size slide

  8. @jeanneboyarsky
    Memories!
    8

    View full-size slide

  9. @jeanneboyarsky
    Til
    Java 6
    (1996-
    2006)
    Hi
    Oracle
    (2010)
    Java 7
    (2011)
    Java 8
    (2014)
    Java 9
    (2017)
    9

    View full-size slide

  10. @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
    10

    View full-size slide

  11. @jeanneboyarsky
    Java 9 “Release” Dates
    •  Sept 2016
    •  May 2017
    •  July 2017
    •  Sept 2017
    11

    View full-size slide

  12. @jeanneboyarsky
    Counting lessons?
    •  1.0, 1.1, 1.2, 1.3, 1.4
    •  5.0
    •  6, 7, 8, 9, 10, 11
    12

    View full-size slide

  13. @jeanneboyarsky
    Advanced counting lessons
    •  10 = 2018.3
    •  11 = 2018.9
    •  12 = ?
    13

    View full-size slide

  14. @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
    14

    View full-size slide

  15. @jeanneboyarsky
    Java School
    Report Card
    Developer
    Community
    à A
    Features
    à B
    Frequency of
    Release
    à F
    Predictability
    of Release
    à D
    15

    View full-size slide

  16. @jeanneboyarsky
    JVM College
    Report Card
    Vocabulary
    à B
    Polyglot
    programming
    à A
    Frequency of
    Release
    à F
    Predictability
    of Release
    à D
    16

    View full-size slide

  17. @jeanneboyarsky
    Re-org at
    the train
    station
    17

    View full-size slide

  18. @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
    18

    View full-size slide

  19. @jeanneboyarsky
    Before Now
    19

    View full-size slide

  20. @jeanneboyarsky
    Before Now
    20

    View full-size slide

  21. @jeanneboyarsky
    Before Now
    Releases
    every
    Varies 6 months
    (or 3 years
    LTS)
    Releases are Feature
    driven
    Date driven
    Oracle/OpenJDK Communications

    View full-size slide

  22. @jeanneboyarsky
    Patches Ask vendor a
    question
    What is Long Term Support?
    Oracle defined as 3 years. Other
    vendors (mostly) following definition.

    View full-size slide

  23. @jeanneboyarsky
    More time to
    code while I wait
    for the next train!
    23

    View full-size slide

  24. @jeanneboyarsky
    Oracle/OpenJDK
    Arrivals Train Schedule
    Java Release Date Long Term
    Support
    9 September 21, 2017
    10 March 20, 2018
    11 September 25, 2018
    T
    h
    e
    i
    24

    View full-size slide

  25. @jeanneboyarsky
    Oracle Security Patches Departure
    Schedule
    Java Public Patches Paid Patches
    6 2013 Late 2018
    7 2015 2022
    8 January 2019 (business)
    December 2020 (public)
    2025
    25

    View full-size slide

  26. @jeanneboyarsky
    Oracle/OpenJDK
    Security Patches Departure Schedule
    Java Public patches Paid patches
    9 March 2018 n/a
    10 September 2018 n/a
    11 March 2019 2023-2028
    26

    View full-size slide

  27. @jeanneboyarsky
    Looking at that another way
    Once Java 12 comes out, what does
    Oracle issue patches for?
    Open JDK 12
    Oracle Java 11 (Paid)
    27

    View full-size slide

  28. @jeanneboyarsky
    Wait. So what happens next?
    How long will Java 12 have Oracle patches?
    Answer: 6 months
    What is the next LTS version
    after Java 11?
    Java 11 + 3*2 = 17
    28

    View full-size slide

  29. @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
    29
    Note: Oracle also publishes Open JDK 6 months for dev; not EA

    View full-size slide

  30. @jeanneboyarsky
    Converged Binaries
    30

    View full-size slide

  31. @jeanneboyarsky
    Found it!
    31
    Some closed-source parts of the Oracle JDK will
    be open-sourced
    •  Flight recorder
    •  Mission control
    •  Others

    View full-size slide

  32. @jeanneboyarsky
    Where did it go?
    32
    Other closed-source parts will be removed
    •  Browser Plugin
    •  Java Web Start
    •  JavaFX (Lives on as OpenJFX)

    View full-size slide

  33. @jeanneboyarsky
    FUD quiz #1
    There will be a LTS release every 3 years. How
    long for free updates?
    6 months
    33

    View full-size slide

  34. @jeanneboyarsky
    FUD quiz #2
    Which of these require a paid license to Oracle?
    •  Open JDK 11
    •  Oracle JDK 11
    Oracle JDK 11
    34

    View full-size slide

  35. @jeanneboyarsky
    FUD quiz #3
    How long can Oracle JDK 8 be used in Prod for
    free?
    Forever (but no security patches)
    35

    View full-size slide

  36. @jeanneboyarsky
    FUD quiz #4
    How long will Oracle contribute to Open JDK for
    each release?
    6 months
    36

    View full-size slide

  37. @jeanneboyarsky
    FUD quiz #5
    How long will Oracle backport updates and security
    patches?
    0 months
    37

    View full-size slide

  38. @jeanneboyarsky
    FUD quiz #6
    Is anyone backporting updates and security
    patches?
    RedHat
    38

    View full-size slide

  39. @jeanneboyarsky
    FUD quiz #7
    Is it enough to pass the TCK (Technology
    Compatibility Kit) to be Java SE?
    No. If vendor doesn’t pay Oracle, “Java SE
    Compatible”
    39

    View full-size slide

  40. @jeanneboyarsky
    Vendor JDKs
    •  Vulnerability Security Group
    •  Backporting – non trivial
    •  Features removed
    •  What is a bug/security patch/enhancement
    40

    View full-size slide

  41. @jeanneboyarsky 41
    Java 8 LTS March 2026
    Java 11 LTS Sept 2027
    Java 13 MTS March 2023
    Java 15 MTS March 2023
    Java 17 LTS Sept 2030
    All others Free 6 months
    Azul Zulu

    View full-size slide

  42. @jeanneboyarsky 42
    Java 8 Free Updates – Adopt OpenJDK
    Paid support - IBM
    March 2023+
    Java 11 Free updates – Adopt OpenJDK
    Paid support - IBM
    Sept 2022+
    All
    others
    Free updates – Adopt OpenJDK 6 months
    Adopt OpenJDK + IBM
    + means support as long as source maintained

    View full-size slide

  43. @jeanneboyarsky 43
    RedHat -> IBM
    •  Java 8, 9, 10 still available
    •  Java 8 and 11 supported
    •  Will maintain OpenJDK after Oracle support
    ends
    •  IBM keeping RedHat somewhat independent?

    View full-size slide

  44. @jeanneboyarsky 44
    Others
    •  SAP distributes Java 10 + 11
    Don’t be sad if your favorite JDK is missing. Just
    examples!

    View full-size slide

  45. @jeanneboyarsky 45
    Mark’s slide - OracleCode One keynote

    View full-size slide

  46. @jeanneboyarsky
    Get ready to play
    46

    View full-size slide

  47. @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
    47

    View full-size slide

  48. @jeanneboyarsky
    LOCAL VARIABLE SYNTAX
    (10/11)
    48

    View full-size slide

  49. @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)
    49

    View full-size slide

  50. @jeanneboyarsky
    var name = "Jeanne";
    String name2 = name;
    •  Compiled code same with var
    (10)
    50

    View full-size slide

  51. @jeanneboyarsky
    List 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)
    51

    View full-size slide

  52. @jeanneboyarsky
    var csvPath = createAndGetFile(CSV_DATA);
    try (var csvWriter =
    Files.newBufferedWriter(csvPath);
    var csvPrinter = new
    CSVPrinter(csvWriter,
    CSVFormat.DEFAULT)); {
    }
    (10)
    52

    View full-size slide

  53. @jeanneboyarsky
    Map productMap1
    = new HashMap();
    Map productMap2
    = new HashMap<>();
    var productMap3
    = new HashMap();
    (10)
    53

    View full-size slide

  54. @jeanneboyarsky
    Where can we use?
    var name = "Jeanne";
    var other = name + 2;
    var list = List.of(1, 2, 3);
    for (var num : list) {}
    (10)
    54

    View full-size slide

  55. @jeanneboyarsky
    Where can’t we use?
    class Inner { var bad = "abc"; }
    var noGood;
    noGood = 4;
    •  Also instance variables, etc
    (10)
    55

    View full-size slide

  56. @jeanneboyarsky
    Does this work?
    var var = "var";
    (10)
    56

    View full-size slide

  57. @jeanneboyarsky
    (10)
    Pros Cons
    Less typing Loss of information
    Less redundancy Variable names matter
    more
    Can scan variable
    names
    Be careful!
    57
    http://openjdk.java.net/projects/amber/LVTIstyle.html

    View full-size slide

  58. @jeanneboyarsky
    Lambdas
    Predicate pred1
    = p -> true;
    Predicate pred2
    = (String p) -> true;
    Predicate pred3
    = (var p) -> true;
    (11)
    58

    View full-size slide

  59. @jeanneboyarsky
    Annotations
    BiPredicate<
    Map,
    List> func =
    (@NotNull var map, var list) -> true;
    (11)
    59

    View full-size slide

  60. @jeanneboyarsky
    All or nothing
    Good
    (var map, var list) -> true
    No good
    (var map, list) -> true
    (var map, List list) -> true
    (11)
    60

    View full-size slide

  61. @jeanneboyarsky
    GARBAGE COLLECTION
    (10/11)
    61

    View full-size slide

  62. @jeanneboyarsky
    Choose your own GC
    •  Who cares?
    •  Agile. With releases every 6 months, features
    are smaller
    (10)
    62

    View full-size slide

  63. @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
    63

    View full-size slide

  64. @jeanneboyarsky
    Regions & space vs speed (10)
    For more, see https://speakerdeck.com/cguntur
    64

    View full-size slide

  65. @jeanneboyarsky
    Epsilon GC (11)
    •  Never reclaims memory
    •  Program proceeds until run out of heap
    •  GC never runs
    •  To use:
    •  -XX:+UseEpsilonGC
    •  (or) -XX:+UseNoGC
    65

    View full-size slide

  66. @jeanneboyarsky
    Epsilon GC Good for (11)
    •  Performance/memory stress test
    •  Very short programs
    •  Last ditch performance improvements
    (this probably isn’t you)
    66

    View full-size slide

  67. @jeanneboyarsky
    Z GC (11)
    •  Experimental
    •  10ms or less pause time
    •  Only for Linux/x64
    •  To use, enable both:
    •  -XX:+UnlockExperimentalVMOptions
    •  -XX:+UseZGC
    67

    View full-size slide

  68. @jeanneboyarsky
    HTTP CLIENT
    (11)
    I’m done
    incubating!
    68

    View full-size slide

  69. @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());
    69

    View full-size slide

  70. @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();
    70

    View full-size slide

  71. @jeanneboyarsky
    Other APIs
    •  BodyHandlers – file, inputstream, string,
    discarding
    •  Request Builder Options – Header, proxy,
    authenticator, http protocol version
    •  Methods – get/post/put/delete
    (11)
    71

    View full-size slide

  72. @jeanneboyarsky
    TIME BASED VERSIONING
    (10)
    72

    View full-size slide

  73. @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)
    73

    View full-size slide

  74. @jeanneboyarsky
    (10)
    10.0.1 11-ea
    [deprecated]
    major()
    10 11
    [deprecated]
    minor()
    0 0
    [deprecated]
    security()
    1 0
    74

    View full-size slide

  75. @jeanneboyarsky
    (10)
    10.0.1 11-ea
    feature() 10 11
    interim() 0 0
    update() 1 0
    patch() 0 0
    75

    View full-size slide

  76. @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
    76

    View full-size slide

  77. @jeanneboyarsky
    System.out.println(
    System.getProperty("java.version.date"));
    (10)
    10.0.1 11-ea
    2018-04-17 2018-09-25
    When run in June.
    Yes, the future!
    77

    View full-size slide

  78. @jeanneboyarsky
    System.out.println(
    System.getProperty("java.version.version"));
    •  Null for Open JDK
    •  For vendor use
    (10)
    Yes, version is
    here twice!
    78

    View full-size slide

  79. @jeanneboyarsky
    ODDS AND ENDS
    79

    View full-size slide

  80. @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)
    80

    View full-size slide

  81. @jeanneboyarsky
    Unmodifiable Collections (10)
    81
    Copying another Terminal operations
    List.copyOf Collectors.toUnmodifiableList
    Set.copyOf Collectors.toUnmodifiableSet
    Map.copyOf Collectors.toUnmodifiableMap

    View full-size slide

  82. @jeanneboyarsky
    Streaming Strings (11)
    82
    String countdown = Stream.iterate(10, i-> i-1)
    .limit(10)
    .map(Object::toString)
    .collect(Collectors.joining("\n"));
    long numLines = countdown.lines().count();
    System.out.println(numLines);

    View full-size slide

  83. @jeanneboyarsky
    Behind the Scenes
    •  Nest based access control
    •  Remove hack for private access in nested
    classes
    •  Pay off tech debt
    (11)
    83

    View full-size slide

  84. @jeanneboyarsky
    JDK Java EE/Corba Modules
    Java 9 Java 11
    (11)
    84

    View full-size slide

  85. @jeanneboyarsky
    Pack200 Tools
    Java 11 à Use jlink to
    compress packages
    (11)
    85

    View full-size slide

  86. @jeanneboyarsky
    Nashorn
    Java 11 •  Challenging to maintain
    •  Unclear adoption
    •  May be adopted
    •  Made it into Java 11
    two days before cutoff
    (11)
    86

    View full-size slide

  87. @jeanneboyarsky
    Unicode 9 and 10 Support
    Languages + emoji
    (10+11)
    87

    View full-size slide

  88. @jeanneboyarsky
    Tying it all together (10+11)
    88
    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");
    }
    }

    View full-size slide

  89. @jeanneboyarsky
    No need to be
    puzzled.
    Java 11 LTS
    6 months
    New features
    Go tell your
    manager/team to
    be ready for
    September!
    89

    View full-size slide

  90. @jeanneboyarsky 90

    View full-size slide