Java 9: Features และ Enhancements หลัก
Oracle ปล่อย Java 9 พร้อมฟีเจอร์ใหม่และการปรับปรุงมากมาย
รายการฟีเจอร์สำคัญ
- Factory Methods for Collections: List.of(), Set.of(), Map.of() สร้าง immutable collections ได้ง่าย
- Java Platform Module System (JPMS): Modularity, encapsulation, dependencies management
- Private Methods in Interfaces: private และ private static methods ลด code duplication
- Java 9 REPL (JShell): Interactive tool รันจาก command line
- Try-with-resources Improvement: ใช้ external effectively-final variables ได้
- Diamond Operator for Anonymous Inner Class: ใช้ <> กับ anonymous classes ได้
- CompletableFuture API Improvements: Timeout support, subclassing, factory methods
- Reactive Streams: Publish-subscribe framework สำหรับ async/parallel apps
- Process API Improvements: ProcessHandle, Info, PID, CPU time, children, descendants
- Optional Class Improvements: or(), ifPresentOrElse(), stream()
- Stream API Improvements: takeWhile, dropWhile, ofNullable, iterate (with predicate)
- Multi-Resolution Image API: Encapsulate images หลาย resolutions
- HTTP/2 Client: HTTP/2 support with backward compatibility (incubator module)
- Enhanced @Deprecated Annotation: since, forRemoval attributes
สรุป
Java 9 เป็น release ที่สำคัญมาก โดยเฉพาะ Module System และ JShell พร้อมการปรับปรุง API หลายอย่าง ทำให้พัฒนา Java ทันสมัยและมีประสิทธิภาพมากขึ้น