Java 16 is released~ Let's take a look at the new features

Java 16 is released~ Let's take a look at the new features

 

As we celebrate the 25th anniversary of Java, 2020 is a memorable year for Java. After more than 20 years of innovation, Java has always been:

  • Maintain platform independence by adapting to the ever-changing technological landscape, thereby allowing flexibility.
  • Reliability is guaranteed by maintaining backward compatibility.
  • Expressed by accelerating innovation without sacrificing safety.

Coupled with Java's ability to continuously improve platform performance, stability and security, it remains the most popular programming language among developers in the world. According to IDC's latest report, Java Turns 25, more than 9 million developers (69% of global full-time developers) use Java-more than any other language.

Oracle further demonstrated the continuous innovation of Java, and proudly announced the comprehensive Release of Java 16, which is the seventh functional version of the release in six months of intense development. The constant flow of expected changes makes it easier for developers to manage their adoption of innovative suggestions.

Java 16 is released~ Let's take a look at the new features

 

Java 16 is now available!

Oracle now officially provides Java 16 to all developers and enterprises. According to the Oracle Critical Patch Update (CPU, Critical Patch Update) schedule, Oracle JDK 16 will receive at least two quarterly updates, and then we will release Oracle JDK 17. Java 17 will be fully available in September 2021, but a build version is already available on the jdk.java.net website.

Oracle once again used the open source GPLv2 agreement and CPE agreement to provide Java 16 as the Oracle OpenJDK version to everyone, and for users who use the Oracle JDK version as Oracle products or services, or for those who wish to obtain commercial support Commercial license.

Java 16,Together

Similar to previous releases, we will continue to thank many individuals and organizations in the OpenJDK community for their contributions to Java 16-we built Java together!

JDK 16 fixed development rate

The overall rate of change of the JDK has remained basically constant for many years, but the speed of delivering products that can be used for production has been greatly increased under the intense development pace of six months.

We no longer release thousands of fixes and approximately one hundred JDK enhancement recommendations (JEP) in major major releases every few years. Instead, we choose a more manageable and predictable six-month plan. Enhancements are provided in the small Feature version. These changes range from important features to small enhancements, to routine maintenance, bug fixes, and documentation improvements. For each issue and change in the JDK Bug system, we present it in the form of a single submission.

Of the 1,897 issues marked as resolved in Java 16, [1,397](
bugs.openjdk.java.net/browse/JDK-… %20ORDER%20BY%20updated%20DESC%2C%20assignee%20ASC) were issued by Oracle The staff solved it, and the other 500 were solved by individual developers and developers working for other organizations. Carefully study these issues and sort out the organizational data from the assignee, and you will get the following organizational chart. This organization chart is made up of people who contributed to the development of the patch in Java 16:

 

Java 16 is released~ Let's take a look at the new features

 

 

Oracle thanks developers who work in organizations such as ARM, SAP, Red Hat, and Tencent for their outstanding contributions. We are also very happy to see the contributions of smaller organizations such as Ampere Computing, Bellsoft, DataDog, Microdoc, and other independent developers, who together contributed 3% of the fixes in Java 16.

We also thank the many experienced developers who reviewed the proposed changes, early adopters who tried to adopt the early access version and reported problems, and dedicated professionals who provided feedback on the OpenJDK mailing list.

The following people provided valuable feedback on the quality of the build, recorded high-quality errors or provided frequent updates:

  • Jaikiran Pai (Apache Ant)
  • Gary Gregory (Apache Commons)
  • Uwe Schindler (Apache Lucene)
  • Robert Scholte (Apache Maven)
  • Mark Thomas (Apache Tomcat)
  • Enrico Olivelli (Apache Zookeeper)
  • Rafale Winterhalter (Byte Buddy)
  • Peter Karich (Graph Hopper)
  • Evgeny Yavits (JaCoCo)
  • Marc Hoffman (JaCoCo)
  • Vincent Privat (JOSM)
  • Christain Stein (JUnit 5)
  • David Karnok (RxJava)

In addition, through the Quality Development Program, we would like to thank the following FOSS projects and individuals who provided excellent feedback for testing early access versions of Java 16 to help improve the quality of the release.

  • Apache Ant
  • Apache Derby (Rich Hillegas)
  • Apache Lucene
  • Apache Maven
  • Apache Tomcat
  • Apache Wicket (Martin Grigorov)
  • Apache ZooKeeper
  • Eclipse Collections (Nikhil Nanivadekar)
  • eo-yaml (Mihai Andronache)
  • FXGL (Almas Baimagambetov)
  • FXyz (Sean Phillips)
  • Java Katas (Chandra Guntur)
  • GraphHopper
  • Hibernate ORM
  • Hibernate Validator
  • Hibernate Search
  • Hibernate Reactive (Sanne Grinovero & Yoann Rodiere)
  • JobRunr (Ronald Dehuysser)
  • jOOQ (Lukas Eder)
  • MyBatis (Iwao Ave)
  • Micrometer (Tommy Ludwig)
  • RxJava
  • Sejda
  • PDFsam (Andrea Vacondio)

What's new in Java 16

With thousands of performance, stability and security updates, Java 16 provides users with a total of 17 major enhancements and changes (called JDK enhancement recommendations, JEP), including three incubator modules and a preview function.

We have introduced some enhancements in the incubator module, which is a way to deliver non-final APIs and non-final tools to developers, allowing users to provide feedback and ultimately improve the quality of the Java platform.

Similarly, some enhancements have been introduced, which are preview features, language or VM features of the Java SE platform, which have been fully determined, fully implemented, but not permanent. We provide these features in the JDK feature version to stimulate feedback from developers based on actual usage, which may affect them and make them permanent features in future versions. This approach provides users with an opportunity to provide timely feedback and gives tool vendors the opportunity to support a large number of Java developers before using the feature in production.

The 17 JEPs included with Java 16 are divided into six different categories:

1. New language features

JEP 394 Pattern Matching 的 instanceof

Pattern Matching was first introduced as a preview feature in Java 14, and we introduced it as a preview feature in Java 15. Pattern Matching enhances the functionality of the Java programming language by pattern matching the instanceof operator.

Pattern matching allows the general logic in the program (that is, the conditional extraction of components from the object) to be more concise and safer.

JEP 395 Records

Record was also introduced as a preview feature in Java 14 and Java 15, providing a compact syntax to declare classes. These classes are transparent holders of shallow immutable data, greatly reducing the level of detail of these classes, and improving the readability and maintainability of the code.

2. JVM improvements

JEP 376 ZGC Concurrent Thread Processing

JEP 376 moves ZGC thread stack processing from a safe point to the concurrent phase. Even on large heaps, we can achieve sub-millisecond pauses within GC safe points. In this version and subsequent versions, eliminating the ultimate source of delay in the ZGC garbage collector will greatly improve the performance and efficiency of the application.

JEP 387 Elastic Metaspace

This function can more quickly return the unused HotSpot VM class metadata (ie  metaspace ) memory to the operating system, thereby reducing the space occupied by the metaspace. Apps that have a lot of loading and unloading activities can take up a lot of unused space.

The new scheme allocates meta-space memory in smaller blocks, reducing the overhead and fragmentation of the class loader. It improves flexibility by returning unused meta-space memory to the operating system, thereby improving application performance and reducing memory utilization.

3. New tools and libraries

JEP 380 Unix-Domain Socket Channels

Unix-Domain Socket Channels has always been a feature of most Unix platforms, and now we have implemented this feature in Windows 10 and Windows Server 2019. This feature adds Unix domain (AF_UNIX) Socket support to the Socket and server Socket API in the java.nio.channels package. It extends the inherited channel mechanism to support Unix domain Socket channels and server Socket channels. Unix domain Socket is used for inter-process communication (IPC) on the same host. In most respects, it is similar to TCP-IP sockets, except that they use file system path names instead of Internet Protocol (IP) addresses and ports. Number to address. For local inter-process communication, Unix Socket is safer and more effective than TCP-IP loopback connection.

JEP 392 Packaging Tool

This feature was first introduced in Java 14 as an incubator module, allowing independent Java applications to be packaged. It supports local packaging format to provide a natural installation experience for end users. These formats include msi and exe on Windows, pkg and dmg on macOS, and deb and rpm on Linux. It also allows to specify startup parameters when packaging, and can be called directly from the command line or programmatically through the ToolProvider API. Note that the name of the jpackage module has changed from jdk.incubator.jpackage to jdk.jpackage. This will improve the end user's experience when installing the application and simplify deployment using the "app store" model.

4. Future verification of work

JEP 390 Warning for value-based classes

This feature specifies the original wrapper class (java.lang.Integer, java.lang.Double, etc.) as value-based (similar to java.util.Optional and java.time.LocalDateTime) and adds forRemoval to its constructor . They are deprecated since JDK 9, and prompt new warnings. It provides warnings about incorrect attempts to synchronize on instances of any value-based classes in the Java platform.

Many popular open source projects have responded to Java 9's obsolescence warning by removing packaged constructor calls from their sources, and given the urgency of the "deprecated deletion not recommended" warning, we can expect more to do so.

JEP 396 strongly encapsulates the JDK internals by default

By default, this function strongly encapsulates all internal elements of the JDK, except for key internal APIs, such as sun.misc.Unsafe. By default, the code that is successfully compiled with an earlier version to access the internal API of the JDK may no longer work. This change is intended to encourage developers to migrate from using internal elements to using standard APIs so that they and their users can easily upgrade to future Java versions. For JDK 9, the strong boot is enabled by the launcher option --illegal-access, while JDK 15 is the default setting, JDK 9-15 will be a warning , and starting from JDK 16, it will be rejected by default  . We can still use a single command line option to relax the packaging of all packages (for the time being), and in the future only use –add-opens to open a specific package to be effective.

5. Incubator and preview function

JEP 338 Vector API (Incubator)

The incubator API provides an initial iteration of the API to express vector calculations that are reliably compiled at runtime into the best vector hardware instructions on the supported CPU architecture, thereby achieving better performance than equivalent scalar calculations. It allows the use of single instruction multiple data (SIMD) instructions available on most modern CPUs. Although HotSpot supports automatic vectorization, the set of transformable scalar operations is limited and susceptible to code changes. The API will enable developers to easily write portable high-performance vector algorithms in Java.

JEP 389 External Link API (Incubator)

The incubator API provides pure Java access to statically typed native code. This API will greatly simplify the otherwise cumbersome and error-prone process of binding to native libraries. Java has supported native method calls through the Java Native Interface (JNI) since Java 1.1, but it is difficult and fragile to use. Java developers should be able to (mostly) only use any native libraries that are useful for specific tasks. It also provides support for foreign functions without any intermediate JNI glue code.

JEP 393 External memory access API (3 times incubator)

It was first introduced in Java 14 and Java 15 as an incubator API. This API enables Java programs to safely and effectively operate on various external memories (for example, native memory, PMEP, managed heap memory, etc.). It also provides the basis for the external linker API.

JEP 397 sealed class (2nd preview)

This preview function limits which other classes or interfaces can extend or implement them. It allows the author of a class or interface to control the code responsible for implementing that code. Moreover, it provides a more declarative way than access modifiers to restrict the use of superclasses. And it supports the future direction of pattern matching through detailed analysis of patterns.

6. Improve the productivity of OpenJDK developers

The remaining changes are not directly visible to Java developers (people who write code and run applications in Java), but only to Java developers (people doing OpenJDK development).

JEP 347 enables C++ 14 language features (in the JDK source code)

This allows the use of C++ 14 language features in the JDK C++ source code and provides specific guidance on which features can be used in the HotSpot code. In JDK 15, the language features used by C++ code in the JDK are limited to the C++ 98/03 language standard. This feature requires updating the minimum acceptable versions of compilers for various platforms.

JEP 357 Migrate from Mercurial to Git
JEP 369 Migrate to GitHub

These two JEPs migrated JDK 11 and later versions of the source code repository of the OpenJDK community from Mercurial (hg) to Git and hosted them on GitHub. The migration includes updating tools (such as jcheck, webrev, and defpath tools) to Git. Git reduces the size of metadata (about a quarter of the original size), which saves local disk space and reduces cloning time. Compared with Mercurial, modern tools can be better integrated with Git. The OpenJDK Git repository is now at github.com/openjdk

JEP 386 Alphine Linux Port

JEP 388 Windows / AArch64 Port

The focus of these JEPs is not the completed porting work itself, but to integrate them into the JDK mainline repository.

JEP 386 ported the JDK to Alpine Linux and other distributions x64 and AArch64 that use musl as its main C library. In addition, JEP 388 ported JDK to Windows AArch 64 (ARM64).

7. Tool support

Current tool support helps improve developer productivity. With Java 16, we will continue to welcome the efforts of leading IDE developers whose tool solutions provide developers with support for the current Java version. Developers can expect to get Java 16 support through the following IDEs:

  • JetBrains IDEA
  • Eclipse Market

Java is still the number one programming language of choice for software programmers. As shown by the on-time delivery of those improvements in Java 16, through continuous thoughtful planning and ecosystem participation, the Java platform is well positioned for modern development and growth in the cloud.

Continue to follow news and updates in the following ways:

  • Visit Inside.Java (news and opinions from the Oracle Java team)
  • Listen to the Inside.Java podcast (this is a show for Java developers, obtained directly from Oracle's Java developers. We will discuss the language, JVM, OpenJDK, platform security, and innovative projects such as Loom and Panama There are other other content).
  • Join the OpenJDK mailing list (a place to find out where you like the progress of the OpenJDK project).

Guess you like

Origin blog.csdn.net/a159357445566/article/details/115210808