都Java16了,你还在Java8?!

没错,甲骨文于April 20, 2021更新了Java™ SE Development Kit 16.0.1 (JDK 16.0.1)。

我们来看看Java16更新了什么。

1. JEP 389: Foreign Linker API (Incubator)

Introduce an API that offers statically-typed, pure-Java access to native code. This API, together with the Foreign-Memory API (JEP 393), will considerably simplify the otherwise error-prone process of binding to a native library.

外键API,介绍一个 API,它提供对本机代码的静态类型、纯 Java 访问

2.JEP 396: Strongly Encapsulate JDK Internals by Default

Strongly encapsulate all internal elements of the JDK by default, except for critical internal APIs such as sun.misc.Unsafe. Allow end users to choose the relaxed strong encapsulation that has been the default since JDK 9.

With this change, the default value of the launcher option --illegal-access is now deny rather than permit. As a consequence, existing code that uses most internal classes, methods, or fields of the JDK will fail to run. Such code can be made to run on JDK 16 by specifying --illegal-access=permit. That option will, however, be removed in a future release.

默认情况下强封装JDK内部

3.JEP 393: Foreign-Memory Access API (Third Incubator)

Introduce an API to allow Java programs to safely and efficiently access foreign memory outside of the Java heap.

内存外访问API,大概的意思就是允许访问堆栈内存外的API

4.JEP 390: Warnings for Value-based Classes

Users of the value-based classes provided by the standard libraries—notably including users of the primitive wrapper classes—should avoid relying on the identity of class instances. Programmers are strongly discouraged from calling the wrapper class constructors, which are now deprecated for removal. New javac warnings discourage synchronization on value-based class instances. Runtime warnings about synchronization can also be activated, using command-line option -XX:DiagnoseSyncOnValueBasedClasses.

基于值的类的警告

5.Add InvocationHandler::invokeDefault Method for Proxy's Default Method Support

A new method, invokeDefault, has been added to the java.lang.reflect.InvocationHandler interface to allow a default method defined in a proxy interface to be invoked.

为代理的默认方法支持添加 InvocationHandler::invokeDefault 方法

6.JEP 380: Unix domain sockets

Provides support for Unix domain sockets (AF_UNIX) in the java.nio.channelsSocketChannel, and ServerSocketChannel classes.

See JEP-380 for more information.

See also the following release note for information about the limitations in the support on Windows in JDK16.

See JDK-8238588

Unix 域套接字,这功能感觉还行

6.Day Period Support Added to java.time Formats

A new formatter pattern, letter 'B', and its supporting method have been added to java.time.format.DateTimeFormatter/DateTimeFormatterBuilder classes. The pattern and method translate day periods defined in Unicode Consortium's CLDR (https://unicode.org/reports/tr35/tr35-dates.html#dayPeriods). Applications can now express periods in a day, such as "in the morning" or "at night", not just am/pm. The following example demonstrates translating the day periods:

DateTimeFormatter.ofPattern("B").format(LocalTime.now()) 

This example produces day period text depending on the time of the day and locale.

日期支持添加到 java.time 格式,这功能也可以啊

7.Add Stream.toList() Method

A new method toList has been added to the java.util.Stream interface. This introduces a potential source incompatibility with classes that implement or interfaces that extend the Stream interface and that also statically import a toList method from elsewhere, for example, Collectors.toList. References to such methods must be changed to use a qualified name instead of a static import.

添加 Stream.toList() 方法,实用

8. JEP 338: Vector API (Incubator)

Provides an initial iteration of an incubator module, jdk.incubator.vector, to express vector computations that reliably compile at runtime to optimal vector hardware instructions on supported CPU architectures and thus achieve superior performance to equivalent scalar computations.

Vector API

9. Improved CompileCommand Flag

The CompileCommand flag has an option type that has been used for a collection of sub commands. These commands weren't verified for validity so spelling mistakes lead to the command being ignored. They had the form:

-XX:CompileCommand=option,,

All option commands now exist as ordinary commands with this form:

-XX:CompileCommand=

The option name is verified and the type is inferred. Helpful error messages are given if the command name doesn't exist, or if the value doesn't match the type of the command. All command names are case insensitive.

The old syntax for option commands can still be used. Verification that the option name, value type, and value is consistent has been added.

All available options can be listed with:

-XX:CompileCommand=help 

改进CompileCommand

10.JEP 392: Packaging Tool

Provides the jpackage tool, for packaging self-contained Java applications. The jpackage tool was introduced as an incubating tool in JDK 14 by JEP 343. It remained an incubating tool in JDK 15, to allow time for additional feedback. It has been promoted in JDK 16 from incubation to a production-ready feature. As a consequence of this transition, the name of the jpackage module has changed from jdk.incubator.jpackage to jdk.jpackage.

打包工具

还有挺多更新内容,有兴趣的自己去官网看看

https://www.oracle.com/java/technologies/javase/16-relnotes.html

jdk

https://www.oracle.com/java/technologies/javase-downloads.html#JDK16

延伸

在甲骨文官网搜到一个挺有意思的help

Is Java still free?

The current version of Java - Java SE 11 is available from Oracle under an open source license at http://jdk.java.net/11/. Java SE 8 remains free of charge for general purpose desktop and server use and is available under the Oracle Binary Code License (BCL) at https://www.oracle.com/java/technologies/javase-downloads.html.

意思就是Java11之前都还可以免费用,Java12开始估计就得收费了。不过这Java8估计还能用十年。

 

 

你可能感兴趣的:(javaSE,Java16,java,jdk)