您的位置 首页 java

JDK8新特性总览,官方原文说明加高质量翻译

前言

2022年9月20号,JDK19发布,从1996年1月SUN公司发布JDK1.0正式发布已经走过了26个年头,包括三个长期支持版本JDK8、JDK11、JDK17

目前JDK11使用率在48.44%,JDK8的使用率仍高达46.45%,JDK17仅仅0.37%,JDK11并没有特别突出的更新,目前绝大多数的变化都在JDK8中

本文章仍为系列文章,带您一步一步 系统完整的理解和掌握JDK8的新特性

本篇是对Java8新特性的总览说明,也是系列文章第一篇,官网原汁原味 + 优质个人理解翻译,带您了解JDK8到底有哪些改进!如果觉得不错还请点赞、关注哦!

Java Programming Language【Java编程语言】

  • Lambda Expressions, a new language feature, has been introduced in this release. They enable you to treat functionality as a method argument, or code as data. Lambda expressions let you express instances of single-method interfaces (referred to as functional interfaces) more compactly.
    翻译:Lambda表达式是一种新的语言特性,已在本版本中引入。它们使您能够将功能视为方法参数,或将代码视为数据。 Lambda表达式 允许您更紧凑地表达单个方法接口(称为函数接口)的实例
  • Method references provide easy-to-read lambda expressions for methods that already have a name.
    翻译:方法引用为已具有名称的方法提供了易于读取的lambda表达式
  • Default methods enable new functionality to be added to the interfaces of libraries and ensure binary compatibility with code written for older versions of those interfaces.
    翻译:默认方法允许将新功能添加到库的接口中,并确保与为这些接口的旧版本编写的代码的二进制兼容性
  • Repeating annotation s provide the ability to apply the same annotation type more than once to the same declaration or type use.
    翻译:重复注释,提供了将同一注释类型多次应用于同一声明或类型使用的能力。
  • Type Annotations provide the ability to apply an annotation anywhere a type is used, not just on a declaration. Used with a pluggable type system, this feature enables improved type checking of your code.
    翻译:类型注释提供了在使用类型的任何地方应用注释的能力,而不仅仅是在声明上。与可插拔类型系统一起使用时,此功能可以改进代码的类型检查
  • Improved type inference.
    翻译:改进的类型推断
  • Method parameter reflection.
    翻译:方法参数反射

Collections【集合】

  • Classes in the new java.util.stream package provide a Stream API to support functional-style operations on streams of elements. The Stream API is integrated into the Collections API, which enables bulk operations on collections, such as sequential or parallel map-reduce transformations.
    翻译:新java.util.stream包提供了一个StreamAPI,以支持对元素通过函数式编程的流式操作。流API集成到集合API中,该API支持对集合进行批量操作,例如顺序或并行映射减少转换
  • Performance Improvement for HashMaps with Key Collisions
    翻译:具有密钥冲突的HashMaps的性能改进

[Compact Profiles] contain predefined subsets of the Java SE platform and enable applications that do not require the entire Platform to be deployed and run on small devices.

翻译:【精简配置文件】包含Java SE平台的预定义子集,并支持不需要在小型设备上部署和运行整个平台的应用程序

[Security]:安全

  • Client-side TLS 1.2 enabled by default
    翻译:默认情况下已启用客户端TLS 1.2
  • New variant of AccessController.doPrivileged that enables code to assert a subset of its privileges, without preventing the full traversal of the stack to check for other permissions
    翻译:AccessController的新变体,AccessController.doPrivileged,它使代码能够断言其特权的子集,而不会阻止对堆栈的完整遍历以检查其他权限
  • Stronger algorithms for password-based encryption
    翻译:更强大的基于密码的加密算法
  • SSL/TLS Server Name Indication (SNI) Extension support in JSSE Server
    翻译:JSSE服务器中的SSL/TLS服务器名称指示(SNI)扩展支持
  • Support for AEAD algorithms: The SunJCE provider is enhanced to support AES/GCM/NoPadding cipher implementation as well as GCM algorithm parameters. And the SunJSSE provider is enhanced to support AEAD mode based cipher suites. See Oracle Providers Documentation, JEP 115.
    翻译:对AEAD算法的支持:SunJCE提供程序得到增强,支持AES/GCM/NoPadding密码实现以及GCM算法参数。SunJSSE提供程序经过增强,支持基于AEAD模式的密码套件。请参阅 Oracle 提供商文档,JEP 115
  • KeyStore enhancements, including the new Domain KeyStore type java.security.DomainLoadStoreParameter, and the new command option -importpassword for the keytool utility
    翻译:KeyStore增强功能,包括新的Domain KeyStore类型`java.security.DomainLoadStoreParameter”和keytool实用程序的新命令选项“-importpassword”
  • SHA-224 Message Digests
    翻译:SHA-224消息摘要
  • Enhanced Support for NSA Suite B Cryptography
    翻译:增强了对NSA Suite B加密的支持
  • Better Support for High Entropy Random Number Generation
    翻译:更好地支持高熵随机数生成
  • New java.security.cert.PKIXRevocationChecker class for configuring revocation checking of X.509 certificates
    翻译:用于配置X.509证书的吊销检查的新 java .security.cert.PKIXRevocationChecker类
  • 64-bit PKCS11 for Windows
    翻译:用于Windows的64位PKCS11
  • New rcache Types in Kerberos 5 Replay Caching
    翻译:Kerberos 5 Replay缓存中的新rcache类型
  • Support for Kerberos 5 Protocol Transition and Constrained Delegation
    翻译:支持Kerberos 5协议转换和受限委派
  • Kerberos 5 weak encryption types disabled by default
    翻译:默认情况下禁用Kerberos 5弱加密类型
  • Unbound SASL for the GSS-API/Kerberos 5 mechanism
    翻译:GSS-API/Kerbos5机制的未绑定SASL
  • SASL service for multiple host names
    翻译:用于多个主机名的SASL服务
  • JNI bridge to native JGSS on Mac OS X
    翻译:JNI桥接到Mac OS X上的本地JGSS
  • Support for stronger strength ephemeral DH keys in the SunJSSE provider
    翻译:在SunJSSE提供程序中支持更强强度的临时DH密钥
  • Support for server-side cipher suites preference customization in JSSE
    翻译:支持JSSE中的服务器端密码套件首选项自定义

javafx :Java桌面应用

  • The new Modena theme has been implemented in this release. For more information, see the blog at 【fxexperience.com】.
    翻译:新的 Modena 主题已在本版本中实现。有关更多信息,请参阅fxexperience.com上的博客
  • The new Swing Node class enables developers to embed Swing content into JavaFX applications. See the [SwingNode] javadoc and [Embedding Swing Content in JavaFX Applications]
    翻译:新的“SwingNode”类使开发人员能够将Swing内容嵌入到JavaFX应用程序中,参见【SwingNode】和【Embedding Swing Content in JavaFX Applications】
  • The new UI Controls include the [DatePicker] and the [TreeTableView]controls.
    翻译:新的UI控件包括【DatePicker】和【TreeTableView】控件
  • The javafx.print package provides the public classes for the JavaFX Printing API. See the [javadoc]for more information.
    翻译:javafx.print包为JavaFX Printing API提供了公共类。有关更多信息,请参阅[javadoc]
  • The 3D graphics features now include 3D shapes, camera, lights, subscene, material, picking, and antialiasing. The new Shape3D (Box, Cylinder, MeshView, and Sphere subclasses), SubScene, Material, PickResult, LightBase (AmbientLight and PointLight subclasses) , and SceneAntialiasing API classes have been added to the JavaFX 3D Graphics library. The Camera API class has also been updated in this release. See the corresponding class javadoc for javafx.scene.shape.Shape3D, JavaFX .scene.SubScene, Java fx.scene.paint.Material, javafx.scene.input.PickResult, javafx.scene.SceneAntialiasing, and the [Getting Started with JavaFX 3D Graphics]document.
    翻译:3D图形功能现在包括3D形状、相机、灯光、子场景、材质、拾取和抗锯齿。新的 “Shape3D”(“Box”、“Cylinder”、“MeshView”和“Sphere”子类)、“SubScene”、“Material”、“PickResult”、”LightBase“(“AmbientLight”和“PointLight”子类”)和“SceneInstance”API类已添加到JavaFX 3D图形库中。在此版本中还更新了“Camera”API类。请参见javafx.scene.shape.Shape3D,javafx.scene.SubScene,javafx.scene.paint.Material,javafx.scene.input.PickResult,javafx.scene.SceneAntiliasing和【Getting Started with JavaFX 3D Graphics】文档
  • The WebView class provides new features and improvements. Review [Supported Features of HTML5]for more information about additional HTML5 features including Web Sockets, Web Workers, and Web Fonts.
    翻译:“WebView”类提供了新的功能和改进。查看【Supported Features of HTML5】了解更多有关 HTML5 功能的信息,包括Web套接字、Web Workers和Web字体
  • Enhanced text support including bi-directional text and complex text scripts such as Thai and Hindi in controls, and multi-line, multi-style text in text nodes.
    翻译:增强的文本支持,包括双向文本和复杂文本脚本,如控件中的泰语和印地语,以及文本节点中的多行、多样式文本
  • Support for Hi-DPI displays has been added in this release.
    翻译:此版本中添加了对高DPI显示器的支持。
  • The CSS Styleable* classes became public API. See the [javafx.css] javadoc for more information.
    翻译:CSS Styleable*类成为公共API。有关更多信息,请参阅【javafx.css】javadoc
  • The new [ScheduledService] class allows to automatically restart the service.
    翻译:新的【ScheduledService】类允许自动重新启动服务。
  • JavaFX is now available for ARM platforms. JDK for ARM includes the base, graphics and controls components of JavaFX.
    翻译:JavaFX现在可用于ARM平台。JDK for ARM包括JavaFX的基础、图形和控件组件。

[Tools]:工具

  • The jjs command is provided to invoke the Nashorn engine.
    翻译:“jjs”命令用于调用Nashorn引擎。
  • The java command launches JavaFX applications.
    翻译:“java”命令启动JavaFX应用程序。
  • The java man page has been reworked.
    翻译:“java”手册页已被修改。
  • The jdeps command-line tool is provided for analyzing class files.
    翻译:“jdeps”命令行工具用于分析类文件。
  • Java Management Extensions ( JMX ) provide remote access to diagnostic commands.
    翻译:Java管理扩展(JMX)提供对诊断命令的远程访问。
  • The jar signer tool has an option for requesting a signed time stamp from a Time Stamping Authority (TSA).
    翻译:“jarsigner”工具可以选择向时间戳管理局(TSA)请求签名的时间戳。

[ Javac tool]

  • The -parameters option of the javac command can be used to store formal parameter names and enable the Reflection API to retrieve formal parameter names.
    翻译:“javac”命令的“-parameters”选项可用于存储正式参数名,并使反射API能够检索正式参数名。
  • The type rules for equality operators in the Java Language Specification (JLS) Section 15.21 are now correctly enforced by the javac command.
    翻译:Java语言规范(JLS)第15.21节中的相等运算符的类型规则现在由“javac”命令正确执行。
  • The javac tool now has support for checking the content of javadoc comments for issues that could lead to various problems, such as invalid HTML or accessibility issues, in the files that are generated when javadoc is run. The feature is enabled by the new -Xdoclint option. For more details, see the output from running “javac -X”. This feature is also available in the javadoc tool, and is enabled there by default.
    翻译:“javac”工具现在支持检查“javadoc”注释的内容,以查找在运行“ javadoc ”时生成的文件中可能导致各种问题的问题,例如无效的 HTML 或可访问性问题。该功能由新的“-Xdoclint”选项启用。有关详细信息,请参阅运行“javac-X”的输出。该功能也可在“javadoc”工具中使用,默认情况下在该工具中启用
  • The javac tool now provides the ability to generate native headers, as needed. This removes the need to run the javah tool as a separate step in the build pipeline. The feature is enabled in javac by using the new -h option, which is used to specify a directory in which the header files should be written. Header files will be generated for any class which has either native methods, or constant fields annotated with a new annotation of type java.lang.annotation.Native.
    翻译:“javac”工具现在可以根据需要生成本机标头。这就不需要将“javah”工具作为构建管道中的一个单独步骤来运行。通过使用新的“-h”选项在“javac”中启用该功能,该选项用于指定头文件应写入的目录。将为任何具有本机方法或用类型为“java.lang.annotation.native”的新注释注释的常量字段的类生成头文件。

Javadoc tool

  • The javadoc tool supports the new DocTree API that enables you to traverse Javadoc comments as abstract syntax trees.
    翻译:“javadoc”工具支持新的“DocTree”API,该API允许您将javadoc注释作为抽象语法树进行遍历。
  • The javadoc tool supports the new Javadoc Access API that enables you to invoke the Javadoc tool directly from a Java application, without executing a new process. See the [javadoc what’s new]page for more information.
    翻译:“javadoc”工具支持新的javadoc访问API,该API允许您直接从Java应用程序调用javadoc工具,而无需执行新流程。有关更多信息,请参阅【javadocwhat’snew】页面。
  • The javadoc tool now has support for checking the content of javadoc comments for issues that could lead to various problems, such as invalid HTML or accessibility issues, in the files that are generated when javadoc is run. The feature is enabled by default, and can also be controlled by the new -Xdoclint option. For more details, see the output from running “javadoc -X”. This feature is also available in the javac tool, although it is not enabled by default there.
    翻译:“javadoc”工具现在支持检查“javadoc”注释的内容,以查找在运行“javadoc”时生成的文件中可能导致各种问题的问题,例如无效的HTML或可访问性问题。默认情况下,该功能已启用,也可以通过新的“-Xdoclint”选项进行控制。有关详细信息,请参阅运行“javadoc-X”的输出。这个特性也可以在“javac”工具中使用,尽管默认情况下没有启用。

[Internationalization]:国际化

  • Unicode Enhancements, including support for Unicode 6.2.0
    翻译:Unicode增强功能,包括对Unicode 6.2.0的支持
  • Adoption of Unicode CLDR Data and the java.locale.providers System Property
    翻译:采用Unicode CLDR数据和java.locale。提供程序系统属性
  • New Calendar and Locale APIs
    翻译:新的日历和区域设置API
  • Ability to Install a Custom Resource Bundle as an Extension
    翻译:能够将自定义资源捆绑包安装为扩展

[Deployment]:部署

  • For sandbox applets and Java Web Start applications, URLPermission is now used to allow connections back to the server from which they were started. SocketPermission is no longer granted.
    翻译:对于沙盒小程序和Java Web Start应用程序,“URLPermission”现在用于允许连接到启动它们的服务器SocketPermission不再被授予
  • The Permissions attribute is required in the JAR file manifest of the main JAR file at all security levels.
    翻译:所有安全级别的主JAR文件的JAR文件清单中都需要Permissions属性。

[Date-Time Package] – a new set of packages that provide a comprehensive date-time model.

翻译: [日期时间包] -一组新的包,提供了全面的日期时间模型。

[Scripting]:编写脚本

  • The Rhino javascript engine has been replaced with the 【Nashorn】Javascript Engine
    翻译:Rhino javascript引擎已被【Nashorn】javascript引擎取代

[Pack200]

  • Pack200 Support for Constant Pool Entries and New Bytecodes Introduced by JSR 292
    翻译:JSR292引入的对常量池项和新字节码的Pack200支持
  • JDK8 support for class files changes specified by JSR-292, JSR-308 and JSR-335
    翻译:JDK8支持JSR-292、JSR-308和JSR-335指定的类文件更改

[IO and NIO]

  • New SelectorProvider implementation for Solaris based on the Solaris event port mechanism. To use, run with the system property java.nio.channels.spi.Selector set to the value sun.nio.ch.EventPortSelectorProvider.
    翻译:基于Solaris事件端口机制的Solaris新“SelectorProvider”实现。请使用系统属性`java.nio.chhannels.spi运行。选择器“设置为值”sun.nio.ch.EventPortSelectorProvider“。
  • Decrease in the size of the <JDK_HOME>/jre/lib/charsets.jar file
    翻译:减小`<JDK_HOME>/jre/lib/charsets.jar文件的大小
  • Performance improvement for the java.lang.String(byte[], *) constructor and the java.lang.String.getBytes() method.
    翻译:“java.lang.String(byte[],*)”构造函数和“java.lang.String”的性能改进。getBytes()`方法。

[java.lang and java.util Packages]

  • Parallel Array Sorting
    翻译:并行阵列排序
  • Standard Encoding and Decoding Base64
    翻译:标准编码和解码Base64
  • Unsigned Arithmetic Support
    翻译:无符号算术支持

[JDBC]

  • The JDBC-ODBC Bridge has been removed.
    翻译:JDBC-ODBC桥已删除。
  • JDBC 4.2 introduces new features.
    翻译:JDBC4.2引入了新特性。

Java DB

  • JDK 8 includes Java DB 10.10.
    翻译:JDK 8包括Java DB 10.10。

[Networking]

  • The class java.net.URLPermission has been added.
    翻译:添加java.net.URLPermission类。
  • In the class java.net.HttpURLConnection, if a security manager is installed, calls that request to open a connection require permission.
    翻译:在类java.net.HttpURLConnection中,如果安装了安全管理器,则调用打开连接的请求需要权限。

[Concurrency]:并发性

  • Classes and interfaces have been added to the java.util.concurrent package.
    翻译:类和接口已添加到java.util.concurrent包中。
  • Methods have been added to the java.util.concurrent.ConcurrentHashMap class to support aggregate operations based on the newly added streams facility and lambda expressions.
    翻译:方法已添加到java.util.concurrent.ConcurrentHashMap类支持基于新添加的流设施和lambda表达式的聚合操作
  • Classes have been added to the java.util.concurrent.atomic package to support scalable updatable variables.
    翻译:类已添加到java.util.concurrent.atomic包,以支持可扩展的可更新变量。
  • Methods have been added to the java.util.concurrent.ForkJoinPool class to support a common pool.
    翻译:方法已添加到java.util.concurrent.ForkJoinPool类以支持公共池。
  • The java.util.concurrent.locks.StampedLock class has been added to provide a capability-based lock with three modes for controlling read/write access.
    翻译:添加了“java.util.concurrent.locks.StampedLock”类,以提供具有三种模式的基于功能的锁,用于控制读/写访问

[HotSpot]:Java默认虚拟机型号

  • Hardware intrinsics were added to use Advanced Encryption Standard (AES). The UseAES andUseAESIntrinsicsflags are available to enable the hardware-based AES intrinsics for Intel hardware. The hardware must be 2010 or newer Westmere hardware. Note: AES intrinsics are only supported by the Server VM.
    翻译:添加硬件内部函数以使用高级加密标准(AES)。“UseAES”和“UseAESIntensics”标志可用于为Intel硬件启用基于硬件的AES内部函数。硬件必须是2010年或更新的Westmere硬件 注意: AES内部函数仅受Server VM支持。
    For example, to enable hardware AES, use the following flags: -XX:+UseAES -XX:+UseAESIntrinsics
    翻译:例如,要启用硬件AES,请使用以下标志:-XX:+UseAES-XX:+UseAESIntensics
    To disable hardware AES use the following flags: -XX:-UseAES -XX:-UseAESIntrinsics
    翻译:要禁用硬件AES,请使用以下标志:-XX:-UseAES-XX:-UseAESIntensics
  • Removal of PermGen.
    翻译:拆除PermGen。
  • Default Methods in the Java Programming Language are supported by the byte code instructions for method invocation.
    翻译:用于方法调用的字节码指令支持Java编程语言中的默认方法。

[Java Mission Control 5.3 Release Notes]

  • JDK 8 includes Java Mission Control 5.3.
    翻译:JDK 8包括Java任务控制5.3。

总结

总的来说JDK主要更新在一下几个地方:

  • 编程语法:Lambda表达式、函数式接口、接口默认实现、注释、反射、类型推断等
  • 集合:增加流式操作,改进HashMap性能
  • 安全:在算法、加密、服务器等多方面增强安全性
  • Java桌面应用的更新,使用较少
  • 工具:比如java、javadoc、jjs等命令的变化和升级
  • 国际化:编码、解码的升级、新的日历类、新的日期类
  • 部署:方便部署,提高jar的安全性
  • 脚本:使用Nashorn引擎替换Rhino js引擎,速度更快
  • IO:减小charsets.jar大小,提升String性能
  • 网络:增加相关网络类,提高安全性
  • 并发:新增juc包和部分并发类
  • 虚拟机:使用HotSpot作为默认虚拟机,剔除PermGen【永久代】使用metaspace【元空间】替代等

JDK8的更新是一个里程碑的更新,对Java的意义重大,推向另一个层次!

文章来源:智云一二三科技

文章标题:JDK8新特性总览,官方原文说明加高质量翻译

文章地址:https://www.zhihuclub.com/196653.shtml

关于作者: 智云科技

热门文章

网站地图