This webinar by Oleksandr Bodnar (Lead Software Engineer, GlobalLogic) was delivered at Java Community Webinar #12 on July 14, 2021.
Webinar abstracts:
- Java History: OpenJDK and Oracle JDK
- Java EE (Jakarta EE) vs SE vs ME
- JEP Java SE 8-16
- Future editions of Java
More details and presentation: https://www.globallogic.com/ua/about/events/java-community-webinar-12/
3. 3
Confidential
1. A Brief History of Java: OpenJDK and Oracle JDK
2. Java EE (Jakarta EE) vs SE vs ME
3. JEPs Java SE 8 - 16
4. Future releases
Agenda
5. 5
Confidential
• Java was originally developed by James Gosling at Sun Microsystems
(which has since been acquired by Oracle) and released in May 23
1995 as a core component of Sun Microsystems' Java platform. The
original and reference implementation Java compilers, virtual
machines, and class libraries were originally released by Sun under
proprietary licenses.
• Oracle offers its own HotSpot Java Virtual Machine, however the
official reference implementation is the OpenJDK JVM which is free
open source software and used by most developers and is the default
JVM for almost all Linux distributions.
Write Once, Run Anywhere (WORA)
6. 6
Confidential
• It solved a number of problems at the time, including portability write
once, run anywhere (WORA), simplified memory management, and
abstraction from the operating system. Java became wildly popular
across enterprises, ISVs, and open source communities. Sun was
acquired by Oracle in January of 2010 which led to what would
become known as the Oracle JDK.
Write Once, Run Anywhere (WORA)
7. 7
Confidential
"OpenJDK is the free, open-source distribution of Java SE.“
• In 2007, the community released their first open-source
implementation of the Java SE, which is commonly referred to as
OpenJDK. Though the first release still used proprietary code, each
subsequent OpenJDK release reduced the amount of proprietary Java
code until they released the first completely open source OpenJDK in
2010.
What is OpenJDK?
8. 8
Confidential
• The Java Community Process - established in 1998, is a formalized
mechanism that allows interested parties to develop standard
technical specifications for Java technology. A specification is a
document that specifies (or defines) something.
• JCP produce new specifications - Java Specification Request
JCP and JSR
9. 9
Confidential
• JDK Enhancement Proposal is a
process drafted by Oracle
Corporation for collecting
proposals for enhancements to
the Java Development Kit and
OpenJDK.
• In the words of the Oracle, the
JEP serve as the long-term
Roadmap for JDK Release
Projects and related efforts.
JEP
10. 10
Confidential
• The JDK enhancement process, as outlined in JEP 1: JDK
Enhancement-Proposal & Roadmap Process, is the process in which
new features and “non-trivial” changes are integrated into new JDKs.
Those changes must meet one of the following criteria:
- More than two weeks of engineering work
- Makes a significant change to the JDK
- Is in high demand by developers/customers
The JDK Enhancement Process (JEP)
11. 11
Confidential
• With the introduction of time-based release versioning under JEP 322,
the JDK entered a new release cycle. The cycle, which follows a
“strict, six month cadence,” means fewer features per release, but
more frequent feature and version releases.
JEP 322 and the Six Month Release Cadence
12. 12
Confidential
• Long Term Release (LTS) version of the products will offer premier
and sustained support from Oracle and it will be targeted every 3
years. Also, updates for these releases will be available for at least
three years.
• This will cause “LTS” to be displayed prominently in the output of
> java -versions
11.0.2+13-LTS
Oracle JDK and LTS
14. 14
Confidential
• Java EE (Jakarta EE) is a set of specifications, extending Java SE
with specifications for enterprise features such as distributed
computing and web services.
• The platform was known as Java 2 Platform, Enterprise Edition or
J2EE from version 1.2, until the name was changed to Java Platform,
Enterprise Edition or Java EE in version 1.5.
• Java EE was maintained by Oracle under the Java Community
Process. On September 12, 2017, Oracle Corporation announced that
it would submit Java EE to the Eclipse Foundation.
Java SE vs EE (Jakarta EE)
15. 15
Confidential
• The Java platform (Enterprise Edition) differs from the Java Standard
Edition Platform (Java SE) in that it adds libraries which provide
functionality to deploy fault-tolerant, distributed, multi-tier Java
software, based largely on modular components running on an
application server.
Java SE vs EE (Jakarta EE)
16. 16
Confidential
• Java SE 6 included a full Web Services stack for the convenience of
Java developers. The stack consisted of four technologies that were
originally developed for the Java EE Platform: JAX-WS (Java API for
XML-Based Web Services), JAXB (Java Architecture for XML
Binding), JAF (the JavaBeans Activation Framework), and Common
Annotations. At the time of inclusion, the versions in Java SE were
identical to the versions in Java EE, except for Java SE dropping a
package in Common Annotations that concerned the Java EE security
model.
Java SE vs EE (Jakarta EE)
17. 17
Confidential
• Java Platform Micro Edition or Java ME is a computing platform for
development and deployment of portable code for embedded and
mobile devices (micro-controllers, sensors, gateways, mobile phones,
personal digital assistants, TV set-top boxes, printers).
• As of 2008, all Java ME platforms are currently restricted to JRE 1.3
features and use that version of the class file format (internally known
as version 47.0).
Java ME
20. 20
Confidential
• JEP-126 Lambda Expressions & Virtual Ext Methods
• JSR 335
• Add lambda expressions (closures) and supporting features,
including method references, enhanced type inference, and
virtual extension methods, to the Java programming
language and platform.
numbers.stream()
.filter(i -> i % 2 == 0)
.forEach(System.out::println);
JEP126
21. 21
Confidential
• JEP 164: Leverage CPU Instructions for AES Cryptography
• Improve the out-of-box AES Crypto performance by using
x86 AES instructions when available, and by avoiding
unnecessary re-expansion of the AES key.
JEP 164
22. 22
Confidential
• JEP 174: Nashorn JavaScript Engine (ECMAScript-262 5.1.)
• Design and implement a new lightweight, high-performance
implementation of JavaScript, and integrate it into the JDK. The new
engine will be made available to Java applications via the existing
javax.script API, and also more generally via a new command-line
tool.
• JEP 372: Remove the Nashorn JavaScript Engine in JDK 15
JEP 174
23. 23
Confidential
• Remove the Permanent
Generation - remove the
permanent generation from
the Hotspot JVM and thus
the need to tune the size of
the permanent generation.
• Move part of the contents of
the permanent generation
in Hotspot to the Java heap
and the remainder to native
memory.
JEP 122
24. 24
Confidential
• Retire Some Rarely-Used GC Combinations - remove three rarely-
used combinations of garbage collectors in order to reduce ongoing
development, maintenance, and testing costs.
• JEP 214: Remove GC Combinations Deprecated in JDK 8
JEP 173
25. 25
Confidential
• JEP 148: Small VM - Support the creation of a small VM that is no
larger than 3MB.
• The size of libjvm.so is less than 3MB, and performance is degraded
by no more than 5%.
• Motivation: Small devices have very strict static and
dynamic memory-footprint requirements. To make Java to
work well on such devices we need to reduce the JRE's overall
static and dynamic footprint.
JEP 148
26. 26
Confidential
• JEP 120: Repeating Annotations - Change the Java programming
language to allow multiple application of annotations with the
same type to a single program element.
• Now you want to set a timer to run a method,
doPeriodicCleanup, on the last day of the month and on
every Friday at 11:00 p.m.
@Schedule(dayOfMonth="last")
@Schedule(dayOfWeek="Fri", hour="23")
public void doPeriodicCleanup() { ... }
JEP 120
27. 27
Confidential
• JEP 139: Enhance javac to Improve Build Speed
• Reduce the time required to build the JDK and enable
incremental builds by modifying the Java compiler to run on
all available cores in a single persistent process, track
package and class dependences between builds,
automatically generate header files for native methods, and
clean up class and header files that are no longer needed.
JEP 139
28. 28
Confidential
• JEP 172: DocLint
• Provide a means to detect errors in Javadoc comments early in the
development cycle and in a way that is easily linked back to the
source code.
• Typical errors can be grouped into various categories:
- Bad syntax, such as unescaped characters ("<") or unmatched parentheses
("{@foo")
- Bad HTML, such as invalid or missing tags or attributes
- Bad references, such as referencing a non-existent type with @see, or a
non-existent parameter with @param
- Accessibility errors, such as a missing summary or caption from a table
- Missing info, such as an undocumented parameter
JEP 172
29. 29
Confidential
• JEP 155: Concurrency Updates & JEP 103: Parallel Array Sorting
• A small set of new classes (DoubleAccumulator, DoubleAdder,
LongAccumulator, LongAdder) internally employ contention-reduction
techniques that provide huge throughput improvements as compared
to Atomic variables.
• Added features (and possibly added APIs) that make
ConcurrentHashMaps and classes built from them more useful as
caches: computeIfAbsent and computeIfPresent.
• Added functionality and improved performance for ForkJoinPools
• parallelSort for arrays
JEP 155 + JEP 103
30. 30
Confidential
• JEP 135: Base64 Encoding & Decoding - Define a standard API for
Base64 encoding and decoding.
• Base64 encoding schemes are frequently used to encode binary/octet
sequences that are transmitted as textual data. It is commonly used by
applications using Multipurpose Internal Mail Extensions (MIME),
encoding passwords for HTTP headers, message digests, etc.
• The JDK is long overdue a standard API for Base64 encoding and
decoding. It has been frequently requested by developers for many
years, many resorting to using JDK private and unsupported classes
such as sun.misc.BASE64Encoder and sun.misc.BASE64Decoder.
JEP 135
31. 31
Confidential
• JEP 150: Date & Time API - Define a new date, time, and calendar API for
the Java SE platform.
• LocalDateTime timePoint = LocalDateTime.now();
• LocalDate.of(2012, Month.DECEMBER, 12);
• LocalDateTime thePast = timePoint.withDayOfMonth(10).withYear(2010);
• Duration oneDay = Duration.between(today, yesterday)
JEP 150
32. 32
Confidential
• JEP 180: Handle Frequent HashMap Collisions with Balanced Trees -
Improve the performance of java.util.HashMap under high hash-
collision conditions by using balanced trees rather than linked lists to
store map entries. Implement the same improvement in the
LinkedHashMap class.
JEP 180
34. 34
Confidential
• JEP 200: The Modular JDK - Use the Java Platform Module System,
specified by JSR 376 and implemented by JEP 261, to modularize the
JDK.
• module-info.java
module com.baeldung.student.service.dbimpl{
requires transitive com.baeldung.student.service;
exports com.baeldung.student.service.dbimpl;
requires java.logging;
}
JEP 200
35. 35
Confidential
• JEP 110: HTTP/2 Client (Incubator)
• Define a new HTTP client API that implements HTTP/2 and
WebSocket, and can replace the legacy HttpURLConnection API. The
API will be delivered as an incubator module, as defined in JEP 11,
with JDK 9. This implies:
• The API and implementation will not be part of Java SE.
• The API will live under the jdk.incubtor namespace.
• The module will not resolve by default at compile or run time.
JEP 110
36. 36
Confidential
• JEP 193: Variable Handles - Define a standard means to invoke the
equivalents of various java.util.concurrent.atomic and sun.misc.Unsafe
operations upon object fields and array elements, a standard set of
fence operations for fine-grained control of memory ordering, and a
standard reachability-fence operation to ensure that a referenced
object remains strongly reachable.
JEP 193
37. 37
Confidential
• JEP 213: Milling Project Coin
• private and private static methods in interfaces
• Diamond operator for anonymous inner classes
• Try-with-resources allows effectively final variables
• @SafeVargs on private instance methods
JEP 213
38. 38
Confidential
• JEP 269: Convenience Factory Methods for Collections - Define
library APIs to make it convenient to create instances of collections
and maps with small numbers of elements, so as to ease the pain of
not having collection literals in the Java programming language.
• 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);
JEP 269
39. 39
Confidential
• JEP 266: More Concurrency Updates - An interoperable publish-
subscribe framework, enhancements to the CompletableFuture API,
and various other improvements.
1. Starting from Java 9, they have become a part of the JDK in the form
of the java.util.concurrent.Flow.* interfaces.
2. Enhancements to the CompletableFuture API:
- Time-based enhancements are added that enable a future to complete
with a value or exceptionally after a certain duration, see methods
orTimeout and completeTimeout.
- Subclass enhancements are added making it easier to extend from
CompletableFuture, such as to provide a subclass that supports an
alternative default executor.
JEP 266
40. 40
Confidential
• JEP 222: jshell: The Java Shell (Read-Eval-Print Loop) - Provide an
interactive tool to evaluate declarations, statements, and expressions
of the Java programming language, together with an API so that other
applications can leverage this functionality.
• JShell is new command line interactive REPL (Read-Evaluate-Print-
Loop) console shipped with JDK 9 distribution to evaluate
declarations, statements and expressions written in Java. JShell
allows us to execute Java code snippets and get immediate results
without having to create a solution or project.
JEP 222
41. 41
Confidential
• JEP 254: Compact Strings - Improve the space efficiency of the String
class and related classes while maintaining performance in most
scenarios and preserving full compatibility for all related Java and
native interfaces. -XX:-CompactStrings - Disables the Compact
Strings feature.
JEP 254
42. 42
Confidential
• JEP 259: Stack-Walking API - Define an efficient standard API for
stack walking that allows easy filtering of, and lazy access to, the
information in stack traces.
• StackWalker stackWalker = StackWalker.getInstance();
• stackWalker.forEach(System.out::println);
JEP 259
43. 43
Confidential
• JEP 295: Ahead-of-Time Compilation - Compile Java classes to
native code prior to launching the virtual machine.
• jaotc --output libHelloWorld.so HelloWorld.class
• jaotc --output libjava.base.so --module java.base
• java -XX:AOTLibrary=./libHelloWorld.so,./libjava.base.so HelloWorld
JEP 295
44. 44
Confidential
• JEP 285: Spin-Wait Hints - Define an API to allow Java code to hint
that a spin loop is being executed. Spin-Wait Hint
(Thread#onSpinWait) to optimize busy-waiting style loops
• It tells your CPU that you are in a loop that may burn many CPU-cycles
waiting for something to happen (busy-waiting). This way, The CPU can
assign more resources to other threads, without actually loading the OS
scheduler and dequeuing a ready-to-run thread (which may be expensive).
while(true) {
while(!newEmailArrived()) {
Thread.onSpinWait();
}
makeNotification();
}
JEP 285
45. 45
Confidential
• JEP 270: Reserved Stack Areas for Critical Sections
• Extra space on thread stack for critical sections, mitigating the risk
of a deadlock in java.util.concurrent locks in case of a stack
overflow
• StackOverflowError is an asynchronous exception that can be thrown
by the Java Virtual Machine whenever the computation in a thread
requires a larger stack than is permitted.
JEP 270
46. 46
Confidential
• JEP 248: Make G1 the Default Garbage Collector - G1 Garbage
Collector is now the default instead of Parallel GC.
• Limiting GC pause times is, in general, more important than
maximizing throughput. Switching to a low-pause collector
such as G1 should provide a better overall experience, for
most users, than a throughput-oriented collector such as the
Parallel GC, which is currently the default.
• Many performance improvements were made to G1 in JDK 8
and its update releases, and further improvements are
planned for JDK 9. The introduction of concurrent class
unloading (JEP 156) in JDK 8u40 made G1 a fully-featured
garbage collector, ready to be the default.
JEP 248
47. 47
Confidential
• More options to transform (dropWhile, takeWhile) and generate
(iterate, ofNullable) streams; readonly collectors (toUnmodifiableList);
optionals can be transformed to streams
Others
48. 48
Confidential
• Arrays.mismatch: find the first mismatching element between two
arrays
• System.Logger API providing a common mechanism to handle
platform logs, allowing JDK platform classes to use the same logging
framework as the application
• Deprecate Object.finalize
Others
49. 49
Confidential
• JEP 289: Deprecate the Applet API
• JEP 291: Deprecate the Concurrent Mark Sweep Garbage Collector
• JEP 214: Remove GC Combinations Deprecated in JDK 8
• JEP 225: The Javadoc tool now emits HTML5 markup instead of a
frame-based layout and the documentation contains a search box to
ease navigation
• JEP 102: Process API Updates - Process API provides more info and
control (e.g. process ID, arguments, CPU time, parent/child
processes), enhance ProcessBuilder to aid the creation of process
pipelines
Others
51. 51
Confidential
• JEP 322: Time-Based Release Versioning.
• Starting from Java 10, Oracle has adapted time based version-string
scheme. The new format of the version number is:
• $FEATURE.$INTERIM.$UPDATE.$PATCH
• Unlike the old releases, the new time-based releases will not be
delayed and features will be released every six months, with no
constraints on what features can go out in the releases.
• There are Long Term Releases (LTS) as well. It is mainly for
enterprise customers. LTS version of the products will offer premier
and sustained support from Oracle and it will be targeted every 3
years. Also, updates for these releases will be available for at least
three years.
JEP 322
52. 52
Confidential
• JEP 286: Local-Variable Type Inference - Introduction of var to make
local variable declarations less ceremonious without lambda support in
JDK 10
• var greeting = "Hello World!";
JEP 286
53. 53
Confidential
• JEP 314: Additional Unicode Language-Tag Extensions - Enhance
java.util.Locale and related APIs to implement additional Unicode
extensions of BCP 47 language tags.
• java.util.Locale and related APIs support language-tag extensions:
- cu (currency type)
- fw (first day of week)
- rg (region override)
- tz (time zone)
JEP 314
54. 54
Confidential
• JEP 316: Heap Allocation on Alternative Memory Devices
• The goal of this change is to enable the HotSpot VM to allocate the
Java object heap on an alternative memory device, such as an NV-
DIMM, specified by the user.
• To allocate the heap in such memory we can add a new option, -
XX:AllocateHeapAt=<path>. This option would take a path to the file
system and use memory mapping to achieve the desired result of
allocating the object heap on the memory device. The existing heap
related flags such as -Xmx, -Xms, etc., and garbage-collection related
flags would continue to work as before.
JEP 316
55. 55
Confidential
• JEP 312: Thread-Local Handshakes
• Thread-Local Handshakes to stop individual threads
• It is a performance enhancement which cannot be used directly by
developers:
- A handshake mechanism is proposed as an optimisation of the Hotspot
safepoints mechanism.
- The former allows threads in a safepoint to continue executing immediately after
performing a regulatory operation (the handshake callback).
- The latter forces all threads to block on a safepoint in order for critical operations
to take place (such as YoungGen GC or the STW parts of a Full GC). The
threads are released only after the critical operation has completed its execution.
JEP 312
56. 56
Confidential
• A new method orElseThrow has been added to the Optional class. It
is synonymous with and is now the preferred alternative to the existing
get method.
• Deprecated Classes in com.sun.security.auth.**
Other
58. 58
Confidential
• JEP 323: Local-Variable Syntax for Lambda Parameters - Allow var to
be used when declaring the formal parameters of implicitly typed
lambda expressions.
• (var x, var y) -> x.process(y)
• @Nonnull var x = new Foo();
• (@Nonnull var x, @Nullable var y) -> x.process(y)
JEP 323
59. 59
Confidential
• JEP 333: ZGC: A Scalable Low-Latency Garbage Collector
(Experimental) - The Z Garbage Collector, also known as ZGC, is a
scalable low-latency garbage collector.
JEP 333
60. 60
Confidential
• JEP 321: HTTP Client - Standardize the incubated HTTP Client API
introduced in JDK 9, via JEP 110, and updated in JDK 10.
HttpClient client = HttpClient.newBuilder()
// just to show off; HTTP/2 is the default
.version(HTTP_2)
.connectTimeout(Duration.ofSeconds(5))
.followRedirects(SECURE)
.build();
JEP 321
61. 61
Confidential
• JEP 318: Epsilon: A No-Op Garbage Collector (Experimental)
• Develop a GC that handles memory allocation but does not
implement any actual memory reclamation mechanism. Once
the available Java heap is exhausted, the JVM will shut down.
JEP 318
62. 62
Confidential
• JEP 328: Flight Recorder - Provide a low-overhead data collection
framework for troubleshooting Java applications and the HotSpot JVM.
JEP 328
63. 63
Confidential
• JEP 330: Launch Single-File Source-Code Programs - Enhance the
java launcher to run a program supplied as a single file of Java source
code, including usage from within a script by means of "shebang" files
and related techniques.
java HelloWorld.java
JEP 330
64. 64
Confidential
• JEP 335: Deprecate the Nashorn JavaScript Engine - Deprecate the
Nashorn JavaScript script engine and APIs, and the jjs tool, with the
intent to remove them in a future release.
JEP 335
65. 65
Confidential
• JEP 362: Deprecate the Solaris and SPARC Ports - Deprecate the
Solaris/SPARC, Solaris/x64, and Linux/SPARC ports, with the intent to
remove them in a future release. Dropping support for these ports will
enable contributors in the OpenJDK Community to accelerate the
development of new features that will move the platform forward.
JEP 362
66. 66
Confidential
• JEP 336: Deprecate the Pack200 Tools and API - Deprecate the
pack200 and unpack200 tools, and the Pack200 API in java.util.jar.
JEP 336
67. 67
Confidential
• JEP 320: Remove the Java EE and CORBA Modules - Remove the
Java EE and CORBA modules from the Java SE Platform and the
JDK. These modules were deprecated in Java SE 9 with the declared
intent to remove them in a future release.
java.xml.ws (JAX-WS)
java.xml.bind (JAXB)
java.activation (JAF)
java.xml.ws.annotation (Common Annotations)
java.corba (CORBA)
java.transaction (JTA)
java.se.ee (Aggregator module for the six modules above)
jdk.xml.ws (Tools for JAX-WS)
jdk.xml.bind (Tools for JAXB)
JEP 320
68. 68
Confidential
• Remove Thread.destroy() and Thread.stop(Throwable)
• These methods have been deprecated for a very long time.
Thread.destroy() has never been implemented, and it has always
thrown NoSuchMethodError to the caller. Thread.stop(Throwable) was
changed to be non-functional (it throws
UnsupportedOperationException to the caller) in JDK 8. They should
now be removed from the Thread API.
JDK-8204243
69. 69
Confidential
• String isBlank() – Check blank or empty string in Java
System.out.println( " ".isBlank() ); //true
• String lines() – Get stream of lines
str.lines().forEach(System.out::println);
• String repeat() – Repeat string N times in Java
System.out.println("Abc".repeat(3)); //AbcAbcAbc
String JDK 11
70. 70
Confidential
• String strip() – returns a string whose value is given string, with all leading
and trailing white space removed. Please note that String.trim() method also
produces the same result.
System.out.println(" Hello World !! ".strip() ); //"Hello World !!"
• String stripLeading() – returns a string whose value is given string, with all
leading white space removed.
System.out.println(" Hello World !! ".stripLeading() ); //"Hello World !! "
• String stripTrailing() – returns a string whose value is given string, with all
trailing white space removed.
System.out.println(" Hello World !! ".stripTrailing() ); //" Hello World !!"
String JDK 11
71. 71
Confidential
• Read a file to string in Java using Files.readString(path) method.
public static String readString(Path path) throws IOException
public static String readString(Path path, Charset cs) throws IOException
First method is equivalent to readString(path, StandardCharsets.UTF_8)
Files readString() API
72. 72
Confidential
• Write a string into file in Java using Files.writeString(path, string,
options) method. java.nio.file.Files class has two overloaded static
methods to write content to file.
public static Path writeString(Path path, CharSequence csq, OpenOption... options) throws IOException
public static Path writeString(Path path, CharSequence csq, Charset cs, OpenOption... options) throws IOException
Options specifies how the file is opened.
Files.writeString(filePath, "Hello World !!", StandardOpenOption.APPEND);
Files writeString() API
74. 74
Confidential
• JEP 325: Switch Expressions (Preview) - This change extends the
switch statement so that it can be used as either a statement or an
expression. Instead of having to define a break statement per case
block, we can simply use the arrow syntax.
switch (day) {
case MONDAY, FRIDAY, SUNDAY -> System.out.println(6);
case TUESDAY -> System.out.println(7);
case THURSDAY, SATURDAY -> System.out.println(8);
case WEDNESDAY -> System.out.println(9);
}
JEP 325
75. 75
Confidential
• JEP 346: Promptly Return Unused Committed Memory from G1 -
Enhance the G1 garbage collector to automatically return Java heap
memory to the operating system when idle.
JEP 346
76. 76
Confidential
• JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector
(Experimental) - Add a new garbage collection (GC) algorithm named
Shenandoah which reduces GC pause times by doing evacuation
work concurrently with the running Java threads. Pause times with
Shenandoah are independent of heap size, meaning you will have the
same consistent pause times whether your heap is 200 MB or 200
GB.
JEP 189
77. 77
Confidential
• JEP 230: Microbenchmark Suite - Add a
basic suite of microbenchmarks to the
JDK source code, and make it easy for
developers to run existing
microbenchmarks and create new ones.
Based on the [Java Microbenchmark
Harness (JMH)
JEP 230
78. 78
Confidential
• String.indent() - The indent method helps
with changing the indentation of a String.
We can either pass a positive value or a
negative value depending on whether we
want to add more white spaces or
remove existing white spaces.
• String.transform(). The transform()
method takes a String and transforms it
into a new String with the help of a
Function.
String API Changes
79. 79
Confidential
• Files.mismatch: find the first mismatched byte in the content of two
files or -1. Return position of the first mismatched byte in the content
of the two files.
• Collectors.teeing() in Stream API. A teeing collector has been exposed
as a static method Collectors::teeing. This collector forwards its input
to two other collectors before merging their results with a function.
SalaryRange salaryRange = Stream
.of(56700, 67600, 45200, 120000, 77600, 85000)
.collect(teeing(
minBy(Integer::compareTo),
maxBy(Integer::compareTo),
SalaryRange::fromOptional));
Others
81. 81
Confidential
• JEP 355: Text Blocks (Preview) - Add text blocks to the Java
language. A text block is a multi-line string literal that avoids the need
for most escape sequences, automatically formats the string in a
predictable way, and gives the developer control over format when
desired.
String query = """
SELECT `EMP_ID`, `LAST_NAME` FROM `EMPLOYEE_TB`
WHERE `CITY` = 'INDIANAPOLIS'
ORDER BY `EMP_ID`, `LAST_NAME`;
""";
JEP 355
82. 82
Confidential
• JEP 354: Switch Expressions (Second Preview) - Extend switch so it
can be used as either a statement or an expression, and so that both
forms can use either traditional case ... : labels (with fall through) or
new case ... -> labels (with no fall through), with a further new
statement for yielding a value from a switch expression.
int numberOfLetters = switch (dayOfWeek) {
case MONDAY, FRIDAY, SUNDAY -> 6;
case TUESDAY -> {yield 2;}
case THURSDAY, SATURDAY -> 8;
case WEDNESDAY -> 9;
default -> throw new IllegalStateException("Huh?: " + day);
};
JEP 354
83. 83
Confidential
• JEP 350: Dynamic CDS Archives - Extend application class-data
sharing to allow the dynamic archiving of classes at the end of Java
application execution. The archived classes will include all loaded
application classes and library classes that are not present in the
default, base-layer CDS archive.
java -XX:ArchiveClassesAtExit=hello.jsa -cp hello.jar Hello
java -XX:SharedArchiveFile=hello.jsa -cp hello.jar Hello
JEP 350
85. 85
Confidential
• JEP 359: Records (Preview) - Enhance the Java programming
language with records. Records provide a compact syntax for
declaring classes which are transparent holders for shallowly
immutable data. javac —enable-preview —release 14 Triangle.java
JEP 359
final class Triangle {
public final int x;
public final int y;
public final int z;
public Triangle(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
// equals, hashCode, toString
}
public record Triangle(int x, int y, int z){}
86. 86
Confidential
• JEP 305: Pattern Matching for instanceof (Preview) - Enhance the
Java programming language with pattern matching for the instanceof
operator. Pattern matching allows common logic in a program, namely
the conditional extraction of components from objects, to be
expressed more concisely and safely.
JEP 305
Object object = Violin;
if (object instanceof Instrument) {
Instrument instrument = (Instrument) object;
System.out.println(instrument.getMaster());
}
Object object = Violin;
if (object instanceof Instrument instrument){
System.out.println(instrument.getMaster());
}
87. 87
Confidential
• JEP 358: Helpful NullPointerExceptions - Improve the usability of
NullPointerExceptions generated by the JVM by describing precisely
which variable was null.
• Enabled with -XX:+ShowCodeDetailsInExceptionMessages in JDK 14
JEP 358
a.b.c.i = 99;
--- Exception in thread "main" java.lang.NullPointerException: Cannot read field "c" because "a.b" is null
88. 88
Confidential
• JEP 361: Switch Expressions
JEP 361
int result = switch (s) {
case "Working from Home" -> 1;
case "Working from Office" -> 2;
default -> {
System.out.println("Neither Home nor Office… Cafe? Car? Park?...");
yield 0;
}
};
89. 89
Confidential
• JEP 343: Packaging Tool (Incubator) - Create a tool for packaging
self-contained Java applications.
o Linux: deb and rpm
o macOS: pkg and dmg
o Windows: MSI and EXE
jpackage --input target/
--name JPackageDemoApp
--main-jar JPackageDemoApp.jar
--main-class com.baeldung.java14.jpackagedemoapp.JPackageDemoApp
--type dmg
--java-options '--enable-preview’
JEP 343
90. 90
Confidential
• JEP 352: Non-Volatile Mapped Byte Buffers - Add new JDK-specific
file mapping modes so that the FileChannel API can be used to create
MappedByteBuffer instances that refer to non-volatile memory.
• jdk.nio.mapmode
• READ_ONLY_SYNC, WRITE_ONLY_SYNC
JEP 352
91. 91
Confidential
• JEP 363: Remove the Concurrent Mark Sweep (CMS) Garbage
Collector - Remove the Concurrent Mark Sweep (CMS) garbage
collector.
• JEP 366: Deprecate the ParallelScavenge + SerialOld GC
Combination
• Deprecate -XX:+UseParallelGC -XX:-UseParallelOldGC
JEP 363 & JEP 366
92. 92
Confidential
• JEP 364: ZGC on macOS and JEP 365: ZGC on Windows - Port the
ZGC garbage collector to macOS and Windows.
JEP 364 & JEP 365
93. 93
Confidential
JEP 368: Text Blocks (Second Preview)
String text1 = """
line1
line2 s
line3 """;
String text2 = "line1nline2 nline3n";
94. 94
Confidential
• JEP 370: Foreign-Memory Access API (Incubator) - Introduce an API
to allow Java programs to safely and efficiently access foreign
memory outside of the Java heap
JEP 370
96. 96
Confidential
• JEP 360: Sealed Classes (Preview) - Enhance the Java programming
language with sealed classes and interfaces. Sealed classes and
interfaces restrict which other classes or interfaces may extend or
implement them.
JEP 360: Sealed Classes (Preview)
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()
};
97. 97
Confidential
• JEP 379: Shenandoah: A Low-Pause-Time Garbage Collector
(Production) - Shenandoah Garbage Collector, offering similar benefits
as ZGC but based on a different algorithm
• JEP 377: ZGC: A Scalable Low-Latency Garbage Collector
(Production) - Z Garbage Collector, offering very low pause times on
large heaps
JEP 379 & JEP 377
98. 98
Confidential
• JEP 339: Edwards-Curve Digital Signature Algorithm (EdDSA) -
Implement cryptographic signatures using the Edwards-Curve Digital
Signature Algorithm (EdDSA) as described by RFC 8032.
// example: generate a key pair and sign
KeyPairGenerator kpg = KeyPairGenerator.getInstance("Ed25519");
KeyPair kp = kpg.generateKeyPair();
// algorithm is pure Ed25519
Signature sig = Signature.getInstance("Ed25519");
sig.initSign(kp.getPrivate());
sig.update(msg);
byte[] s = sig.sign();
JEP 339
// example: use KeyFactory to contruct a public key
KeyFactory kf = KeyFactory.getInstance("EdDSA");
boolean xOdd = ...
BigInteger y = ...
NamedParameterSpec paramSpec = new NamedParameterSpec("Ed25519");
EdECPublicKeySpec pubSpec = new EdECPublicKeySpec(paramSpec, new
EdPoint(xOdd, y));
PublicKey pubKey = kf.generatePublic(pubSpec);
99. 99
Confidential
• JEP 378: Text Blocks
• JDK-8233014: Enable ShowCodeDetailsInExceptionMessages by
default
Final (not preview more)
100. 100
Confidential
• Remove the Nashorn Javascript Engine and the jjs tool
• Remove the Solaris and SPARC Ports
• Deprecate RMI Activation, affecting the java.rmi.activation package
and the rmid tool, does not affect Java RMI in general
• Disable Biased Locking by default, deprecate related command-line
flags
• Deprecate Unsafe::defineAnonymousClass()
Remove & Deprecate
102. 102
Confidential
• JEP 397: Sealed Classes (Second Preview) - Enhance the Java
programming language with sealed classes and interfaces. Sealed
classes and interfaces restrict which other classes or interfaces may
extend or implement them.
JEP 397
public sealed class Sealed { }
final class Impl {
void f(Runnable r) {
Sealed s = (Sealed) r; // error: incompatible types
}
}
103. 103
Confidential
• JEP 390: Warnings for Value-Based Classes - Designate the
primitive wrapper classes as value-based and deprecate their
constructors for removal, prompting new deprecation
warnings. Provide warnings about improper attempts to
synchronize on instances of any value-based classes in the
Java Platform.
JEP 390
Double d = 0.0;
synchronized (d) {
// warning: [synchronization] attempt to synchronize on an instance of a value-
based class
}
104. 104
Confidential
• JEP 376: ZGC: Concurrent Thread-Stack Processing - Move ZGC
thread-stack processing from safepoints to a concurrent phase.
JEP 376
105. 105
Confidential
• JEP 387: Elastic Metaspace - Return unused HotSpot class-metadata
(i.e., metaspace) memory to the operating system more promptly,
reduce metaspace footprint, and simplify the metaspace code in order
to reduce maintenance costs.
JEP 387
106. 106
Confidential
• JEP 392: Packaging Tool. Packaging Tool to create self-contained
applications, also supporting native package formats: msi, exe, pkg,
dmg, deb and rpm
Final (not preview more)
108. 108
Confidential
• Stream.toList as convenience for the most typical collection method
(instead of relying on .collect(Collectors.toList()))
• Stream.mapMulti to replace each element of this stream with zero or
more elements, an alternative to flatMap
• New builder to HTTP client that specifies a header filter
• DateTimeFormatterBuilder.html#appendDayPeriodText to support
other day periods than AM/PM
• JEP 380: Unix-domain socket channels and server socket channels
Other
110. 110
Confidential
• JEP 391: macOS/AArch64 Port - Apple announced in 2020 a two-year
transition plan (Apple Silicon) to move its Central Process Unit (CPU)
from Intel’s x86–64 to Apple-designed chips that use the
ARM64/AArch64 architecture.
JEP 391
111. 111
Confidential
• JEP 356: Enhanced Pseudo-Random Number Generators - JEP 356
introduces new interface types and implementation for pseudorandom
number generators (PRNGs).
• The goals are to make it easier to change between various PRGNs
algorithms, remove duplicated code in existing PRGNs, provide better
stream-based programming support and, lastly, to preserve the
current behaviour of java.util.Random.
JEP 356
112. 112
Confidential
• JEP 410: Remove the Experimental AOT and JIT Compiler - Remove
the experimental Java-based ahead-of-time (AOT) and just-in-time
(JIT) compiler. This compiler has seen little use since its introduction
and the effort required to maintain it is significant. Retain the
experimental Java-level JVM compiler interface (JVMCI) so that
developers can continue to use externally-built versions of the
compiler for JIT compilation.
JEP 410
114. 114
Confidential
• Improved interoperability with native code, to enable Java source code
to call functions and use data types from other languages, in a way
that is easier and has better performance than today.
Project Panama
115. 115
Confidential
• Virtual threads, a lightweight user-mode scheduled alternative to
standard OS managed threads. Virtual threads are mapped to OS
threads in a many-to-many relationship, in contrast to the many-to-one
relationship from the original green threads implementation in early
versions of Java.
Project Loom