Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Keeping Up with Java: Look at All These New Features!

145 visualizaciones

Publicado el

SpringOne Platform 2019
Session Title: Keeping Up with Java: Look at All These New Features!
Speaker: Gil Tene, CTO, Azul Systems
Youtube: https://youtu.be/6gNF2W-1REw

Publicado en: Software
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí

Keeping Up with Java: Look at All These New Features!

  1. 1. © Copyright Azul Systems 2019 © Copyright Azul Systems 2015 @giltene Keeping Up with Java: Look at All These New Features! Gil Tene CTO, Azul Systems 1
  2. 2. © Copyright Azul Systems 2019 © Copyright Azul Systems 2015 @giltene From JDK 9 To 13 And Beyond Gil Tene CTO, Azul Systems 2
  3. 3. © Copyright Azul Systems 2019 © Copyright Azul Systems 2015 @giltene Java After 8 Gil Tene 3
  4. 4. © Copyright Azul Systems 2019 © Copyright Azul Systems 2015 @giltene Java After 8 Gil Tene CTO, Azul Systems 4
  5. 5. © Copyright Azul Systems 2019 Changes…  Java 6 2006 (December)  Java 7 2011 (July)  Java 8 2014 (March)  Java 9 2017 (September)  Java 10 2018 (18.3)  Java 11 2018 (18.9)  Java 12 2019 (19.3)  Java 13 2019 (19.9)  Java 14 2020 (20.3) … 5
  6. 6. © Copyright Azul Systems 2019 Java version timeline 6
  7. 7. © Copyright Azul Systems 2019 Coming up to speed  “Current” Java is 13, or 11 – Depending on who you talk to  Consider changes from your “current” version  For most of you, that’s Java 8  So need to go over Java 9, 10, 11, 12, 13,… 7
  8. 8. © Copyright Azul Systems 2019 Changes…  Java the language (“Java 13”) – the syntax, the meaning  Java SE the platform (“Java 13”, “JDK 13”, “Java SE 13”) – specified APIs, packages, behaviour  OpenJDK: an implementation (“OpenJDK 13”) – under the hood stuff – garbage collectors, CDS, … 8
  9. 9. © Copyright Azul Systems 2019 JDK 9: Big And Small Changes 9
  10. 10. © Copyright Azul Systems 2019 Java Platform Module System (JPMS)  The core Java libraries are now a set of modules (JEP 220) – 75 OpenJDK modules:  24 Java SE  2 aggregator modules  1 smartcard (???)  48 JDK  Most internal APIs now encapsulated (JEP 260) – sun.misc.Unsafe – Some can be used with command line options 10
  11. 11. © Copyright Azul Systems 2019 jlink: The Java Linker (JEP 282) $ jlink --module-path $JDKMODS:$MYMODS --addmods com.azul.zapp –-output myimage $ myimage/bin/java –-list-modules java.base@9 java.logging@9 java.sql@9 java.xml@9 com.azul.zapp@1.0 com.azul.zoop@1.0 com.azul.zeta@1.0 myimage …confbin jlink lib
  12. 12. © Copyright Azul Systems 2019 JDK 9: The Clean Up Starts  JDK 9 was a significant change for Java – Deprecated APIs were removed for the first time  Six methods and one class  JDK 10 removed 1 package, 6 classes, 9 methods and 1 field – Parts of the platform were removed for the first time  The entire java.se.ee aggregator module was “hidden” in JDK 9  And completely removed in JDK 11  JDK 10, 11, 12, 13, 14… continue this work  More features will be removed in the future  CMS GC, Nashorn and Pack200 all deprecated. Others? 12
  13. 13. © Copyright Azul Systems 2019 JDK 9 Onwards And Compatibility 13 "Clean applications that just depend on java.se should just work" - Oracle • Note careful spelling of “java.se” • ”java.se” refers to an aggregator module in JDK 9+ • Java SE 8 parts are absolutely being removed
  14. 14. © Copyright Azul Systems 2019 Platform parts removed – The java.se.ee aggregator-module  java.corba  java.transaction  java.activation  java.xml.bind  java.xml.ws  java.xml.ws.annotation 14
  15. 15. © Copyright Azul Systems 2019 Compatibility Not Guaranteed  New versions of Java may include breaking changes – Anything for removal will be deprecated first – Minimum of one release warning  Could be only six months 15
  16. 16. © Copyright Azul Systems 2019 JDK 10
  17. 17. © Copyright Azul Systems 2019 Local Variable Type Inference (JEP 286)  Java gets var 17 var userList = new ArrayList<String>(); // infers ArrayList<String> var stream = list.stream(); // infers Stream<String> for (var name : userList) { // infers String ... } for (var i = 0; i < 10; i++) { // infers int ... }
  18. 18. © Copyright Azul Systems 2019 var: Clearer try-with-resources 18 try (InputStream inputStream = socket.getInputStream(); InputStreamReader inputStreamReader = new InputStreamReader(inputStream, UTF_8); BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { // Use bufferedReader }
  19. 19. © Copyright Azul Systems 2019 var: Clearer try-with-resources 19 try (var inputStream = socket.getInputStream(); var inputStreamReader = new InputStreamReader(inputStream, UTF_8); var bufferedReader = new BufferedReader(inputStreamReader)) { // Use bufferedReader }
  20. 20. © Copyright Azul Systems 2019 var: Reserved Type (Not Keyword) var var = new ValueAddedReseller(); public class var { public var(String x) { ... } } public class Var { public Var(String x) { ... } }
  21. 21. © Copyright Azul Systems 2019 JDK 10: Selected JEPs  JEP 286: Local-Variable Type Inference  JEP 307: Parallel Full GC for G1  JEP 310: Application Class-Data Sharing  JEP 317: Experimental Java-based JIT compiler (Graal)  JEP 316: Heap allocation on alternative devices (Intel)  JEP 312: Thread-local Handshakes 21
  22. 22. © Copyright Azul Systems 2019 JDK 10: APIs  73 New APIs – List, Set, Map.copyOf(Collection) – Collectors  toUnmodifiableList  toUnmodifiableMap  toUnmodifiableSet – Optional.orElseThrow() 22
  23. 23. © Copyright Azul Systems 2019 JDK 11
  24. 24. © Copyright Azul Systems 2019 323: Extend Local-Variable Syntax  Local-variable syntax for lambda parameters 24 list.stream() .map(s -> s.toLowerCase()) .collect(Collectors.toList()); list.stream() .map((var s) -> s.toLowerCase()) .collect(Collectors.toList()); list.stream() .map((@Notnull var s) -> s.toLowerCase()) .collect(Collectors.toList());
  25. 25. © Copyright Azul Systems 2019 330: Launch Single File Source Code  JDK 10 has three modes for the Java launcher – Launch a class file – Launch the main class of a JAR file – Launch the main class of a module  JDK 11 adds a forth – Launch a class declared in a source file 25 $ java Factorial.java 4
  26. 26. © Copyright Azul Systems 2019 Single File Source Code Shebang 26 #!$JAVA_HOME/bin/java --source 11 public class Factorial { public static void main(String[] args) { int n = Integer.parseInt(args[0]); int r = (n == 0) ? 0 : 1; for (int i = 1; i <= n; i++) r *= i; System.out.println("n = " + n + ", n! = " + r); } } $ ./Factorial 4 n = 4, n! = 24
  27. 27. © Copyright Azul Systems 2019 JDK 11 Selected JEPs  181: Nest-based Access Control  309: Dynamic Class-file constants  321: HTTP client  332: Transport Layer Security (TLS) 1.3  333: ZGC: Experimental low-latency garbage collector  318: Epsilon garbage collector 27
  28. 28. © Copyright Azul Systems 2019 New APIs  New I/O methods  InputStream nullInputStream()  OutputStream nullOutputStream()  Reader nullReader()  Writer nullWriter()  Optional  isEmpty() // Opposite of isPresent 28
  29. 29. © Copyright Azul Systems 2019 New APIs  New String methods – isBlank() – Stream lines() – String repeat(int) – String strip() – String stripLeading() – String stripTrailing() 29
  30. 30. © Copyright Azul Systems 2019 New APIs  Predicate not(Predicate) 30 lines.stream() .filter(s -> !s.isBlank()) lines.stream() .filter(Predicate.not(String::isBlank)) lines.stream() .filter(not(String::isBlank))
  31. 31. © Copyright Azul Systems 2019 JDK 11: Modules Removed – The java.se.ee aggregator-module has been removed  java.corba  java.transaction  java.activation  java.xml.bind  java.xml.ws  java.xml.ws.annotation 31
  32. 32. © Copyright Azul Systems 2019 JDK 12
  33. 33. © Copyright Azul Systems 2019 Switch Expressions  First preview feature in the OpenJDK – Not included in the Java SE standard – Preview features require use of ––enable–preview flag  Switch construct was a statement – No concept of generating a result that could be assigned  Rather clunky syntax – Every case statement needs to be separated – Must remember break (default is to fall through) – Scope of local variables is not intuitive 33
  34. 34. © Copyright Azul Systems 2019 Old-Style Switch Statement 34 int numLetters; switch (day) { case MONDAY: case FRIDAY: case SUNDAY: numLetters = 6; break; case TUESDAY: numLetters = 7; break; case THURSDAY: case SATURDAY: numLetters = 8; break; case WEDNESDAY: numLetters = 9; break; default: throw new IllegalStateException("Huh?: " + day); };
  35. 35. © Copyright Azul Systems 2019 New-Style Switch Expression int numLetters = switch (day) { case MONDAY, FRIDAY, SUNDAY -> 6; case TUESDAY -> 7; case THURSDAY, SATURDAY -> 8; case WEDNESDAY -> 9; default -> throw new IllegalStateException("Huh?: " + day); };
  36. 36. © Copyright Azul Systems 2019 New Old-Style Switch Expression int numLetters = switch (day) { case MONDAY: case FRIDAY: case SUNDAY: break 6; case TUESDAY break 7; case THURSDAY case SATURDAY break 8; case WEDNESDAY break 9; default: throw new IllegalStateException("Huh?: " + day); };
  37. 37. © Copyright Azul Systems 2019 Switch Expression: Code Blocks 37 int levelResult = switch (level) { case 1 -> { var x = computeFrom(level); logger.info("Level 1 alert"); break x; } case 2 -> { var x = negativeComputeFrom(level); logger.info("Level 2 alert"); break x; } default -> throw new IllegalStateException("What level?: " + level); };
  38. 38. © Copyright Azul Systems 2019 JDK 12: Selected JEPs  189: Shenandoah GC (Experimental)  G1 GC updates – 344: Abortable mixed collections – 346: Return unused committed memory  334: JVM constant API  341: Default CDS archive
  39. 39. © Copyright Azul Systems 2019 Streams  New collector, teeing – teeing(Collector, Collector, BiFunction)  Collect a stream using two collectors  Use a BiFunction to merge the two collections 39 Collector 1 Collector 2 BiFunction Stream Result
  40. 40. © Copyright Azul Systems 2019 Streams 40 // Averaging Double average = Stream.of(1, 4, 5, 2, 1, 7) .collect(teeing(summingDouble(i -> i), counting(), (sum, n) -> sum / n));
  41. 41. © Copyright Azul Systems 2019 JDK 13
  42. 42. © Copyright Azul Systems 2019 Text Blocks String webPage = """ <html> <body> <p>My web page</p> </body> </html> """; System.out.println(webPage); $ java WebPage <html> <body> <p>My web page</p> </body> </html> $
  43. 43. © Copyright Azul Systems 2019 Switch Expression int numLetters = switch (day) { case MONDAY: case FRIDAY: case SUNDAY: break 6; case TUESDAY break 7; case THURSDAY case SATURDAY break 8; case WEDNESDAY break 9; default: throw new IllegalStateException("Huh?: " + day); };
  44. 44. © Copyright Azul Systems 2019 Switch Expression (still a preview feature) int numLetters = switch (day) { case MONDAY: case FRIDAY: case SUNDAY: yield 6; case TUESDAY yield 7; case THURSDAY case SATURDAY yield 8; case WEDNESDAY yield 9; default: throw new IllegalStateException("Huh?: " + day); };
  45. 45. © Copyright Azul Systems 2019 Switch Expressions int numLetters = switch (day) { case MONDAY, FRIDAY, SUNDAY -> 6; case TUESDAY -> 7; case THURSDAY, SATURDAY -> 8; case WEDNESDAY -> 9; default -> throw new IllegalStateException("Huh?: " + day); };
  46. 46. © Copyright Azul Systems 2019 JDK 13: Selected JEPs  JEP-354: Switch Expressions (Preview)  JEP-355: Text Blocks (Preview)  JEP-350: Dynamic CDS Archives  JEP-351: ZGC (Experimental): Uncommit Unused Memory  JEP-353: Reimplement the Legacy Socket API
  47. 47. © Copyright Azul Systems 2019 Longer Term JDK Futures
  48. 48. © Copyright Azul Systems 2019 Project Valhalla  Java has: – Primitives: for performance – Objects: for encapsulation, polymorphism, inheritance, OO  Problem is where we want to use primitives but can't – ArrayList<int> won't work – ArrayList<Integer> requires boxing and unboxing, object creation, heap overhead, indirection reference 48
  49. 49. © Copyright Azul Systems 2019 Project Valhalla  Value types  "Codes like a class, works like a primitive" – Can have methods and fields – Can implement interfaces – Can use encapsulation – Can be generic – Can't be mutated – Can't be sub-classed 49
  50. 50. © Copyright Azul Systems 2019 Project Loom  Further work on making concurrent programming simpler – Threads are too heavyweight  Loom will introduce fibres – JVM level threads (remember green threads?) – Add continuations to the JVM – Use the ForkJoinPool scheduler – Much lighter weight than threads  Less memory  Close to zero overhead for task switching 50
  51. 51. © Copyright Azul Systems 2019 Zulu Community  OpenJDK is a source code project  Any binary you run comes from some sort of distro  Many distros of OpenJDK out there – Some are well built and well tested – Other are…. Ahem.. Not so much. – E.g. “Mystery meat OpenJDK builds strike again” – Zulu, Corretto, Dragonwell, Liberica, Adopt, etc. etc. etc. – You have plenty of choice…
  52. 52. © Copyright Azul Systems 2019 Zulu Community
  53. 53. © Copyright Azul Systems 2019 Zulu  A FREE, 100% OSS community distribution of OpenJDK – Certified Java SE compliant, TCK tested, etc.  JDK 6*, 7, 8, 9, 10, 11, 12, 13, …  Curated distribution – Wide platform support:  Intel 64-bit & 32-bit Windows, Mac, Linux  ARM 32-bit and 64-bit – JFR (Java Flight Recorder) and TLS 1.3 support in JDK 8 – JDK, JRE, JDK+FX, … 53www.zulu.org
  54. 54. © Copyright Azul Systems 2019 Zulu Community MTS
  55. 55. © Copyright Azul Systems 2019 The need for version overlap  Major Java releases take time to stabilize post GA – huge number of bugs are detected via (post-GA) early adopter exposure – Java 8 fixed 1,926 bugs in first 17 months – (1,213 between 6 months and 18 months past GA)  Production use remains on previous version – until newly GA’ed version matures  Production version needs updates during overlap period – security updates, critical fixes, etc. 55
  56. 56. © Copyright Azul Systems 2019 Java lifecycle: historic al view 56
  57. 57. © Copyright Azul Systems 2019 Java version timeline 57
  58. 58. © Copyright Azul Systems 2019 Zulu LTS Releases Prior Zulu Roadmap: LTS
  59. 59. © Copyright Azul Systems 2019 Zulu MTS Releases Zulu LTS Releases Zulu Roadmap: LTS and MTS
  60. 60. © Copyright Azul Systems 2019 Zulu Enterprise  Zulu with commercial support  Releases (LTS, MTS, updates) fit for long term production use  Timely updates and security fixes (CPU, PSU, etc.)  Includes indemnification, non-Contamination, etc.  Used widely across multiple industries 60
  61. 61. © Copyright Azul Systems 2019 Select Azul Customers
  62. 62. © Copyright Azul Systems 2019 Zulu 7, 8, 11, and 13 Azure Spring Cloud
  63. 63. © Copyright Azul Systems 2019 Zulu Enterprise  Zulu with commercial support  Releases (LTS, MTS, updates) fit for long term production use  Timely updates and security fixes (CPU, PSU, etc.)  Includes indemnification, non-Contamination, etc.  Used widely across multiple industries  Java 6, 7, 8, 11, 13, …  24x7 support 63
  64. 64. © Copyright Azul Systems 2019 Summary MTS LTS8 10 9 11 12 17 13 15.. LTS LTS ..
  65. 65. © Copyright Azul Systems 2019 © Copyright Azul Systems 2015 @giltene Gil Tene CTO, Azul Systems 65

×