Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the new features of Java15

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "what are the new features of Java15", friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the new features of Java15"?

Version number: java-versionopenjdk version "15" 2020-09-15OpenJDK Runtime Environment (build 15-36-1562) OpenJDK 64-Bit Server VM (build 15-36-1562, mixed mode, sharing)

From the version information, we can see that it is build 1536.

Property list 339:Edwards-Curve Digital Signature Algorithm (EdDSA)

Added Edwards-Curve Digital Signature Algorithm (EdDSA) implementation of rfc8032 description as an example

/ / example: generate a key pair and signKeyPairGenerator kpg = KeyPairGenerator.getInstance ("Ed25519"); KeyPair kp = kpg.generateKeyPair (); / / algorithm is pure Ed25519Signature sig = Signature.getInstance ("Ed25519"); sig.initSign (kp.getPrivate ()); sig.update (msg); byte [] s = sig.sign (); / / example: use KeyFactory to contruct a public keyKeyFactory kf = KeyFactory.getInstance ("EdDSA"); boolean xOdd =. BigInteger y =. NamedParameterSpec paramSpec = new NamedParameterSpec ("Ed25519") EdECPublicKeySpec pubSpec = new EdECPublicKeySpec (paramSpec, new EdPoint (xOdd, y)); PublicKey pubKey = kf.generatePublic (pubSpec); 360:Sealed Classes (Preview)

JDK15 introduced sealed classes and interfaces. Used to qualify the implementation class, limit the use of the parent class, and provide convenient examples for subsequent exhaustive analysis of pattern matching

Package com.example.geometry;public abstract sealed class Shape permits Circle, Rectangle, Square {...} public final class Circle extends Shape {...} public sealed class Rectangle extends Shape permits TransparentRectangle, FilledRectangle {...} public final class TransparentRectangle extends Rectangle {...} public final class FilledRectangle extends Rectangle {...} public non-sealed class Square extends Shape {...}

Three keywords are used here, one is sealed, the other is permits, and the other is that the subclasses of non-sealed;permits either use final, or use sealed, or use non-sealed modification; for the record type, you can also use sealed, because the record type implies the final

Package com.example.expression;public sealed interface Expr permits ConstantExpr, PlusExpr, TimesExpr, NegExpr {...} public record ConstantExpr (int I) implements Expr {...} public record PlusExpr (Expr a, Expr b) implements Expr {...} public record TimesExpr (Expr a, Expr b) implements Expr {...} public record NegExpr (Expr e) implements Expr {...} 371:Hidden Classes

JDK15 introduces Hidden Classes while abandoning the non-standard sun.misc.Unsafe::defineAnonymousClass, with the goal of providing frameworks with internal class generated at run time

372:Remove the Nashorn JavaScript Engine

JDK15 has removed Nashorn JavaScript Engine and jjs tool, which are marked as obsolete in JDK11; specifically, jdk.scripting.nashorn and jdk.scripting.nashorn.shell modules have been removed

373:Reimplement the Legacy DatagramSocket API

This feature reimplements java.net.DatagramSocket and java.net.MulticastSocket in a simpler and more modern way to facilitate better maintenance and debug. The new implementation will be easier to support virtual threads.

374:Disable and Deprecate Biased Locking

Biased locking (- XX:+UseBiasedLocking) is disabled by default, and all relevant command line options (BiasedLockingStartupDelay, BiasedLockingBulkRebiasThreshold, BiasedLockingBulkRevokeThreshold, BiasedLockingDecayTime, UseOptoBiasInlining, PrintBiasedLockingStatistics and PrintPreciseBiasedLockingStatistics) are discarded.

375:Pattern Matching for instanceof (Second Preview)

The Pattern Matching of instanceof performs Second Preview in JDK15. The example is as follows:

Public boolean equals (Object o) {return (o instanceof CaseInsensitiveString cis) & & cis.s.equalsIgnoreCase (s);} 377:ZGC: a Scalable Low-Latency Garbage Collector

ZGC is introduced as experimental feature in JDK11 and becomes Production in JDK15, but this does not replace the default GC, the default GC is still G1; previously, you needed to use-XX:+UnlockExperimentalVMOptions-XX:+UseZGC to enable ZGC, but now you only need-XX:+UseZGC to enable ZAllocationSpikeTolerance, ZCollectionInterval, ZFragmentationLimit, ZMarkStackSpaceLimit, ZProactive, ZUncommit, ZUncommitDelay ZGC-specific JFR events (ZAllocationStall, ZPageAllocation, ZPageCacheFlush, ZRelocationSet, ZRelocationSetGroup, ZUncommit) from experimental to product

378:Text Blocks

Text Blocks is introduced as preview feature in JDK13, as Second Preview in JDK14, and becomes final in JDK15

379:Shenandoah: A Low-Pause-Time Garbage Collector

Shenandoah was introduced as an experimental in JDK12. Before JDK15 becomes Production;, it needs to be enabled through-XX:+UnlockExperimentalVMOptions-XX:+UseShenandoahGC. Now you only need-XX:+UseShenandoahGC to enable it.

381:Remove the Solaris and SPARC Ports

Solaris and SPARC Ports is marked as obsolete in JDK14 and officially removed in JDK15 version

383:Foreign-Memory Access API (Second Incubator)

Foreign-Memory Access API is introduced as incubating API in JDK14 and Second Incubator in JDK15

384:Records (Second Preview)

Records is introduced as preview in JDK14 and Second Preview in JDK15

385:Deprecate RMI Activation for Removal

JDK15 discarded RMI Activation and will be removed later

Detailed interpretation

The above list of major features, in addition to some api updates and obsolescence, mainly see JDK 15 Release Notes, here are a few examples.

Add item

Support for Unicode 13.0 (JDK-8239383)

Upgraded Unicode to support Unicode 13.0

Added isEmpty Default Method to CharSequence (JDK-8215401)

Added isEmpty method java.base/java/lang/CharSequence.java to CharSequence

/ * * Returns {@ code true} if this character sequence is empty. * * @ implSpec * The default implementation returns the result of calling {@ code length () = = 0}. * * @ return {@ code true} if {@ link # length ()} is {@ code 0}, otherwise * {@ code false} * * @ since 15 * / default boolean isEmpty () {return this.length () = = 0;}

Added Support for SO_INCOMING_NAPI_ID Support (JDK-8243099)

Jdk.net.ExtendedSocketOptions added SO_INCOMING_NAPI_ID selection.

Specialized Implementations of TreeMap Methods (JDK-8176894)

JDK15 provides putIfAbsent, computeIfAbsent, computeIfPresent, compute and merge methods for TreeMap and overriding implementation.

New Option Added to jcmd for Writing a gzipped Heap Dump (JDK-8237354)

Jcmd's GC.heap_dump command now supports gz selection. The gzip compressed version of heap;compression level is available from 1 (fastest) to 9 (slowest, but best compression) with dump. The default is 1.

New System Properties to Configure the TLS Signature Schemes (JDK-8242141)

Added jdk.tls.client.SignatureSchemes and jdk.tls.server.SignatureSchemes to configure TLS SignatureSchemes

Support for certificate_authorities Extension (JDK-8206925)

Support for certificate_authorities extensions

Remove item

Obsolete-XX:UseAdaptiveGCBoundary (JDK-8228991)

Eliminated.-XX:UseAdaptiveGCBoundary.

Abandoned item

Deprecated-XX:ForceNUMA Option (JDK-8243628)

Discarded the ForceNUMA option

Disable Native SunEC Implementation by Default (JDK-8237219)

Native SunEC Implementation is disabled by default

Known problem

Java.net.HttpClient Does Not Override Protocols Specified in SSLContext Default Parameters (JDK-8239594)

HttpClient does not now overwrite the Protocols specified in SSLContext Default Parameters

Other matters

DatagramPacket.getPort () Returns 0 When the Port Is Not Set (JDK-8237890)

When DatagramPacket does not set port, its getPort method returns 0

Improved Ergonomics for G1 Heap Region Size (JDK-8241670)

Optimized the calculation of the default G1 Heap Region Size

At this point, I believe you have a deeper understanding of "what are the new features of Java15"? you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report