Oracle will maintain the latest JDK 11 until 2026.

New features for Java11

1. Update support to Unicode 10 encoding

Unicode 10 (Version 10.0 of the Unicode Standard) is an evolving industry Standard with which Java has been consistently compliant.

Unicode8.0-9.0 has been updated for Java8, and Java10 will have 16,018 characters, 18 blocks, and 10 scripts.

2. Publish Http Client as JDK standard

The HTTP classes used to be included in the JDk.incubator. HTTP package as a supplement to the JDK, but now they are unified under the java.net.http package. There are four core classes.

  • HttpClient
  • HttpRequest
  • HttpResponse
  • WebSocket
HttpClient client = HttpClient.newBuilder() .version(HttpClient.Version.HTTP_1_1) .connectTimeout(Duration.ofSeconds(3))  .build(); HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://www.baidu.com")).build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.statusCode()); // 200 System.out.println(response.body()); // Baidu page HTMLCopy the code

3. New optimization methods

  • Java.util. Collection added a new method toArray(IntFunction) to convert collections to arrays.
  • String adds lines\ stritrailing \stripTrailing etc. Common projects have the StringUtils class.
  • Java.io.InputStream adds a constructor
  • Nio package under the large class extension methods such as Channels\XXXBuffer

4. Support dynamic distribution Compiler Threads

New JVM startup parameters – XX: + UseDynamicNumberOfCompilerThreads, dynamic control of the number of threads programming, the original compilation thread will start the default waste a lot of CPU and memory.

5. GC capacity has been greatly improved

The low power Extensible GC (ZGC) module is an experimental concurrent GC that does heavy collection work such as string table cleanup during thread execution. The execution cycle is within 10ms, processing heaps size from MB to TB range, currently only support Linux and X64 system, in addition to the processing of memory allocation Epsilon GZ, interested in your own research.

6. Heap analysis ability improvement: JVMTI

JVMTI provides a low-load heap-allocation acquisition and analysis program :JVMTI. The default startup scheme works continuously and does not stress the server. It is interface oriented and can collect information about living and dead objects.

Transport Layer Security 1.3 Update

TLS1.3 is a network transport layer protocol. It is not compatible with historical versions and is officially acknowledged to have risks. We hope that it can be continuously optimized in the future.

8. Nested access control

Nesting is an access control context that allows multiple classes to belong to the same logical code block, but to be compiled into separate class files that access each other’s private members without adding access extension methods through the compiler.

Example:

/** * @author: Owen Jia * @time: 2019/11/7 */ public class NestBasedTest { public static class Nest1 { private int varNest1; public void f() throws Exception { final Nest2 nest2 = new Nest2(); Nest2. VarNest2 = 2; final Field f2 = Nest2.class.getDeclaredField("varNest2"); F2.setint (nest2, 1); f2.setint (nest2, 1); System.out.println(nest2.varNest2); } } public static class Nest2 { private int varNest2; } public static void main(String[] args) throws Exception { new Nest1().f(); }}Copy the code

New Class methods:

// Get the host class. The host class of a non-nested class is itself. public Class<? Public Boolean isNestmateOf(Class<? > c) // Returns an array of nested classes for a class. The first is the host Class, followed by the nested members of that host Class, in no order, and also including their own public Class<? >[] getNestMembers()Copy the code

9. Add and optimize many encryption algorithms

More algorithms are provided in PKCS#1 v2.2, such as RSASSA-PSS signature algorithm. ChaCha20 and Poly1305 password algorithms are added to use cipher. getInstance. Also Curve25519 and Curve448 have been added. AES128 and 265 also support Kerberos 5 encryption.

10. Local parameters support Lambda

Lambda expressions can be declared using var.

	lst.forEach((var x) -> {
		System.out.print(x);
	});
Copy the code

11. Single Java file load run

A single *.java file can be executed directly with a Java command in the format Java HelloWorld.java.

Flight recorder analysis tool

Jvm startup parameters: -xx :StartFlightRecording

Java11 integrates this commercially available tool into the JDK standard. It is a low-cost event information collection framework for troubleshooting and analyzing applications and JVMS. It collects application, JVM, and OS data and stores it in a separate event log file. Analyze faults by extracting useful information from event log files.

More other abilities

There are a number of other updates that I won’t cover in detail, but are basic capabilities supported by the JDK standard package, thanks to Oracle’s continued support for JDK releases. A full list of jdK11 changes can be found on the jdK11 website.

List of modules removed since 11

  • Removal of com.sun.awt.AWTUtilities Class
  • Removal of Lucida Fonts from Oracle JDK
  • Removal of appletviewer Launcher
  • Oracle JDK’s javax.imageio JPEG Plugin No Longer Supports Images with alpha
  • Removal of sun.misc.Unsafe.defineClass
  • Removal of Thread.destroy() and Thread.stop(Throwable) Methods
  • Removal of sun.nio.ch.disableSystemWideOverlappingFileLockCheck Property
  • Removal of sun.locale.formatasdefault Property
  • Removal of JVM-MANAGEMENT-MIB.mib
  • Removal of SNMP Agent
  • Remove the Java EE and CORBA Modules
  • Removal of JavaFX from the Oracle JDK
  • Removal of JMC from the Oracle JDK
  • Removal of Java Deployment Technologies
  • Check out the official website for more information

Upgrade Suggestion (Critical)

Since Java 11, Oracle no longer releases JRE and Server JRE separately and uses the same JDK name: Oracle JDK.

In addition, Java 11 and later versions will not be released with support for 32-bit operating systems.

Different strategies for new and old projects

It is recommended to build a new Java project directly from The Oracle JDK 11. Don’t hesitate, because the newer the technology, the stronger it gets. Java8 is the late Volkswagen, while Java11 is the new tesla.

Historical projects that are just maintenance should be left running until you decide to refactor and upgrade to Java11. The biggest problem is not that your Code can’t be migrated to a higher version, but that third-party jars introduced into the project can be a pain in the ass.

JDK upgrade analysis tools

The biggest worry of the upgrade is the deleted module!

IBM’s Liberty team provides a very useful detection Toolkit that scans application binaries (.war) for any potential Java 11 problems and generates Html reports. Absolute big sharp tool, details directly see IBM official introduction: Scanner Kit.

Direct run Java – jar binaryAppScannerInstaller jar, according to the steps to install a lisence statement and directory specified, the default directory name wamt.

This is explained in detail in the reference documentation, or you can refer to the following test examples (scan slowly, be patient, etc.) :

java -jar binaryAppScanner.jar Root.war --analyzeJavaSE --sourceJava=oracle8 --targetJava=java11 --output=./java11/RootReport.html

View help commands:

java -jar binaryAppScanner.jar Root.war --help --all

The results are as follows:

The JDK is different from OpenJDK

Oracle JDK is recommended because it is more stable and reliable.

  • Only the Oracle JDK supports Solaris;
  • Only the Oracle JDK supports installers like MSI;
  • Oracle JDK versions will be released every three years, while OpenJDK versions will be released every three months;
  • The OpenJDK is a reference model and is fully open source, whereas the Oracle JDK is an implementation of OpenJDK and is not fully open source;
  • The Oracle JDK is more stable than the OpenJDK. The OpenJDK and Oracle JDK have nearly identical code, but it is recommended that you choose the Oracle JDK because it has been thoroughly tested and stable fixed;
  • The Oracle JDK provides better performance than the OpenJDK in terms of responsiveness and JVM performance;
  • The Oracle JDK does not provide long-term support for upcoming releases; users must update to the latest version each time to get support;
  • The Oracle JDK is licensed under the binary code License, while the OpenJDK is licensed under the GPL V2 license. Oracle is very litigious, so this is important.

A link to the

JDK 11 Documentation Home

Java SE Development Kit 11 Downloads

java 11 release docs list

JDK 6~13 Release List