May 31, 2021 Article blog
This article comes from the public number: Java Chinese Community Author: Lei ge
JDK 15 was officially released on September 15, 2020, and the main features of this release are:
JEP:JDK Proposals, JDK Enhancement Recommendations, i.e. JDK feature additions and improvement proposals.
The number of JEPs corresponding to the releases released over the years is shown in the following image:
According to the release plan, this release of JDK 15 will be a short-term over-release and will only be supported (maintained) by Oracle for 6 months until this release of JDK 16 in March next year will stop maintenance. Oracle's next long-term support release (LTS) will be released in September next year (Java 17), LTS will be released every 3 years, and the last long-term support release will be JDK 11 released in September 18.
JDK 15 provides users with fourteen major enhancements/changes, including an incubator module, three preview features, two features that are not recommended, and two removal features.
Newly added Edwards-Curve Digital Signature Algorithm (EdDSA) enables encrypted signatures. S upport is available in many other encryption libraries, such as OpenSSL and BoringSSL. E dDSA offers greater security and performance than existing signature scenarios in the JDK. This is a new feature.
This feature helps frameworks that need to build classes at runtime. F ramework generation classes need to dynamically extend their behavior, but they also want to restrict access to those classes. H idden classes are useful because they can only be accessed by reflection, not by normal bytecode. I n addition, hidden classes can be loaded independently of other classes, which reduces the memory footprint of the framework. This is a new feature.
Re-implementing legacy DatagramSocket APIs, with simpler, more modern implementations to replace the basic implementations of
java.net.DatagramSocket
and
java.net.MulticastSocket
APIs, improves the maintainability and stability of the JDK.
ZGC has been integrated from JEP 333 into JDK 11 with the goal of improving performance by reducing GC pause time. With JEP 377, ZGC moved from preview to production.
Proposed by JEP 355 in 2019, a block of text is a multi-line string text that avoids the need for most escape sequences, automatically formats strings in a predictable way, and gives developers control over formats when needed. With JEP 378, text blocks have become a permanent feature of the Java language.
Shenandoah garbage collection has changed from experimental to product. T his is a recycling algorithm introduced from JDK 12 that reduces GC pause time by simultaneously evacuating with a running Java thread. Shenandoah's pause time is independent of the heap size, and has the same consistent pause time regardless of whether the stack is 200 MB or 200 GB.
Enhance the Java programming language by sealing classes and interfaces to limit the use of superclasses, and sealed classes and interfaces to restrict other classes or interfaces that might inherit or implement them.
Old writing:
// 先判断类型
if (obj instanceof String) {
// 然后转换
String s = (String) obj;
// 然后才能使用
}
New writing:
if (obj instanceof String s) {
// 如果类型匹配 直接使用
} else {
// 如果类型不匹配则不能直接使用
}
This is the second time we've previewed the feature, and we've previewed it for the first time in Java 14.
Records Class is also a second preview feature, which also appears once in JDK 14, and uses Record to make it easier to create a constant class using the following before and after code comparisons.
Old writing:
class Point {
private final int x;
private final int y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
int x() { return x; }
int y() { return y; }
public boolean equals(Object o) {
if (!(o instanceof Point)) return false;
Point other = (Point) o;
return other.x == x && other.y = y;
}
public int hashCode() {
return Objects.hash(x, y);
}
public String toString() {
return String.format("Point[x=%d, y=%d]", x, y);
}
}
New writing:
record Point(int x, int y) { }
That is, after using record, you can write a constant class with a row of code, and this constant class also contains methods such as construction methods, toString(), equals(), and hashCode().
The goal is to introduce an API to allow Java programs to securely and efficiently access external memory outside the Java heap. This is also a preview feature of Java 14.
Other features include deprecated and uns recommended features, such as removing the Nashorn JavaScript engine, removing solaris and SPARC ports, and marking some deprecation features.
Above is
W3Cschool编程狮
about
the official release of JDK15, new features preview!
Related to the introduction, I hope to help you.