(Second Preview) • ツール – JEP 400: UTF-8 by Default – JEP 408: Simple Web Server – JEP 413: Code Snippets in Java API Documentation • 非推奨 – JEP 421: Deprecate Finalization for Removal • API – JEP 416: Reimplement Core Reflection with Method Handles – JEP 418: Internet-Address Resolution SPI – Incubators • JEP 417: Vector API (Third Incubator) • JEP 419: Foreign Function & Memory API (Second Incubator)
jwebserver • API jshell> var server = SimpleFileServer.createFileServer(new InetSocketAddress(8000), Path.of("c:/Users/naoki"), OutputLevel.VERBOSE) server ==> sun.net.httpserver.HttpServerImpl@2f7c7260 jshell> server.start()
埋め込めたり便利 /** * The following code shows how to use {@code Optional.isPresent}: * {@snippet : * if (v.isPresent()) { * System.out.println("v: " + v.get()); * } * } */
• java/javac/jshellコマンドに`--preview-feature`が必要 Object o; System.out.println(switch (o) { case String s when s.length() >= 5 -> s.toUpperCase(); case String s -> " %s ".formatted(s); case Integer i -> "%,d".formatted(i); default -> o.toString(); } ガード節はJava 19でwhenになる模様
すべてfinal • 最適化をかけやすい。 – 平坦化、コピー • recordはIdentityを持つ – value record http://openjdk.java.net/jeps/8277163 value record NameAndScore(String name, int score) { } value class ArrayCursor<T> { T[] array; int offset;
JEP 402 Classes for the Basic Primitives – 既存の基本型のクラス定義 – `23.compareTo(34)`と書ける primitive class Point implements Shape { private double x; private double y;