Dernière mise à jour: 29/09/2020, y compris les modifications apportées au JDK 15 .
De la sortie de la version 8 à la version 15, Java a généré 163 propositions d'extension JDK (JEP), chacune apportant des améliorations à la plate-forme. Cette page est une liste systématique et soigneusement organisée des améliorations les plus importantes.
Contenu
Nouvelles fonctionnalités linguistiques
Nouvelle API
-
Javadoc
, , :
Java 8 , . , .
, . . , Java 8 .
String html = """ <html> <body> <p>Hello, world</p> </body> </html> """;
(Sealed) , ( )
public abstract sealed class Shape permits Circle, Rectangle {...} public class Circle extends Shape {...} // OK public class Rectangle extends Shape {...} // OK public class Triangle extends Shape {...} // Compile error // No need for default case if all permitted types are covered double area = switch (shape) { case Circle c -> Math.pow(c.radius(), 2) * Math.PI case Rectangle r -> r.a() * r.b() };
(Records )
record Point(int x, int y) { }
instanceof ( )
if (obj instanceof String s) { System.out.println("obj is a String and it' length is " + s.length()); }
Switch
int numLetters = switch (day) { case MONDAY, FRIDAY, SUNDAY -> 6; case TUESDAY -> 7; default -> { String s = day.toString(); int result = s.length(); yield result; } };
NullPointerExceptions, , null
JDK 15 (
-XX:+ShowCodeDetailsInExceptionMessages
JDK 14 )a.b.c.i = 99; --- Exception in thread "main" java.lang.NullPointerException: Cannot read field "c" because "a.b" is null
var,
var greeting = "Hello World!";
,
ClassDefNotFoundErrors
APIJDK 9 (Project Jigsaw)
module hu.advancedweb.helloworld { requires hu.advancedweb.somedependency; exports hu.advancedweb.hello }
JDK 9 ( Milling Coin)Diamond
JDK 9 ( Milling Coin)Try-with-resources, final
JDK 9 ( Milling Coin)@SafeVargs
private
JDK 9 ( Milling Coin)import
JDK 9
API
Java, , .
API Java 8 14, AdoptOpenJDK / jdk-api-diff GitHub .
(Non-Volatile Mapped Byte Buffers) API- FileChannel
JDK 14Files.mismatch
:
JDK 12Collectors.teeing
,
JDK 12:
indent
transform
JDK 12HTTP- HTTP/2, WebSocket API
HttpClient httpClient = HttpClient.newBuilder().build(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://advancedweb.hu/")) .GET() .build(); HttpResponse<String> response = httpClient.send(request, BodyHandlers.ofString());
- :
isBlank
,lines
,repeat
strip
JDK 11(Factory Methods) ,
Set<Integer> mySet = Set.of(1, 2, 3); List<Integer> myList = List.of(1, 2, 3); Map<String, Integer> myMap = Map.of("one", 1, "two", 2);
Reactive Streams, - « » (backpressure)1
JDK 9CompletableFuture
(-, )
JDK 9(
dropWhile
,takeWhile
) (iterate
,ofNullable
) ; (toUnmodifiableList
);
JDK 9Arrays.mismatch
:
JDK 9Stack-Walking API,
JDK 9API (, , , , / ),
ProcessBuilder
JDK 9VarHandle
API , ,java.util.concurrent.atomic
sun.misc.Unsafe
, , .
JDK 9(combinators) (lookup)
MethodHandle
JDK 9.
@Deprecated
forRemoval
, .
JDK 9OASIS Standard XML Catalog API XML
JDK 9JDK XML Xerces 2.11.0
JDK 9TIFF Image I/O Framework
java.util.Locale
API , .
JDK 10ResourceBundle
UTF-8 ISO-8859-1
JDK 9CLDR (Common Locale Data Repository)
JDK 9
, //
JDK 9MultiResolutionImage
DPI
JDK 9HiDPI Windows Linux
JDK 9GTK 3 Linux JavaFX, Swing AWT
JDK 9Javadoc
@beaninfo
@BeanInfo
Swing
JDK 9GStreamer, JavaFX / Media, 1.4.4
JDK 9ICU OpenType HarfBuzz
JDK 9
java.lang.Math
sin
,cos
log
AArch64
JDK 11Security Manager
JDK 9Spin-Wait Hint (
Thread#onSpinWait
) «-»
JDK 9Marlin Renderer Java 2D Pisces
JDK 9GHASH RSA SPARC Intel x64
JDK 9.
G1 ( )
Z Garbage Collector,
JDK 15 ( JDK 14 (Windows) JDK 14 (OS X) JDK 11 (Linux))Epsilon, ,
JDK 11XX:AllocateHeapAt=<path>
JDK 10
TLS
TLS 1.3
JDK 11Datagram Transport Layer Security (DTLS) API
JDK 9OCSP TLS
JDK 9TLS Application-Layer Protocol Negotiation (ALPN) Extension, ; ALPN HTTP/ 2
JDK 9
Packaging Tool, : msi, exe, pkg, dmg, deb rpm ( Incubator )
JDK 14jlink
Java, Java, JDK
JDK 9 - [ 2 ], [ 3 ], [ 4 ], [ 4 ], [ 5 ]JAR , Java
JDK 9
Javadoc
-
Unsafe::defineAnonymousClass()
Lookup::defineHiddenClass()
, , , .java.lang.invoke.constant
, (ldc
), ,
JDK 12CONSTANT_Dynamic
, ,INVOKEDYNAMIC
JDK 11Nest, - , - -.
JDK 11-, ,
invokedynamic
StringBuilder#append
. -.
JDK 9INVOKEDYNAMIC
/
JDK 9
RMI Activation ( RMI),
java.rmi.activation
rmid
, Java RMI
JDK 15Biased Locking ( ) ,
JDK 15Unsafe::defineAnonymousClass()
JDK 15Concurrent Mark Sweep (CMS)
JDK 14ParallelScavenge + SerialOld GC
JDK 14Pack200 API
JDK 14Pack200 API
JDK 11Java EE
JDK 11CORBA
JDK 11Thread#destroy
Thread#stop
JDK 11var
JDK 10javah
JDK 10apple.applescript
com.apple
JDK 9X.509 SHA-1
JDK 9JRE :
JRE-Version
-version:
cli
JDK 9jhat
JDK 9JVM TI hprof Agent
JDK 9GC, JDK 8
JDK 9ResourceBundle UTF-8 ISO-8859-1
JDK 9API
JDK 9Concurrent Mark Sweep Garbage Collector
JDK 9Object.finalize()
JDK 9(
lib/endorsed
) (lib/ext
) JRE
JDK 9rt.jar
JRE
JDK 9
API Java 8 14, Java Almanac . jdeps, Java, , API.
JDK 8 est sorti en 2014. Nous avons dû attendre le JDK 9 pendant trois ans et demi. Mais les choses sont allées plus vite depuis. Java a une nouvelle structure de publication qui vise à publier une nouvelle version tous les six mois.
Bien que Java 8 soit toujours pris en charge, la mise à niveau vers la dernière version apporte un nombre important d'améliorations à la table.