Skip to content

Commit ff1d728

Browse files
committed
1223
1 parent 4d6aa3a commit ff1d728

1 file changed

Lines changed: 231 additions & 1 deletion

File tree

docs/java/java8.md

Lines changed: 231 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,216 @@ Java8 新增了非常多的特性,我们主要讨论以下几个:
3131

3232

3333

34+
Java8
35+
36+
- Java编程语言
37+
- Lambda表达式: 它们使您能够将功能视为方法参数,或将代码视为数据
38+
- Method references provide easy-to-read lambda expressions for methods that already have a name.
39+
- 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.
40+
- Repeating Annotations provide the ability to apply the same annotation type more than once to the same declaration or type use.
41+
- 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.
42+
- Improved type inference.
43+
- Method parameter reflection.
44+
45+
- 集合
46+
- Stream API:新java.util中的类。stream包提供了一个流API来支持对元素流的函数式操作
47+
- 具有键冲突的hashmap的性能改进
48+
49+
- [Compact Profiles](http://docs.oracle.com/javase/8/docs/technotes/guides/compactprofiles/) 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.
50+
51+
- [Security](http://docs.oracle.com/javase/8/docs/technotes/guides/security/enhancements-8.html)
52+
53+
- Client-side TLS 1.2 enabled by default
54+
- 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
55+
- Stronger algorithms for password-based encryption
56+
- SSL/TLS Server Name Indication (SNI) Extension support in JSSE Server
57+
- 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.
58+
- KeyStore enhancements, including the new Domain KeyStore type `java.security.DomainLoadStoreParameter`, and the new command option `-importpassword` for the keytool utility
59+
- SHA-224 Message Digests
60+
- Enhanced Support for NSA Suite B Cryptography
61+
- Better Support for High Entropy Random Number Generation
62+
- New `java.security.cert.PKIXRevocationChecker` class for configuring revocation checking of X.509 certificates
63+
- 64-bit PKCS11 for Windows
64+
- New rcache Types in Kerberos 5 Replay Caching
65+
- Support for Kerberos 5 Protocol Transition and Constrained Delegation
66+
- Kerberos 5 weak encryption types disabled by default
67+
- Unbound SASL for the GSS-API/Kerberos 5 mechanism
68+
- SASL service for multiple host names
69+
- JNI bridge to native JGSS on Mac OS X
70+
- Support for stronger strength ephemeral DH keys in the SunJSSE provider
71+
- Support for server-side cipher suites preference customization in JSSE
72+
73+
- [JavaFX](http://docs.oracle.com/javase/8/javase-clienttechnologies.htm)
74+
75+
-
76+
The new Modena theme has been implemented in this release. For more information, see the blog at [fxexperience.com](http://fxexperience.com/2013/03/modena-theme-update/).
77+
- The new `SwingNode` class enables developers to embed Swing content into JavaFX applications. See the [`SwingNode`](http://docs.oracle.com/javase/8/javafx/api/javafx/embed/swing/SwingNode.html) javadoc and [Embedding Swing Content in JavaFX Applications](http://docs.oracle.com/javase/8/javafx/interoperability-tutorial/embed-swing.htm).
78+
- The new UI Controls include the [`DatePicker`](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/DatePicker.html) and the [`TreeTableView`](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TreeTableView.html) controls.
79+
- The `javafx.print` package provides the public classes for the JavaFX Printing API. See the [javadoc](http://docs.oracle.com/javase/8/javafx/api/javafx/print/package-summary.html) for more information.
80+
- 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`, `javafx.scene.paint.Material`, `javafx.scene.input.PickResult`, `javafx.scene.SceneAntialiasing`, and the [Getting Started with JavaFX 3D Graphics](http://docs.oracle.com/javase/8/javafx/graphics-tutorial/javafx-3d-graphics.htm) document.
81+
- The `WebView` class provides new features and improvements. Review [Supported Features of HTML5](http://docs.oracle.com/javase/8/javafx/embedded-browser-tutorial/index.html) for more information about additional HTML5 features including Web Sockets, Web Workers, and Web Fonts.
82+
- 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.
83+
- Support for Hi-DPI displays has been added in this release.
84+
- The CSS Styleable* classes became public API. See the [`javafx.css`](http://docs.oracle.com/javase/8/javafx/api/javafx/css/package-frame.html) javadoc for more information.
85+
- The new [`ScheduledService`](http://docs.oracle.com/javase/8/javafx/api/javafx/concurrent/ScheduledService.html) class allows to automatically restart the service.
86+
- JavaFX is now available for ARM platforms. JDK for ARM includes the base, graphics and controls components of JavaFX.
87+
88+
- [Tools](http://docs.oracle.com/javase/8/docs/technotes/tools/enhancements-8.html)
89+
90+
- The `jjs` command is provided to invoke the Nashorn engine.
91+
- The `java` command launches JavaFX applications.
92+
- The `java` man page has been reworked.
93+
- The `jdeps` command-line tool is provided for analyzing class files.
94+
- Java Management Extensions (JMX) provide remote access to diagnostic commands.
95+
- The `jarsigner` tool has an option for requesting a signed time stamp from a Time Stamping Authority (TSA).
96+
- [Javac tool](http://docs.oracle.com/javase/8/docs/technotes/guides/javac/index.html)
97+
- 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.
98+
- The type rules for equality operators in the Java Language Specification (JLS) Section 15.21 are now correctly enforced by the `javac` command.
99+
- 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.
100+
- 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`.
101+
- [Javadoc tool](http://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/whatsnew-8.html)
102+
- The `javadoc` tool supports the new `DocTree` API that enables you to traverse Javadoc comments as abstract syntax trees.
103+
- 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](http://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/whatsnew-8.html) page for more information.
104+
- 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.
105+
106+
- [Internationalization](http://docs.oracle.com/javase/8/docs/technotes/guides/intl/enhancements.8.html)国际化
107+
108+
- Unicode增强,包括对Unicode 6.2.0的支持
109+
- Adoption of Unicode CLDR Data and the java.locale.providers System Property
110+
- New Calendar and Locale APIs
111+
- Ability to Install a Custom Resource Bundle as an Extension
112+
113+
- [Deployment](http://docs.oracle.com/javase/8/docs/technotes/guides/jweb/enhancements-8.html)部署
114+
115+
- 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.
116+
- The Permissions attribute is required in the JAR file manifest of the main JAR file at all security levels.
117+
118+
- [Date-Time Package](http://docs.oracle.com/javase/8/docs/technotes/guides/datetime/index.html) - a new set of packages that provide a comprehensive date-time model.
119+
120+
- [Scripting](http://docs.oracle.com/javase/8/docs/technotes/guides/scripting/enhancements.html#jdk8)
121+
122+
- The Rhino javascript engine has been replaced with the [Nashorn](http://docs.oracle.com/javase/8/docs/technotes/guides/scripting/nashorn/) Javascript Engine
123+
124+
- [Pack200](http://docs.oracle.com/javase/8/docs/technotes/guides/pack200/enhancements.html)
125+
126+
- Pack200 Support for Constant Pool Entries and New Bytecodes Introduced by JSR 292
127+
- JDK8 support for class files changes specified by JSR-292, JSR-308 and JSR-335
128+
129+
- [IO and NIO](http://docs.oracle.com/javase/8/docs/technotes/guides/io/enhancements.html#jdk8)
130+
131+
- 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`.
132+
- Decrease in the size of the `/jre/lib/charsets.jar` file
133+
- Performance improvement for the `java.lang.String(byte[], *)` constructor and the `java.lang.String.getBytes()` method.
134+
135+
- [java.lang and java.util Packages](http://docs.oracle.com/javase/8/docs/technotes/guides/lang/enhancements.html#jdk8)
136+
137+
- Parallel Array Sorting
138+
- Standard Encoding and Decoding Base64
139+
- Unsigned Arithmetic Support
140+
141+
- [JDBC](http://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/)
142+
143+
- The JDBC-ODBC Bridge has been removed.
144+
- JDBC 4.2 introduces new features.
145+
146+
- Java DB
147+
148+
- JDK 8 includes Java DB 10.10.
149+
150+
- [Networking](http://docs.oracle.com/javase/8/docs/technotes/guides/net/enhancements-8.0.html)
151+
152+
- The class `java.net.URLPermission` has been added.
153+
- In the class `java.net.HttpURLConnection`, if a security manager is installed, calls that request to open a connection require permission.
154+
155+
- [Concurrency](http://docs.oracle.com/javase/8/docs/technotes/guides/concurrency/changes8.html)
156+
157+
- Classes and interfaces have been added to the `java.util.concurrent` package.
158+
- 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.
159+
- Classes have been added to the `java.util.concurrent.atomic` package to support scalable updatable variables.
160+
- Methods have been added to the `java.util.concurrent.ForkJoinPool` class to support a common pool.
161+
- The `java.util.concurrent.locks.StampedLock` class has been added to provide a capability-based lock with three modes for controlling read/write access.
162+
163+
- [Java XML](http://docs.oracle.com/javase/8/docs/technotes/guides/xml/enhancements.html) - [JAXP](http://docs.oracle.com/javase/8/docs/technotes/guides/xml/jaxp/enhancements-8.html)
164+
165+
- [HotSpot](http://docs.oracle.com/javase/8/docs/technotes/guides/vm/)
166+
167+
- Hardware intrinsics were added to use Advanced Encryption Standard (AES). The `UseAES` and `UseAESIntrinsics` flags are available to enable the hardware-based AES intrinsics for Intel hardware. The hardware must be 2010 or newer Westmere hardware.
168+
169+
**Note:** AES intrinsics are only supported by the Server VM.
170+
171+
For example, to enable hardware AES, use the following flags:
172+
173+
```
174+
-XX:+UseAES -XX:+UseAESIntrinsics
175+
```
176+
177+
To disable hardware AES use the following flags:
178+
179+
```
180+
-XX:-UseAES -XX:-UseAESIntrinsics
181+
```
182+
183+
- Removal of PermGen.
184+
185+
- Default Methods in the Java Programming Language are supported by the byte code instructions for method invocation.
186+
187+
- [Java Mission Control 5.3 Release Notes](http://www.oracle.com/technetwork/java/javase/jmc53-release-notes-2157171.html)
188+
189+
- JDK 8 includes Java Mission Control 5.3.
190+
191+
[![E-mail this page](https://www.oracle.com/us/assets/email.gif)](javascript:mailpage()) [E-mail this page](javascript:mailpage()) [![Printer View](https://www.oracle.com/us/assets/print_icon.gif) Printer View](javascript: void 0;)
192+
193+
##### Resources for
194+
195+
- [Developers](https://developer.oracle.com/)
196+
- [Startups](https://www.oracle.com/startup/)
197+
- [Students and Educators](https://academy.oracle.com/en/oa-web-overview.html)
198+
199+
200+
201+
##### Partners
202+
203+
- [Oracle PartnerNetwork](https://www.oracle.com/partnernetwork/)
204+
- [Find a Partner](https://solutions.oracle.com/scwar/scr/Partners/index.html)
205+
- [Log in to OPN](https://www.oracle.com/partners/)
206+
207+
208+
209+
##### How We Operate
210+
211+
- [Corporate Security Practices](https://www.oracle.com/corporate/security-practices/)
212+
- [Corporate Responsibility](https://www.oracle.com/corporate/citizenship/)
213+
- [Diversity and Inclusion](https://www.oracle.com/corporate/careers/diversity/)
214+
215+
216+
217+
##### Contact Us
218+
219+
- [US Sales: +1.800.633.0738](tel:18006330738)
220+
- [Global Contacts](https://www.oracle.com/corporate/contact/global.html)
221+
- [Subscribe to emails](https://go.oracle.com/subscriptions)
222+
223+
224+
225+
-
226+
-
227+
-
228+
-
229+
230+
- [© 2019 Oracle](https://www.oracle.com/legal/copyright.html)
231+
- [Site Map](https://www.oracle.com/sitemap.html)
232+
- [Terms of Use and Privacy](https://www.oracle.com/legal/privacy/index.html)
233+
-
234+
- Cookie 喜好设置
235+
- [Ad Choices](https://www.oracle.com/legal/privacy/marketing-cloud-data-cloud-privacy-policy.html#12)
236+
- [Careers](https://www.oracle.com/corporate/careers/)
237+
238+
-
239+
240+
241+
242+
243+
34244
Java 8新特性简介
35245
36246
 速度更快
@@ -51,17 +261,27 @@ Java 8新特性简介
51261
52262
## Lambda表达式
53263
264+
Lambda表达式使您能够封装单个行为单元并将其传递给其他代码。如果希望对集合的每个元素、流程完成时或流程遇到错误时执行某个操作,可以使用lambda表达式。Lambda表达式由以下特性支持:
265+
266+
- [Method References](http://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html) are compact, easy-to-read lambda expressions for methods that already have a name.
267+
- [Default Methods](http://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html) enable you to add new functionality to the interfaces of your libraries and ensure binary compatibility with code written for older versions of those interfaces. They are interface methods that have an implementation and the `default` keyword at the beginning of the method signature. In addition, you can define static methods in interfaces.
268+
- [New and Enhanced APIs That Take Advantage of Lambda Expressions and Streams in Java SE 8](https://docs.oracle.com/javase/8/docs/technotes/guides/language/lambda_api_jdk8.html) describe new and enhanced classes that take advantage of lambda expressions and streams.
269+
270+
271+
54272
Lambda 是一个匿名函数,我们可以把 Lambda表达式理解为是一段可以传递的代码(将代码 像数据一样进行传递)。可以写出更简洁、更 灵活的代码。作为一种更紧凑的代码风格,使Java的语言表达能力得到了提升。
55273
56274
57275
276+
匿名类的一个问题是,如果您的匿名类的实现非常简单,例如一个接口只包含一个方法,那么匿名类的语法可能看起来很笨拙和不清楚。在这些情况下,您通常试图将功能作为参数传递给另一个方法,例如当有人单击按钮时应该采取什么操作。Lambda表达式允许您这样做,将功能视为方法参数,或将代码视为数据。
277+
58278
59279
60280
Lambda 表达式语法
61281
62282
Lambda 表达式在Java 语言中引入了一个新的语法元 素和操作符。这个操作符为 “->” , 该操作符被称 为 Lambda 操作符或剪头操作符。它将 Lambda 分为 两个部分:
63283
64-
左侧:指定了 Lambda 表达式需要的所有参数
284+
左侧:指定了 Lambda 表达式需要的所有参数
65285
66286
右侧:指定了 Lambda 体,即 Lambda 表达式要执行的功能。
67287
@@ -85,6 +305,10 @@ Lambda 表达式在Java 语言中引入了一个新的语法元 素和操作符
85305
86306
语法格式五:当 Lambda 体只有一条语句时,return 与大括号可以省略
87307
308+
```
309+
email -> System.out.println(email)
310+
```
311+
88312
89313
90314
语法格式六:
@@ -97,6 +321,12 @@ Lambda 表达式在Java 语言中引入了一个新的语法元 素和操作符
97321
98322
99323
324+
Lambda表达式的理想用例
325+
326+
假设您正在创建一个社交网络应用
327+
328+
329+
100330
101331
102332
## 函数式接口

0 commit comments

Comments
 (0)