Java 27 Features: Complete Guide with Practical Examples
Read this MyExamCloud Blog article for practical insights on Software. Explore more blog categories, search related topics in blog search, or return to the MyExamCloud Blog home.
Java 27 introduces important improvements across JVM performance, security, garbage collection, concurrency, cryptography, and pattern matching. This guide covers the major Java 27 features with practical examples, while also highlighting the Java certification paths developers can use to strengthen their Java skills.
What's New in Java 27?
Java 27 focuses heavily on improving the JVM and continuing the evolution of modern Java APIs. The release includes finalized platform improvements as well as preview and incubator features.
- Compact Object Headers
- JFR In-Process Data Redaction
- Post-Quantum Hybrid Key Exchange for TLS 1.3
- G1 as the Default Garbage Collector Everywhere
- Lazy Constants
- Primitive Types in Patterns, instanceof, and switch
- Structured Concurrency
- PEM Encodings of Cryptographic Objects
- Vector API
- ISO-8601 short time-zone offsets
- G1 configuration changes
- JVMCI removal
- Compressed Class Pointer changes
1. Compact Object Headers
Compact Object Headers reduce the memory used by Java object headers. Java 27 enables the feature by default.
Example
public class Customer {
private final int id;
private final String name;
public Customer(int id, String name) {
this.id = id;
this.name = name;
}
}
List<Customer> customers = new ArrayList<>();
for (int i = 0; i < 10_000_000; i++) {
customers.add(
new Customer(i, "Customer-" + i)
);
}
This application creates millions of small objects. Because every Java object has an object header, reducing the header size can reduce total heap consumption for object-heavy workloads.
You can explicitly disable Compact Object Headers with:
java -XX:-UseCompactObjectHeaders MyApplication
The important point is that developers normally do not need to modify application code to benefit from this Java 27 JVM improvement.
2. JFR In-Process Data Redaction
Java Flight Recorder is widely used for monitoring and troubleshooting production applications. Java 27 improves protection of sensitive information that could otherwise appear in JFR recordings.
For example, an application may be started with:
java \
-Ddatabase.password=SuperSecret123 \
-Dapi.token=ABC123XYZ \
-jar application.jar
Instead of exposing sensitive values in diagnostic data, Java 27 can record them as:
database.password = [REDACTED]
api.token = [REDACTED]
Custom Redaction
java \
-XX:FlightRecorderOptions:'redact-key=ACCESS_TOKEN;*password*' \
-jar application.jar
This is particularly useful when JFR recordings are collected from production environments and shared with development or operations teams.
3. Post-Quantum Hybrid Key Exchange for TLS 1.3
Java 27 introduces post-quantum hybrid key exchange for TLS 1.3. The approach combines traditional cryptography with post-quantum cryptography.
The main hybrid group is:
X25519MLKEM768
Other supported hybrid groups include:
SecP256r1MLKEM768
SecP384r1MLKEM1024
Example
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class SecureClient {
public static void main(String[] args)
throws Exception {
HttpClient client =
HttpClient.newHttpClient();
HttpRequest request =
HttpRequest.newBuilder()
.uri(URI.create(
"https://example.com"))
.GET()
.build();
HttpResponse<String> response =
client.send(
request,
HttpResponse.BodyHandlers
.ofString());
System.out.println(
response.statusCode());
}
}
The Java application can continue using the standard HTTPS APIs while the TLS implementation handles supported cryptographic negotiation.
4. G1 Becomes the Default Garbage Collector Everywhere
G1 has been the default garbage collector for most Java applications since Java 9. Java 27 extends the default so that G1 is used across machine sizes instead of selecting Serial GC automatically for very small environments.
Small machine → G1
Large machine → G1
You can still explicitly select Serial GC when required:
java -XX:+UseSerialGC MyApplication
This change provides a more consistent garbage-collection default across Java environments.
5. Lazy Constants
Lazy Constants remain a preview feature in Java 27. They allow an immutable value to be initialized only when it is actually required.
Example
private final LazyConstant<Validator> validator =
LazyConstant.of(this::createValidator);
The expensive initialization does not have to happen when the application starts.
public Set<ConstraintViolation<Order>> validate(
Order order) {
return validator.get().validate(order);
}
The value is initialized when it is first requested and can then be reused.
6. Lazy Lists
Java 27 also continues the evolution of lazy collections.
List<Thumbnail> thumbnails =
List.ofLazy(
document.pageCount(),
this::renderThumbnail);
A potentially expensive value can be initialized when an element is accessed instead of constructing every value immediately.
Thumbnail thumbnail =
thumbnails.get(5);
This approach can be useful for large collections containing expensive-to-create objects.
7. Lazy Maps
Lazy maps can defer expensive value creation until a value is requested.
Set<String> currencies =
Set.of("USD", "EUR", "GBP", "JPY");
Map<String, BigDecimal> rates =
Map.ofLazy(
currencies,
this::fetchExchangeRate);
When the application requests:
BigDecimal rate = rates.get("JPY");
the corresponding value can be initialized lazily.
8. Lazy Sets
Java 27 adds lazy set support as part of the continuing Lazy Constants API.
Set<String> candidates =
Set.of(
"dark-mode",
"ai-assistant",
"live-collaboration");
Set<String> enabledFeatures =
Set.ofLazy(
candidates,
this::isFeatureEnabled);
The application can then query the set:
if (enabledFeatures.contains("ai-assistant")) {
System.out.println(
"AI Assistant is enabled");
}
Lazy Constants remain a preview feature, so developers should verify the exact API against the Java 27 preview documentation when compiling.
9. Primitive Types in Patterns, instanceof, and switch
Primitive Type Patterns continue as a preview feature in Java 27. Pattern matching is being extended to work more naturally with primitive values.
Example
int temperature = 38;
switch (temperature) {
case int t when t < 0 ->
System.out.println("Freezing");
case int t when t < 20 ->
System.out.println("Cold");
case int t when t < 30 ->
System.out.println("Warm");
case int t ->
System.out.println("Hot");
}
This allows the primitive value to be captured directly by the pattern.
The feature is part of Java's continuing evolution of pattern matching and remains a preview feature.
10. Structured Concurrency
Structured Concurrency remains a preview feature in Java 27. It provides a structured way to run and manage related concurrent tasks.
Consider an e-commerce application that needs product information, pricing, and inventory data.
try (var scope =
StructuredTaskScope.open()) {
var details =
scope.fork(() ->
catalogService.getDetails(productId));
var price =
scope.fork(() ->
pricingService.getPrice(productId));
var stock =
scope.fork(() ->
inventoryService.getStock(productId));
scope.join();
ProductPage page =
ProductPage.assemble(
details.get(),
price.get(),
stock.get());
}
The tasks form a structured hierarchy:
Product Request
|
+-- Product Details
|
+-- Price
|
+-- Inventory
This makes task lifetime, failure handling, and cancellation easier to manage.
11. Structured Concurrency and First Successful Result
Some applications need only one successful response from several services.
try (var scope =
StructuredTaskScope.open(
Joiner.<GeoCoordinates>
anySuccessfulOrThrow())) {
scope.fork(() ->
primaryGeocoder.lookup(address));
scope.fork(() ->
backupGeocoder.lookup(address));
scope.fork(() ->
offlineGeocoder.lookup(address));
GeoCoordinates result =
scope.join();
}
This model is useful for redundant services, backup APIs, search providers, and distributed applications.
12. Structured Concurrency Timeouts
Java 27 continues improving timeout handling for structured tasks.
try (var scope =
StructuredTaskScope.open(
config -> config
.withTimeout(
Duration.ofSeconds(2))
.withName("checkout"))) {
scope.fork(() ->
cartService.getCart(userId));
scope.fork(() ->
profileService.getProfile(userId));
scope.join();
}
A timeout prevents the application from waiting indefinitely for slow operations.
13. PEM Encodings of Cryptographic Objects
PEM files are commonly used for certificates and cryptographic keys. Java 27 continues the PEM API as a preview feature.
PEM Decoder Example
String pem = loadPrivateKey();
char[] password =
"secret".toCharArray();
PrivateKey key =
PEMDecoder.of()
.withDecryption(password)
.decode(
pem,
PrivateKey.class);
This avoids manually removing PEM headers, Base64 decoding the content, and constructing the cryptographic object.
PEM Encoder Example
String pem =
PEMEncoder.of()
.withEncryption(password)
.encodeToString(privateKey);
The result can be represented as an encrypted PEM private key.
14. Vector API
The Vector API remains an incubator feature in Java 27. It allows Java applications to express vector and SIMD-style operations.
Suppose two arrays contain numerical values:
A = [1, 2, 3, 4]
B = [5, 6, 7, 8]
The result is:
[6, 8, 10, 12]
Vector Addition Example
static final VectorSpecies<Float> SPECIES =
FloatVector.SPECIES_PREFERRED;
static void addVectors(
float[] a,
float[] b,
float[] result) {
int upperBound =
SPECIES.loopBound(a.length);
int i = 0;
for (; i < upperBound;
i += SPECIES.length()) {
FloatVector va =
FloatVector.fromArray(
SPECIES, a, i);
FloatVector vb =
FloatVector.fromArray(
SPECIES, b, i);
FloatVector vc =
va.add(vb);
vc.intoArray(result, i);
}
for (; i < a.length; i++) {
result[i] = a[i] + b[i];
}
}
The vector loop processes multiple elements at a time, while the final loop handles remaining elements.
The Vector API is particularly relevant to numerical computing, scientific applications, image processing, signal processing, and machine-learning workloads.
15. ISO-8601 Short Time-Zone Offsets
Java 27 improves date and time parsing for ISO-8601 short offsets.
For example:
2026-06-01T22:57:00+02
can be parsed using the standard ISO date-time formatter.
String value =
"2026-06-01T22:57:00+02";
OffsetDateTime dateTime =
OffsetDateTime.parse(
value,
DateTimeFormatter.ISO_DATE_TIME);
System.out.println(dateTime);
This improves interoperability with systems producing different valid ISO-8601 offset representations.
16. G1 Heap Free-Ratio Changes
Java 27 changes the G1-related default behavior for heap free-ratio settings.
The relevant JVM options are:
-XX:MinHeapFreeRatio
-XX:MaxHeapFreeRatio
The G1 defaults move toward:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
Developers can still explicitly configure these values when required:
java \
-XX:MinHeapFreeRatio=20 \
-XX:MaxHeapFreeRatio=80 \
MyApplication
17. G1IHOP Configuration Name
The G1 configuration option previously known as:
-XX:InitiatingHeapOccupancyPercent
has the shorter G1-specific name:
-XX:G1IHOP=45
The new name makes it immediately clear that the option belongs to G1.
18. JVMCI Removal
Java 27 removes the JVM Compiler Interface. JVMCI was introduced to support interaction between HotSpot and Java-based JIT compilers.
For most Java application developers, ordinary application code remains unchanged:
public class Application {
public static void main(String[] args) {
System.out.println(
"Hello Java 27");
}
}
The change primarily matters to specialized JVM and compiler integrations.
19. UseCompressedClassPointers Changes
The JVM option:
-XX:-UseCompressedClassPointers
is no longer a meaningful configuration for selecting uncompressed class pointers in Java 27.
Applications and deployment scripts that contain old JVM options should therefore be reviewed during Java 27 migration.
Java 27 Features at a Glance
| Feature | JEP | Status |
|---|---|---|
| Compact Object Headers | 534 | Final / Default |
| JFR In-Process Data Redaction | 536 | Final |
| Post-Quantum Hybrid TLS | 527 | Final |
| G1 Default Everywhere | 523 | Final |
| Lazy Constants | 531 | Preview |
| Primitive Type Patterns | 532 | Preview |
| Structured Concurrency | 533 | Preview |
| PEM Encodings | 538 | Preview |
| Vector API | 537 | Incubator |
| ISO-8601 Short Offsets | API Change | Available |
| G1 Configuration Changes | JVM Change | Available |
| JVMCI Removal | JVM Change | Removed |
Java Certification in 2026
Learning the latest Java features is valuable, but professional Java development also requires a strong understanding of Java fundamentals, APIs, object-oriented programming, collections, concurrency, exceptions, streams, and modern Java language features.
Developers preparing for professional certification can explore the Java Certification resources from MyExamCloud.
Oracle Certified Professional Java SE 25 Developer
The Oracle Certified Professional Java SE 25 Developer (1Z0-831) preparation course includes practice tests and study material for developers working with the latest long-term-support Java platform.
Java 27 learners can use Java 25 certification preparation to strengthen their understanding of modern Java concepts while continuing to experiment with newer Java 27 features.
Oracle Certified Professional Java SE 21 Developer
The Oracle Certified Professional Java SE 21 Developer (1Z0-830) certification is another important modern Java certification path.
Java 21 introduced several important language and platform improvements, making its certification preparation useful for developers building a strong modern Java foundation.
Oracle Certified Professional Java SE 17 Developer
Developers working with Java 17 can prepare using the Oracle Certified Professional Java SE 17 Developer (1Z0-829) practice tests.
Oracle Certified Professional Java SE 11 Developer
For organizations maintaining Java 11 applications, the Oracle Certified Professional Java SE 11 Developer (1Z0-819) preparation resources provide practice for the Java SE 11 developer certification.
Java Foundations Associate
Beginners can start with the Java Foundations Associate (1Z0-811) preparation resources before moving toward professional-level Java certifications.
Java SE 8 Certification
Developers maintaining legacy Java applications can also use Java SE 8 Programmer and Java SE 8 Programmer II practice resources.
Java Certification Path
For an overview of the certification journey, see the Oracle Java SE Certification Path 2026.
Developers can also explore the Java Developer Certification Roadmap 2026 to understand how Java certification can fit into a broader developer career plan.
Java 27 and Certification Preparation
Java 27 introduces several concepts that are useful for experienced Java developers, including advanced concurrency, JVM memory management, cryptography, pattern matching, and performance optimization.
For certification preparation, however, developers should not assume that every Java 27 preview or incubator feature will immediately appear in an Oracle certification exam. Certification objectives depend on the specific exam version and official exam syllabus.
A practical learning approach is:
- Master Java fundamentals.
- Build strong object-oriented programming skills.
- Learn collections, streams, exceptions, generics, and concurrency.
- Study modern Java language features.
- Prepare using realistic practice questions and mock exams.
- Experiment with newer Java features such as those introduced in Java 27.
Practice Java Certification Questions
MyExamCloud provides Java Certification Practice Tests and Mock Exams covering multiple Java certification levels.
Developers can also use Java Interview Questions and Answers to practice Java coding, APIs, collections, object-oriented programming, and interview-oriented questions.
Java 27: Final Takeaway
Java 27 is an important JVM and platform release. Its major themes include memory efficiency, secure diagnostics, post-quantum cryptography, garbage collection, concurrency, cryptographic APIs, pattern matching, and vector processing.
The most important production-oriented improvements include Compact Object Headers, JFR data redaction, post-quantum hybrid TLS, and G1 becoming the default garbage collector across environments.
At the same time, Lazy Constants, Primitive Type Patterns, Structured Concurrency, and PEM Encodings continue through preview stages, while the Vector API remains an incubator feature.
For Java developers, the best way to approach Java 27 is to understand both the new JVM improvements and the evolving language and API features, while continuing to build a strong foundation in the Java certification objectives relevant to their target exam.
| Author | Ganesh P Certified Artificial Intelligence Scientist (CAIS) | |
| Published | 1 week ago | |
| Category: | Software | |
| HashTags | #Java #Programming #Software |

