Java / Java 17
Java 17 is a long-term support (LTS) release, that reached General Availability on 14 September 2021. Java 17 has 14 JEP (JDK Enhanced Proposals).
Restore Always-Strict Floating-Point Semantics
: This JEP is for numerically-sensitive programs, mainly for scientific purposes; It again made default floating-point operations strict or Strictfp, ensuring the same results from the floating-point calculations on every platform.
Enhanced Pseudo-Random Number Generators
: This JEP introduced a new interface called RandomGenerator to make future pseudorandom number generator (PRNG) algorithms easier to implement or use.
1 2 3 4 5 6 7 8 | RandomGenerator randomGenerator = RandomGeneratorFactory.of("Xoshiro256PlusPlus").create(999); System.out.println(randomGenerator.getClass()); // 0-10 int result = randomGenerator.nextInt(11); System.out.println(result); |
Java 17 also refactored the legacy random classes like java.util.Random, SplittableRandom and SecureRandom to extend the new RandomGenerator interface.
New macOS Rendering Pipeline:
This JEP changes the Java 2D (like Swing GUI) internal rendering pipeline for macOS from Apple OpenGL API to Apple Metal API; this is an internal change; there are no new Java 2D APIs, nor change any existing APIs. This change is implemented as Apple deprecated the OpenGL rendering library in macOS 10.14 release(September 2018), in favor of the new Metal framework for better performance.
macOS/AArch64 Port:
Apple has a long-term plan to transition its Mac from x64 to AArch64 (e.g., Apple M1 processors).
This JEP port JDK to run on AArch64 platforms on macOS.
Deprecate the Applet API for Removal:
Java 9 deprecated the Applet API and now it is marked for removal.
Strongly Encapsulate JDK Internals:
Many third-party libraries, frameworks, and tools are accessing the internal APIs and packages of the JDK. The Java 16, JEP 396 make the strong encapsulation by default (we are not allowed to access the internal APIs easily). However, we can still use --illegal-access to switch to the simple encapsulation to still access the internal APIs. This successor JEP removes the --illegal-access option, so we have no ways to access the internal APIs, except for critical internal APIs such as sun.misc.Unsafe.
Pattern Matching for switch (Preview):
This JEP adds pattern matching for switch statements and expressions. Since this is a preview feature, we need to use --enable-preview option to enable it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public class JEP406Example { public static void main(String[] args) { System.out.println(formatObject("javapedia.net")); System.out.println(formatObject(10)); } static String formatObject(Object o) { return switch (o) { case Integer i -> String.format("int %d", i); case Long l -> String.format("long %d", l); case Double d -> String.format("double %f", d); case String s -> String.format("String %s", s); default -> o.toString(); }; } } |