Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Coding Your Way to Java 13

169 views

Published on

It seems like keeping up to date with Java nowadays can be a daunting task. Gone is the era of big, delayed Java releases that span years. We’re now getting a new major release every six months. What’s up with that? You’re probably still developing on Java 8, even though Java 13 is almost released already. Attend this session to get a code-first overview of what’s new in Java since Java 8. You’ll get an overview of the module system (Java 9), the local variable type inference feature (Java 10), and the new HttpClient API (Java 11), plus a sneak peek of Java 12 and 13 preview features. It’s time to embrace the newfound agility of the Java platform!

Published in: Technology
  • Be the first to comment

Coding Your Way to Java 13

  1. 1. Coding Your Way to Java 13 @Sander_Mak
  2. 2. About Sander Director of Technology @ Picnic Conference Speaker & Author
  3. 3. @Sander_Mak Java 13 (Sept. 2017)
  4. 4. @Sander_Mak Preview Feature: Text Blocks String jsonOrIsIt = "{n" + " "no": "escaping for nested strings!",n" + " "preserves_indentation?": true,n" + " "awesomeness_level": 11n" + "}";
  5. 5. @Sander_Mak Preview Feature: Text Blocks String json = """ { "no": "escaping for nested strings!", "preserves_indentation?": true, "awesomeness_level": 11 }""";
  6. 6. @Sander_Mak Java 12 (March 2019)
  7. 7. @Sander_Mak Switch Statements int numletters; switch (day) { case MONDAY: FRIDAY: SUNDAY: numletters = 6; break; case TUESDAY: numletters = 7; break; case THURSDAY: SATURDAY: numletters = 8; break; case WEDNESDAY: numletters = 9; break; }
  8. 8. @Sander_Mak Preview Feature: Switch Expression int numLetters = switch (day) { case MONDAY, FRIDAY, SUNDAY -> 6; case TUESDAY -> 7; case THURSDAY, SATURDAY -> 8; case WEDNESDAY -> 9; };
  9. 9. @Sander_Mak Java 11 (Sept. 2018)
  10. 10. @Sander_Mak HttpClient HttpURLConnection
  11. 11. @Sander_Mak HttpClient HttpURLConnection HTTP/2 & WebSocket Reactive Streams Support
  12. 12. @Sander_Mak HttpClient send sendAsync ... HttpClient
  13. 13. @Sander_Mak HttpClient send sendAsync ... HttpClient.Builder newBuilder HttpClient
  14. 14. @Sander_Mak HttpClient send sendAsync ... HttpClient.Builder HttpRequest uri headers method ...newBuilder HttpClient
  15. 15. @Sander_Mak HttpClient send sendAsync ... HttpClient.Builder HttpRequest uri headers method ... HttpRequest.Builder newBuilder newBuilder HttpClient
  16. 16. @Sander_Mak HttpClient send sendAsync ... HttpClient.Builder HttpRequest uri headers method ... HttpRequest.Builder HttpResponse uri statusCode body ...newBuilder newBuilder HttpClient
  17. 17. @Sander_Mak HttpClient HttpClient httpClient = HttpClient.newHttpClient(); HttpRequest req = HttpRequest.newBuilder(URI.create("https://google.com")) .GET() .build(); HttpResponse<String> response = httpClient.send(req, BodyHandlers.ofString())
  18. 18. @Sander_Mak Java
  19. 19. @Sander_Mak Java 9 (Sept. 2017)
  20. 20. @Sander_Mak R jshell E P L
  21. 21. @Sander_Mak R jshell E P L ead
  22. 22. @Sander_Mak R jshell E P L ead val
  23. 23. @Sander_Mak R jshell E P L ead val rint
  24. 24. @Sander_Mak R jshell E P L ead val rint oop
  25. 25. @Sander_Mak R jshell E P L ead val rint oop Input code
  26. 26. @Sander_Mak R jshell E P L ead val rint oop Input code Run code
  27. 27. @Sander_Mak R jshell E P L ead val rint oop Input code Run code See results
  28. 28. @Sander_Mak R jshell E P L ead val rint oop Input code Run code See results Iteratively refine
  29. 29. @Sander_Mak jshell DEMO
  30. 30. @Sander_Mak Java 10 (March 2018)
  31. 31. @Sander_Mak var
  32. 32. @Sander_Mak var String name = "Sander";
  33. 33. @Sander_Mak var String name = "Sander"; public void aMethod() { String name = "Sander"; }
  34. 34. @Sander_Mak var String name = "Sander"; public void aMethod() { String name = "Sander"; } public void aMethod() { var name = "Sander"; }
  35. 35. @Sander_Mak var URL url = new URL("https://javamodularity.com"); URLConnection connection = url.openConnection(); BufferedInputStream inputStream = new BufferedInputStream(connection.getInputStream());
  36. 36. @Sander_Mak var URL url = new URL("https://javamodularity.com"); URLConnection connection = url.openConnection(); BufferedInputStream inputStream = new BufferedInputStream(connection.getInputStream()); var bookurl = new URL("https://javamodularity.com"); var connection = bookurl.openConnection(); var bookStream = new BufferedInputStream(connection.getInputStream());
  37. 37. @Sander_Mak var URL url = new URL("https://javamodularity.com"); URLConnection connection = url.openConnection(); BufferedInputStream inputStream = new BufferedInputStream(connection.getInputStream()); var bookurl = new URL("https://javamodularity.com"); var connection = bookurl.openConnection(); var bookStream = new BufferedInputStream(connection.getInputStream());
  38. 38. @Sander_Mak var URL url = new URL("https://javamodularity.com"); URLConnection connection = url.openConnection(); BufferedInputStream inputStream = new BufferedInputStream(connection.getInputStream()); var bookurl = new URL("https://javamodularity.com"); var connection = bookurl.openConnection(); var bookStream = new BufferedInputStream(connection.getInputStream()); DEMO
  39. 39. @Sander_Mak Java 9 (Sept. 2017)
  40. 40. @Sander_Mak Collection Factory Methods
  41. 41. @Sander_Mak List<String> books = new ArrayList<>(); books.add("Java 9 Modularity"); books.add("Designing Data-Intensive Applications"); books.add("Java 8 Lambdas"); Collection Factory Methods
  42. 42. @Sander_Mak Collection Factory Methods List<String> books = List.of("Java 9 Modularity", "Designing Data-Intensive Applications", "Java 8 Lambdas");
  43. 43. @Sander_Mak Collection Factory Methods List<String> books = List.of("Java 9 Modularity", "Designing Data-Intensive Applications", "Java 8 Lambdas"); Set.of Map.of
  44. 44. @Sander_Mak Quick Java Module Overview
  45. 45. @Sander_Mak module main { } module-info.java Module Declarations
  46. 46. @Sander_Mak module main { } module-info.java Module Declarations main.web main.persistence main.integration main
  47. 47. @Sander_Mak module main { requires helper; } module-info.java module helper { } module-info.java Explicit Dependencies main.web main.persistence main.integration main
  48. 48. @Sander_Mak module main { requires helper; } module-info.java module helper { } module-info.java helper Explicit Dependencies main.web main.persistence main.integration main
  49. 49. @Sander_Mak module main { requires helper; } module helper { exports helper.api; } module-info.java module-info.java helper.api helper Well-defined Interfaces main.web main.persistence main.integration main
  50. 50. @Sander_Mak module main { requires helper; } module helper { exports helper.api; } module-info.java module-info.java helper.api helper.impl helper Strong Encapsulation main.web main.persistence main.integration main
  51. 51. @Sander_Mak Demo: EasyText easytext.cli easytext.analysis
  52. 52. @Sander_Mak Why?
  53. 53. @Sander_Mak Why? Modular JDK
  54. 54. @Sander_Mak Why? Modular JDK Maintainability Reliable composition Flexibility
  55. 55. @Sander_Mak quick refresher why/advantages (JDK: modularized, your app: architecture from whiteboard to code, explicit dependencies in language, strong encapsulation, jlink Why? Decrease the model-code gap
  56. 56. @Sander_Mak jlink
  57. 57. @Sander_Mak jlink + main lib1 lib2 jdk ~300mb application ~2mb
  58. 58. @Sander_Mak jlink + main lib1 lib2 jdk ~300mb application ~2mb JVM main lib1 lib2 java.base java.logging java.xml Custom Run-time Image ~25mb
  59. 59. @Sander_Mak jlink + main lib1 lib2 jdk ~300mb application ~2mb JVM main lib1 lib2 java.base java.logging java.xml Custom Run-time Image
  60. 60. @Sander_Mak IoT Device jlink + main lib1 lib2 jdk ~300mb application ~2mb JVM main lib1 lib2 java.base java.logging java.xml Custom Run-time Image
  61. 61. @Sander_Mak Impact on Java 8 codebases
  62. 62. @Sander_Mak Impact on Java 8 codebases Use of encapsulated JDK types: Run-time warnings Compile-time errors
  63. 63. @Sander_Mak Impact on Java 8 codebases Use of encapsulated JDK types: Run-time warnings Compile-time errors Use of enterprise APIs in JDK: Won't resolve by default Gone in Java 11! java.corba java.xml.bind java.xml.ws.* java.activation java.transaction
  64. 64. @Sander_Mak Let's Talk About Adoption
  65. 65. @Sander_Mak https://jaxenter.com/java-8-still-strong-java-10-142642.html
  66. 66. @Sander_Mak https://jaxenter.com/java-8-still-strong-java-10-142642.html https://www.baeldung.com/java-in-2018
  67. 67. @Sander_Mak https://jaxenter.com/java-8-still-strong-java-10-142642.html https://www.baeldung.com/java-in-2018 https://www.jetbrains.com/research/devecosystem-2018/java/
  68. 68. @Sander_Mak https://jaxenter.com/java-8-still-strong-java-10-142642.html https://www.baeldung.com/java-in-2018 https://www.jetbrains.com/research/devecosystem-2018/java/ Java Magazine & Snyk
  69. 69. @Sander_Mak https://jaxenter.com/java-8-still-strong-java-10-142642.html https://www.baeldung.com/java-in-2018 https://www.jetbrains.com/research/devecosystem-2018/java/ Java Magazine & Snyk
  70. 70. @Sander_Mak Java 11
  71. 71. @Sander_Mak Java 11 Java 9 Java 10 Java 12 Java 13 6 months Java 11
  72. 72. @Sander_Mak Java 11 Java 9 Java 10 Java 12 Java 13 6 months Java 11
  73. 73. @Sander_Mak Java 11 Long Term Support Java 9 Java 10 Java 12 Java 13 6 months Java 11 Java 11 LTS minimum 3 years
  74. 74. @Sander_Mak Which JDK? JDK 11 changes the game
  75. 75. @Sander_Mak Oracle JDK 8 Binary Code License
  76. 76. @Sander_Mak Oracle JDK 8 Binary Code License Oracle JDK 11 Java SE Subscription $
  77. 77. @Sander_Mak Oracle JDK 8 Binary Code License Oracle JDK 11 Java SE Subscription $ OpenJDK 11 GPL v2
  78. 78. @Sander_Mak Oracle JDK 8 Binary Code License Oracle JDK 11 Java SE Subscription $ OpenJDK 11 GPL v2 =
  79. 79. @Sander_Mak Oracle JDK 8 Binary Code License Oracle JDK 11 Java SE Subscription $ OpenJDK 11 GPL v2 Amazon Corretto AdoptOpenJDK Red Hat OpenJDK Azul Zulu =
  80. 80. Thanks. Join us: join.picnic.app @Sander_Mak bit.ly/ps-sander

×