The Java JDK 11 was officially released on September 25, 2018. It is a long-term support (LTS) release, meaning it receives updates and bug fixes for an extended period until September 2026.
Below is the list of JEPs that were part of Java 11 development.
Let's try and take a look at some of the new features that were introduced in Java JDK 11 in brief.
Nest-Based Access Control (JEP 181)
Enhanced the access control for nested classes.
JEP 181 introduced nests, enabling logically related classes compiled into separate files to access each other's private members without requiring additional accessibility bridge methods to be inserted by the compiler.
Example:
1. class OuterClass {
2. private int x;
3. class InnerClass {
4. void doSomething() {
5. x = 10; //Accessing the private field of the outer class
6. }
7. }
8. }
Dynamic Class-File Constants (JEP 309)
A new constant-pool CONSTANT_Dynamic form was added to the Java class-file format to efficiently load constants in class files.
Example:
public class Constants {
public static final int SUNDAY = 0;
public static final int MONDAY = 1;
}
Improve Aarch64 Intrinsics (JEP 315)
JEP 315 enhanced the performance of Java applications on AArch64 processors by optimizing intrinsics.
Intrinsics allowed the execution of CPU-specific assembly code instead of generic Java code to boost performance.
Improvements were made by implementing intrinsics for java.lang.Math functions like sin, cos, and log, as well as improving existing intrinsics for string and array operations.
Example:
public static void main(String[] args) {
double angle = 45.0;
double result = Math.sin(angle); // Benefitted from optimized intrinsics on AArch64
}
If you have a Java application that uses the Math.sin function frequently. With JEP 315, the implementation of Math.sin was optimized for AArch64 processors - such as Apple Silicon Chip based M1/M2 processors.
Epsilon: A No-Op Garbage Collector (Experimental) (JEP 318)
JEP 318 introduced Epsilon, a unique experimental (No-Op) garbage collector for Java. Unlike traditional garbage collectors, Epsilon doesn't perform memory reclamation; it simply handles memory allocation. When the Java heap is full, the JVM shuts down.
Helpful for:
Performance Testing
Memory Pressure Testing
VM Interface Testing
Short-Lived Jobs
Latency Improvements
Throughput Improvements
We can enable Epsilon by passing the below argument to the Java Virtual Machine (JVM).
-XX:+UseEpsilonGC
Remove the Java EE and CORBA Modules (JEP 320)
As part of JEP 320, the Java EE and CORBA modules are being removed from the Java SE Platform and JDK because they were deprecated in Java SE 9. This simplifies Java SE, reduces maintenance complexity, and encourages developers to use standalone versions of these technologies.
The inclusion of Java EE and CORBA technologies caused maintenance challenges due to differences between Java SE and Java EE versions. Standalone alternatives are readily available, making their inclusion unnecessary.
In Java SE 9, these modules were marked for removal, and in Java SE 11, they will be removed, including source code deletion. Tools related to these modules will no longer be available. Tests related to Java EE and CORBA APIs will be removed.
HTTP Client (JEP 321)
The HTTP Client API which was introduced in Java 9, was added as a standard feature in Java JDK 11 by JEP-321.
Example:
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class HttpClientExampleJava11 {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://code2care.org/v2/api/get-users"))
.GET()
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Local-Variable Syntax for Lambda Parameters (JEP 323)
By this JEP, var can be used when declaring the formal parameters of implicitly typed lambda expressions.
Example:
import java.util.function.Predicate;
public class LambdaExampleJEP323 {
public static void main(String[] args) {
Predicate isNotEmpty = (var s) -> s != null && !s.isEmpty();
System.out.println(isNotEmpty.test("Code2care!"));
}
}
Unicode 10 (JEP 327)
- Character and String in the java.lang package.
- NumericShaper in the java.awt.font package.
- Bidi, BreakIterator, and Normalizer in the java.text package.
Below existing classes were enhanced to support version 10.0 of the Unicode Standard.
Example:
public static void main(String[] args) {
char heartSymbol = '\u2764';
System.out.println("Heart Symbol: " + heartSymbol);
}
Facing issues? Have Questions? Post them here! I am happy to answer!
- Deep Dive into Java 8 Predicate Interface
- Read and Parse XML file using Java DOM Parser [Java Tutorial]
- Java 8 Predicate Functional Interface isEqual() Method Example
- Convert Multidimensional Array toString In Java
- How to read int value using Scanner Class Java
- Spring Boot AI + LLM + Java Code Example
- Write to a File using Java Stream API
- Implementing Bubble Sort Algorithm using Java Program
- How to Fix XmlBeanDefinitionStoreException in Java SpringBoot ApplicationConfig.xml
- YAML Parser using Java Jackson Library Example
- [Fix] java: integer number too large compilation error
- Convert JSON String to Java GSON Object Example
- Read a file using Java 8 Stream
- Java Spring Boot 3 Web Hello World with Gradle in IntelliJ
- Ways Compare Dates in Java Programming with Examples
- Pretty Print JSON String in Java Console Output
- Java JDBC with Join Queries Example
- How to Check For Updates on Windows 11 (Step-by-Step)
- [Fix] java.net.MalformedURLException: unknown protocol
- How to display date and time in GMT Timezone in Java
- Error: LinkageError occurred while loading main class UnsupportedClassVersionError [Eclipse Java]
- How to convert a String to Java 8 Stream of Char?
- RabbitMQ Queue Listener Java Spring Boot Code Example
- 5+ Fibonacci number Series Java Program Examples [ 0 1 1 2 3 ..]
- Handling NullPointerException with Java Predicate
- How to Update macOS Ventura to Sonoma 14.0 - MacOS
- How to Close Safari in Mac using Keyboard shortcut - MacOS
- New Mac? How to install Native Chrome on M1/M2 Mac - Chrome
- How to Disable Windows Terminal Bell Sound (Updated for Windows 11) - Windows
- Code2care Daily: Your Source for Tech & Programming News - April 14th, 2023 - News
- How to hide toolbar on Notepad++ - NotepadPlusPlus
- pwd Command - Print Working Directory - Linux
- When should we use Primitive or Wrapper types in Java? - Java