Contenu connexe Similaire à Javantura v6 - JDK 11 & JDK 12 - Dalibor Topic (20) Plus de HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association (20) Javantura v6 - JDK 11 & JDK 12 - Dalibor Topic1. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JDK 11 & JDK 12
Dalibor Topić
Principal Product Manager
Java Platform Group, Oracle
@robilad
February 23rd, 2019 @ Javantura in Zagreb, Croatia
2. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
2
4. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JDK 11 – Feb 2018 -> Sep 2018
• 17 JEPs completed
4
5. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Building JDK 11 Together
5
6. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 330: Launching Single Source File Programs
• Simplify the ”on-ramp” for new Java users
• Example
– Before:
• $Javac -d classes HelloWorld.java
• $Java -cp classes HelloWorld
– After:
• $java HelloWorld.java
6
7. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 321: HTTP Client
• Standardizes the incubated HTTP Client API in the java.net.http package
• It supports
– HTTP/1.1 and HTTP/2,
– both synchronous and asynchronous programming models,
– handles request and response bodies as reactive-streams, and
– follows the familiar builder pattern
7
8. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 332: Transport Layer Security (TLS) 1.3
• TLS 1.3 is a major overhaul of the TLS protocol and provides significant security and
performance improvements over previous versions
• TLS 1.3 is a new TLS version which supersedes and obsoletes previous versions of TLS
including version 1.2 (RFC 5246)
• It also obsoletes or changes other TLS features such as the OCSP stapling extensions
(RFC 6066, RFC 6961), and the session hash and extended master secret extension
(RFC 7627)
• Deliver new cryptographic algorithm support for the following optional TLS 1.3 features:
– ChaCha20/Poly1305 cipher suites (8140466)
– X25519/X448 elliptic curve algorithms (8171279)
– edDSA signature algorithms (8166596)
8
9. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 181: Nest-Based Access Control
• Nests allow classes that are
– logically part of the same code entity, but
– compiled to distinct class files, to
– access each other's private members
– without the need for compilers to insert accessibility-broadening bridge methods.
• Such classes become smaller when compiled with JDK 11
9
10. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 181: Nest-Based Access Control
• For example:
– With javac –release 10, it compiles to
• 382 byte Person.class and
• 870 byte Person$Greeting.class
– With javac, it compiles to
• 309 byte Person.class and
• 872 byte Person$Greeting.class
10
11. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 328: Java Flight Recorder
• Enabled with –XX:StartFlightRecording option
• Built deep inside the JVM & JDK, by the engineers developing the JVM/JDK
• Always on - less that 1% overhead in production deployment
• High performance flight recording engine and data collection for Enterprise
mission-critical workload
– Access to data already collected in the JVM runtime
– Thread local native buffers
– Invariant TSC for time stamping
– More accurate method profiling (method profiling data even from outside safe-points)
– Faster and more accurate allocation profiling with automatic memory leak detection
Profiling with Extremely Low Overhead
11
12. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 12
JEP 333: ZGC - Predictable, Low latency, Large heap GC
Enabled with –XX:+UnlockExperimentalVMOptions –XX:+UseZGC
14. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Migrating to JDK 11
14
15. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
How much faster is Java 11?
15
16. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Read-eval-act Loop of JDK Migration
• Read the JDK documentation
• Evaluate if advice applies to you
• Act accordingly
• GOTO 10
16
17. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Not just JavaDoc
• Oracle Java Documentation
– https://docs.oracle.com/en/java/
• JDK 11 documentation
– https://docs.oracle.com/en/java/javase/11/
– Release Notes
• Important changes, new, removed & deprecated features & options, removed CA certificates
– Migration Guide
• Lists important changes, provides advice for migration from JDK 8 & JDK 10 to JDK 11
• Documentation for older releases is available there, too
17
18. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Migrating To JDK 11
• Download and install the latest JDK 11 release
• Run your program on JDK 11 before recompiling it with JDK 11
– Update third party tools and libraries to a version that supports latest JDK release
– Run jdeps tool to scan your code for problematic internal API usage
• Analyze runtime warnings from JVM
– Deprecated & removed GC flags, illegal reflective access operations
• Run your tests on JDK 11
– Check for changes in behavior due to different defaults, e.g. CLDR locale data
• Recompile your program with JDK 11
– Use javac –release flag to compile for older JDK releases
18
19. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Migrating To JDK 11 from JDK 8
• Read the docs from JDK 9 and JDK 10 as well as JDK 11
• Learn about new features, removed and deprecated APIs
– New version string
– Modularity & encapsulation of internal APIs
– Changes to JDK runtime image
– Removal of Deployment stack (plugin, Java Web Start)
– Removal of unbundled, deprecated, unsupported or no longer necessary tools
• appletviewer, javah, jhat, javadb, jvisualvm, …
19
20. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Staying up to date
• Open Source Project (Lead) Developers
– Join OpenJDK Quality Outreach
• https://wiki.openjdk.java.net/display/quality/Quality+Outreach
• Developers
– Start testing your applications early on upcoming JDK releases
• The weekly Early Access builds start many months before GA
– JDK 12 Early Access builds already available at
• http://jdk.java.net/12/
– Docker images for your CI system
• docker pull openjdk:12-ea-oracle
20
21. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JDK Updates
21
24. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Maintaining OpenJDK Releases
24
25. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 25
JDK Updates in OpenJDK
• Four active update Projects
– OpenJDK 6 led by Andrew Brygin from Azul Systems
– OpenJDK 7u led by Andrew Haley from Red Hat
– OpenJDK 8u led by Andrew Haley from Red Hat
– JDK Updates (9 and above) led by Rob McKenna from Oracle
• I’ll focus on
– JDK Updates
26. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 26
JDK Updates
• Project Lead
– Sets technical direction, communicates schedules, etc.
• Rob McKenna (Oracle)
• Maintainers
– Approve or reject changes after coordinating with stake holders, uphold policies
• David Buck, Sean Coffey, Jeff Dinkins, Rob McKenna, Naoto Sato, Dalibor Topic (all Oracle)
• 11u Lead Maintainer: Andrew Haley (Red Hat)
• Code repositories
– https://hg.openjdk.java.net/jdk-updates/jdk11u/
– https://hg.openjdk.java.net/jdk-updates/jdk12u/
• Mailing lists
– Development: jdk-updates-dev@openjdk.java.net
– Commits: jdk-updates-changes@openjdk.java.net
27. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 27
JDK Updates Repository Maintainer Transitions
• A maintainer (group) that intends to step down sends an e-mail to the list
– Announcing their plans
– Providing a time frame to allow everyone to plan for it
– Call for new maintainers
• If some new maintainers step up, then
– the Project Lead gets to chose if they are suitable
• Maintaining OpenJDK Updates is not trivial
– If so, adds them as (lead) maintainers for that repository
• Maintainers may
– Specify alternative code review and approval mechanisms
– Chose a different set of platforms and CPU architectures to support
• No expectation of continuity
29. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 29
JDK Updates Development Process
• Ground Rules
– Process can change after discussion on mailing list
– Changes not specific to an update must go into JDK Project first (i.e. backports only)
– Changes must go through review by Reviewers and push approval by Maintainers
• Public Code Review
– Can be skipped if change is identical to JDK Project (i.e. already reviewed)
– Changes must have been reviewed by at least one Reviewer
– Original Author and Reviewers should agree change is suitable for backport
• Push Approvals
– Done through labels in JIRA
• jdk12u-fix-request, jdk12u-fix-yes
– Any reasonable fix which improves stability, security or performance should be considered
• CPU fix merges, TZ data updates, test fixes, changes to Root CA certs, build numbers, downstream ports
30. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 30
What happens after an OpenJDK maintainer transition
• New maintainers may have different
– Priorities & goals
• Backport the minimal set of changes necessary or more?
• Support a single CPU/OS (vendor) or more?
– Resources
• Patch existing HotSpot or try to use the latest from JDK instead?
– Timing
• Backports take time, to non-mainstream platforms even more so
– Release for all platforms at the same time?
• Support time frame?
• Other considerations
– Multiple successful maintainer transitions in the past
– Commercial support
32. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JDK 12 – Jun 2018 -> Mar 2019
• 8 JEPs completed
32
33. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 346: Promptly Return Unused Committed Memory
from G1
• Automatically return Java heap memory to the OS when idle.
• Good for container environments where resources are paid by use.
– Better hardware utilization for cloud providers
• Tests with a prototype in Bruno et al., section 5.5, shows that based on
the real-world utilization of a Tomcat server that serves HTTP requests
during the day, and is mostly idle during the night, this solution can
reduce the amount of memory committed by the Java VM by 85%.
– Rodrigo Bruno, Paulo Ferreira, Ruslan Synytsky, Tetiana Fydorenchyk, Jia Rao,
Hang Huang, and Song Wu. 2018. Dynamic Vertical Memory Scalability for
OpenJDK Cloud Applications. In Proceedings of 2018 ACM SIGPLAN International
Symposium on Memory Management (ISMM’18). ACM, New York, NY, USA, 12
pages.
33
34. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 341: Default CDS Archives
• Enhance the JDK build process to generate a class data-sharing (CDS)
archive, using the default class list, on 64-bit platforms.
– Improves out-of-the-box startup time
– Eliminates the need to run –Xshare:dump to benefit from CDS
• Many enhancements have been added to CDS feature since 8u40
– Example: 32% HelloWorld startup time reduction in JDK 11 EA builds on Linux
• Resulting archive can be found in bin/server/classes.jsa
• Users will benefit automatically, since –Xshare:auto was enabled by
default in JDK 11
34
35. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 325: Switch Expressions (Preview)
35
switch (day) {
case MONDAY:
case FRIDAY:
case SUNDAY:
System.out.println(6);
break;
case TUESDAY:
System.out.println(7);
break;
case THURSDAY:
case SATURDAY:
System.out.println(8);
break;
case WEDNESDAY:
System.out.println(9);
break;
}
switch (day) {
case MONDAY, FRIDAY, SUNDAY -> System.out.println(6);
case TUESDAY -> System.out.println(7);
case THURSDAY, SATURDAY -> System.out.println(8);
case WEDNESDAY -> System.out.println(9);
}
36. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 325: Switch Expressions (Preview)
36
int letters = 0;
switch (day) {
case MONDAY:
case FRIDAY:
case SUNDAY:
letters = 6;
break;
case TUESDAY:
letters = 7;
break;
case THURSDAY:
case SATURDAY:
letters = 8;
break;
case WEDNESDAY:
letters = 9;
break;
default:
throw new IllegalStateException();
}
int letters = switch (day) {
case MONDAY, FRIDAY, SUNDAY -> 6;
case TUESDAY -> 7;
case THURSDAY, SATURDAY -> 8;
case WEDNESDAY -> 9;
}
37. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 325: Switch Expressions (Preview)
• Extend the switch statement so
– It can be used either as a statement or an expression
– Both forms can use „traditional“ or „simplified“ scoping and control flow
• Simplify everyday coding
• Prepare the way for the use of pattern matching (JEP 305) in switch
37
38. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 325: Switch Expressions (Preview)
• This is a preview language feature
– Fully implemented, fully specified, yet impermanent
– Made available in a release to get real world use feedback from developers
– To try a preview feature out, it has to be enabled at compile time and at runtime
• javac –release 12 –enable-preview Foo.java
• java –enable-preview Foo
38
39. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
JEP 189: Shenandoah: A Low-Pause-Time Garbage
Collector (Experimental)
• Add a new garbage collection (GC) which reduces GC pause times
– by doing evacuation work concurrently with the running Java threads.
• It trades concurrent cpu cycles and space for pause time improvements
• Pause times with Shenandoah are independent of heap size
• To enable Shenandoah:
– -XX:+UnlockExperimentalVMOptions –XX:+UseShenandoahGC
39
40. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Beyond JDK 12
40
41. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
The Next Big Challenges Opportunities
• Containers
• Predictability
• Performance
• Data optimization
• HW acceleration
• Scalability
• Continual language enhancements
41
42. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Portola
Skara
Loom
Valhalla
Panama
Amber
42
openjdk.java.net
43. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Summary
• The cloud is demanding a faster pace and continuous delivery
– Accelerating the pace of innovations with 6-month releases while providing stability and security to enterprise
mission-critical services via 3 years LTS releases
• JDK 11, the next LTS release, includes innovations, security, productivity and performance
improvements
– Delivering on our commitment to open source commercial features (JFR, AppCDS, ZGC)
• Oracle is simplifying Java licensing by transitioning out of the BCL “dual purpose” license
– JDK 11 Is delivered both as Oracle OpenJDK under GPL/CPE license for free, and Oracle JDK under Oracle
technology license for commercial support
• Oracle introduced a new Java subscription offering to make Java support affordable and
predictable for everyone
• Beyond Java 11, we have a solid technical roadmap
43
openjdk.java.net and jdk.java.net