Skip to content

Commit fe27f3a

Browse files
committed
java 15 新特性
1 parent e87e939 commit fe27f3a

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,25 @@
113113

114114
---
115115

116-
- [instanceof模式识别 增强](java-14/src/main/java/com/di1shuai/java14/instance/InstanceOfDemo.java)
116+
- [instanceof模式识别 增强](java-14/src/main/java/com/di1shuai/java14/instance/InstanceOfDemo.java)(预览)
117117
- [Record 类型](java-14/src/main/java/com/di1shuai/java14/record/RecordDemo.java)
118118
- [异常信息提示改进](java-14/src/main/java/com/di1shuai/java14/nullexception/NullPointerExceptionDemo.java)
119119
- 其他
120120
- G1 的 NUMA 可识别内存分配
121121
- 删除 CMS GC
122-
- GC 支持 MacOS 和 Windows 系统
122+
- GC 支持 MacOS 和 Windows 系统
123+
124+
### [JDK 15](java-15)
125+
126+
---
127+
128+
- [sealed 封闭类](java-15/src/main/java/com/di1shuai/java15/sealed/SealedDemo.java)
129+
- EdDSA 数字签名算法
130+
- hidden Classes(隐藏类)
131+
- Disable and Deprecate Biased Locking(准备禁用偏向锁)
132+
- instanceof 自动匹配模式(二次预览)
133+
- ZGC,一个可伸缩、低延迟的垃圾回收器。(转正)
134+
- Text Blocks,文本功能转正(JDK 13和14预览,14终于转正)
135+
- Remove the Solaris and SPARC Ports(删除 Solaris 和 SPARC 端口)
136+
- 外部存储器访问 API(允许Java 应用程序安全有效地访问 Java 堆之外的外部内存。)
137+
- Record类型二次预览(在Java 14就预览过啦)

java-15/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### [JDK 15](java-15)
2+
3+
---
4+
5+
- [sealed 封闭类](src/main/java/com/di1shuai/java15/sealed/SealedDemo.java)
6+
- EdDSA 数字签名算法
7+
- hidden Classes(隐藏类)
8+
- Disable and Deprecate Biased Locking(准备禁用偏向锁)
9+
- instanceof 自动匹配模式(二次预览)
10+
- ZGC,一个可伸缩、低延迟的垃圾回收器。(转正)
11+
- Text Blocks,文本功能转正(JDK 13和14预览,14终于转正)
12+
- Remove the Solaris and SPARC Ports(删除 Solaris 和 SPARC 端口)
13+
- 外部存储器访问 API(允许Java 应用程序安全有效地访问 Java 堆之外的外部内存。)
14+
- Record类型二次预览(在Java 14就预览过啦)

java-15/pom.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
<groupId>org.apache.maven.plugins</groupId>
1818
<artifactId>maven-compiler-plugin</artifactId>
1919
<configuration>
20-
<source>14</source>
21-
<target>14</target>
20+
<source>15</source>
21+
<target>15</target>
22+
<compilerArgs>--enable-preview</compilerArgs>
2223
</configuration>
2324
</plugin>
2425
</plugins>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.di1shuai.java15.sealed;
2+
3+
/**
4+
* @author Shea
5+
* @date 2021-01-23
6+
* @description
7+
* 封闭类 sealed class
8+
* permits 可以允许三种类型的子类进行继承
9+
* 1. final 类
10+
* 2. non-sealed 不封闭类
11+
* 3. sealed 类
12+
*
13+
*/
14+
public sealed class SealedDemo
15+
permits FinalClass, NonSealedClass, SealedClass {
16+
17+
}
18+
19+
final class FinalClass extends SealedDemo {
20+
21+
}
22+
23+
non-sealed class NonSealedClass extends SealedDemo {
24+
25+
}
26+
27+
sealed class SealedClass extends SealedDemo permits SealedClass.SubSealed {
28+
29+
non-sealed class SubSealed extends SealedClass {
30+
31+
}
32+
}
33+

0 commit comments

Comments
 (0)