Wener笔记故事指南
- 没有任何语言上的修改
- Flow
- 对 CompletableFuture 的扩展
- 支持 ReactiveStream
- G1 为默认 GC
- Jigsaws - module
Contents
JEPs
- 102: Process API Updates
- 提升与系统的互操作性
- 取得当前进程的 PID
- 以前会比较麻烦,现在只需要
ProcessHandle.current().pid()
- 检测进程是否存活
ProcessHandle.of(pid).map(v->v.isAlive())
- 获取进程相关信息
- 获取进程父子关系
- 110: HTTP 2 Client
- HTTP 2.0 客户端
- WebSocket 客户端
- 143: Improve Contended Locking
- 158: Unified JVM Logging
- 165: Compiler Control
- 193: Variable Handles
- 197: Segmented Code Cache
- 199: Smart Java Compilation, Phase Two
- 200: The Modular JDK
- 201: Modular Source Code
- 211: Elide Deprecation Warnings on Import Statements
- 212: Resolve Lint and Doclint Warnings
- 213: Milling Project Coin
@SafeVarargs
可以用在私有方法
- 带资源的
try
可以直接使用变量而不需要赋值
- 以前必须
try(FileReader fileReader = new FileReader("input"))
, 现在可以 try(fileReader)
- 匿名类的类型参数如果可以推断则可以省略
Comparator<Person> comp = new Comparator<>() {}
- 下划线不能作为标识符
- 214: Remove GC Combinations Deprecated in JDK 8
- 215: Tiered Attribution for javac
- 216: Process Import Statements Correctly
- 217: Annotations Pipeline 2.0
- 219: Datagram Transport Layer Security (DTLS)
- 220: Modular Run-Time Images
- 221: Simplified Doclet API
- 222: jshell: The Java Shell (Read-Eval-Print Loop)
- 223: New Version-String Scheme
- 224: HTML5 Javadoc
- 225: Javadoc Search
- 226: UTF-8 Property Files
- 227: Unicode 7.0
- 228: Add More Diagnostic Commands
- 用于对 HotSpot 进行诊断的新的
jcmd
命令
jcmd 1083 VM.stringtable
- 229: Create PKCS12 Keystores by Default
- 231: Remove Launch-Time JRE Version Selection
- 232: Improve Secure Application Performance
- 233: Generate Run-Time Compiler Tests Automatically
- 235: Test Class-File Attributes Generated by javac
- 236: Parser API for Nashorn
- 237: Linux/AArch64 Port
- 238: Multi-Release JAR Files
- 可以在一个 Jar 中包含针对多个版本的内容
- 需要在 MANIFEST.MF 中添加 Multi-Release: true
- 会根据版本不同从不同的目录加载更多的内容
META-INF/versions/9
, META-INF/versions/10
- 240: Remove the JVM TI hprof Agent
- 移除 hprof
- 早期主要用于堆转储和取得 CPU profile
- 现在堆转储可以使用 jmap, 而 profile 可以使用 visualvm 等工具
- 241: Remove the jhat Tool
- 243: Java-Level JVM Compiler Interface
- 244: TLS Application-Layer Protocol Negotiation Extension
- 245: Validate JVM Command-Line Flag Arguments
- 246: Leverage CPU Instructions for GHASH and RSA
- 247: Compile for Older Platform Versions
- 早期编译时使用 source 和 target 来控制, 现在可以统一使用 release 来控制
--release
等同于 -source N -target N -bootclasspath <bootclasspath-from-N>
- Java 9 可以针对早期版本的签名做一些处理
$JDK_HOME/lib/ct.sym
- 248: Make G1 the Default Garbage Collector
- 249: OCSP Stapling for TLS
- 250: Store Interned Strings in CDS Archives
- 251: Multi-Resolution Images
- 252: Use CLDR Locale Data by Default
- 253: Prepare JavaFX UI Controls & CSS APIs for Modularization
- 254: Compact Strings
- 压缩的字符串格式
- JVM 的内部优化, 主要考虑是大部分字符都不需要两个字节, 内部使用 byte 数组, 使用编码进行控制.
- 通过一个额外的字节来标识编码, 最多使用 1 byte 的字符串使用 Latin-1, 其他的使用 UTF16
- 255: Merge Selected Xerces 2.11.0 Updates into JAXP
- 256: BeanInfo Annotations
- 257: Update JavaFX/Media to Newer Version of GStreamer
- 258: HarfBuzz Font-Layout Engine
- 259: Stack-Walking API
- 早期需要使用
sun.reflect.Reflection::getCallerClass
- 现在可以直接遍历调用栈
StackWalker.getInstance().walk((s) -> s.collect(Collectors.toList()))
- 260: Encapsulate Most Internal APIs
- 将大部分 Java 内部接口(sun., com.sun.)封装在内部模块
- 但针对常用的内部接口也做了暴露,不过已标识为弃用
- sun.misc.{Signal,SignalHandler}
- sun.misc.Unsafe
- sun.reflect.Reflection::getCallerClass
- sun.reflect.ReflectionFactory.newConstructorForSerialization
- 261: Module System
- 262: TIFF Image I/O
- 263: HiDPI Graphics on Windows and Linux
- 264: Platform Logging API and Service
- 265: Marlin Graphics Renderer
- 266: More Concurrency Updates
- 提供 ReactiveStream 实现接口
- Flow
- Flow.Publisher
- Flow.Subscriber
- Flow.Subscription
- Flow.Processor
- 267: Unicode 8.0
- 268: XML Catalogs
- 269: Convenience Factory Methods for Collections
- 在 List, Set, Map 上添加用于创建不可变集合的辅助类工厂方法
of
- Stream 增强
Stream<T> takeWhile(Predicate<? super T> predicate)
Stream<T> dropWhile(Predicate<? super T> predicate)
Stream<T> iterate(T seed, Predicate<? super T> hasNext, UnaryOperator<T> next)
Stream<T> ofNullable(T t)
- Optional 增强
void ifPresentOrElse(Consumer<? super T> action, Runnable emptyAction)
Optional<T> or(Supplier<? extends Optional<? extends T>> supplier)
Stream<T> stream()
- 270: Reserved Stack Areas for Critical Sections
- 271: Unified GC Logging
- 272: Platform-Specific Desktop Features
- 273: DRBG-Based SecureRandom Implementations
- 274: Enhanced Method Handles
- 275: Modular Java Application Packaging
- 276: Dynamic Linking of Language-Defined Object Models
- 277: Enhanced Deprecation
@Deprecated
添加 forRemoval
和 since
属性
- 278: Additional Tests for Humongous Objects in G1
- 279: Improve Test-Failure Troubleshooting
- 280: Indify String Concatenation
- 281: HotSpot C++ Unit-Test Framework
- 282: jlink: The Java Linker
- 283: Enable GTK 3 on Linux
- 284: New HotSpot Build System
- 285: Spin-Wait Hints
java.lang.Thread.onSpinWait()
用于提示 JVM 进行优化
- 287: SHA-3 Hash Algorithms
- 288: Disable SHA-1 Certificates
- 289: Deprecate the Applet API
- 废弃所有 Applet 相关接口, 但暂未考虑移除
- 290: Filter Incoming Serialization Data
- 292: Implement Selected ECMAScript 6 Features in Nashorn
- 294: Linux/s390x Port
- 295: Ahead-of-Time Compilation
- 297: Unified arm32/arm64 Port