Back to Advanced Topics
Q11Question 11 of 41

What are the major OpenJDK projects and what does each change?

Key Concepts
  • Loom delivers virtual threads and structured concurrency, making blocking thread-per-request code scale to millions of concurrent tasks.
  • Valhalla introduces value and primitive classes that the JVM can flatten inline, eliminating boxing overhead and pointer indirection.
  • Panama provides the Foreign Function and Memory API for safe native interop replacing JNI, plus the Vector API for SIMD parallelism.
  • Amber delivers incremental language features: records, sealed types, pattern matching, and text blocks to reduce boilerplate.
  • Leyden targets faster startup through ahead-of-time compilation and class-data sharing for cloud and serverless workloads.
  • Loom and most of Amber are final today; Valhalla, Leyden, and the Vector API are still maturing.

Definition

Loom makes concurrency cheap, Valhalla makes small objects cheap, Panama bridges native code and adds SIMD, Amber simplifies the language, and Leyden makes startup fast.
  • Project Loom – virtual threads and structured concurrency that make massive blocking-style concurrency cheap without reactive frameworks.
  • Project Valhalla – value and primitive classes that let the JVM flatten objects and eliminate boxing overhead for small immutable types.
  • Project Panama – the Foreign Function and Memory API (replacing JNI) and the Vector API for SIMD parallelism.
  • Project Amber – incremental language features: records, sealed types, pattern matching, text blocks, reducing boilerplate.
  • Project Leyden – ahead-of-time compilation and class-data sharing for fast startup in cloud and serverless deployments.

Think of the Java platform as National Bank of India running five renovation programs in parallel. Loom rebuilds the counters so one branch serves a million customers at once. Valhalla redesigns the forms so amounts and codes are stored compactly. Panama builds a bridge to partner systems and adds a batch-processing machine. Amber simplifies the paperwork. Leyden makes the branch open instantly each morning. Together they transform the bank.

Understanding the Concepts

What is Project Loom?

Project Loom attacks the cost of concurrency. A platform thread maps one-to-one to an OS thread, using about a megabyte of stack, so you can run only a few thousand. Loom adds virtual threads that are managed by the JVM and mounted onto a small pool of carrier threads only while running. When a virtual thread blocks on I/O, it unmounts and frees the carrier.

JAVA
package com.bank.service;

import java.math.BigDecimal;
import java.util.concurrent.Executors;

public class VirtualThreadDemo {
    public static void main(String[] args) throws Exception {
        // One virtual thread per request: scales to millions
        try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
            for (int i = 0; i < 100_000; i++) {
                final int accountId = i;
                executor.submit(() -> {
                    // Simulates blocking I/O (database call)
                    BigDecimal balance = fetchBalance(accountId);
                    return balance;
                });
            }
        }
        System.out.println("100,000 virtual threads completed.");
    }

    static BigDecimal fetchBalance(int accountId) {
        try { Thread.sleep(10); } catch (InterruptedException e) { }
        return new BigDecimal("50000.00");
    }
}
TEXT
100,000 virtual threads completed.

What is Project Valhalla?

Valhalla introduces value classes: immutable objects with no identity that the JVM can flatten inline. Today, storing a Money object in a collection means a heap allocation, an object header, and pointer indirection. With value classes, the JVM stores the value directly in the array, like a C struct.

JAVA
package com.bank.model;

import java.math.BigDecimal;

// Future Valhalla syntax (preview)
// value class Money {
//     BigDecimal amount;
//     String currency;
// }

// Today's approximation using record
public record Money(BigDecimal amount, String currency) {
    public Money {
        if (amount == null || currency == null) {
            throw new IllegalArgumentException("Amount and currency required");
        }
    }
}

What is Project Panama?

Panama provides the Foreign Function and Memory API for calling native code safely, replacing JNI. It also includes the Vector API for SIMD parallelism.

JAVA
package com.bank.risk;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;

public class OffHeapPrices {
    public static void main(String[] args) {
        try (Arena arena = Arena.ofConfined()) {
            // Allocate off-heap memory for 1000 prices
            MemorySegment prices = arena.allocate(
                ValueLayout.JAVA_DOUBLE, 1000);

            // Store price at index 0
            prices.setAtIndex(ValueLayout.JAVA_DOUBLE, 0, 2450.75);
            double price = prices.getAtIndex(ValueLayout.JAVA_DOUBLE, 0);
            System.out.println("Bond price: " + price);
        }
    }
}
TEXT
Bond price: 2450.75

What is Project Amber?

Amber delivers incremental language features that reduce boilerplate. Records, sealed types, pattern matching, and text blocks all come from Amber.

JAVA
package com.bank.model;

import java.math.BigDecimal;

// Record: one-line immutable data carrier
public record TransferReceipt(
    String from, String to, BigDecimal amount) {}

// Sealed type with exhaustive switch
public sealed interface TransactionResult
    permits Approved, Declined, Pending {}

public record Approved(BigDecimal amount) implements TransactionResult {}
public record Declined(String reason) implements TransactionResult {}
public record Pending(String referenceId) implements TransactionResult {}
JAVA
package com.bank.service;

import com.bank.model.*;
import java.math.BigDecimal;

public class ResultProcessor {
    public static String process(TransactionResult result) {
        return switch (result) {
            case Approved a -> "Approved: " + a.amount();
            case Declined d -> "Declined: " + d.reason();
            case Pending p  -> "Pending: " + p.referenceId();
            // No default needed: sealed + exhaustive
        };
    }
}

What is Project Leyden?

Leyden targets startup and footprint. Java's JIT compiler delivers excellent peak performance but needs warmup. Leyden shifts work to build time through class-data sharing and ahead-of-time compilation, so applications reach peak performance sooner.

BASH
# Create a CDS archive for faster startup
java -Xshare:dump -XX:SharedArchiveFile=app-cds.jsa \
     -cp app.jar com.bank.Main

# Start with the archive
java -Xshare:on -XX:SharedArchiveFile=app-cds.jsa \
     -cp app.jar com.bank.Main

How do the projects compare?

| Project | Pain removed | Status | Key deliverable |
|---------|-------------|--------|----------------|
| Loom | Concurrency at scale | Final (Java 21+) | Virtual threads, structured concurrency |
| Valhalla | Boxing and object overhead | Preview/incubating | Value classes, primitive generics |
| Panama | Unsafe native interop | FFM final (Java 22), Vector incubating | Foreign Function API, Vector API |
| Amber | Language boilerplate | Records, sealed, pattern matching final | Records, sealed types, patterns |
| Leyden | Slow startup | In progress | AOT compilation, enhanced CDS |

What should a senior engineer know?

These projects are coordinated bets on where Java must improve. Understanding which project a feature comes from tells you its maturity (preview vs. final) and its intent. Loom and Amber are production-ready today. Valhalla and the Vector API are still evolving. Knowing the roadmap lets you design systems that ride the platform forward.

How are these used together in a banking system?

Consider a risk-pricing engine at National Bank of India. Loom lets it accept a hundred thousand concurrent requests with blocking code. Valhalla will let price values live in flat arrays. Panama vectorizes pricing math and calls native libraries safely. Amber expresses the domain with records and sealed types. Leyden makes the service start in milliseconds for serverless deployment. No single project makes this system; the combination makes it simultaneously simple, concurrent, efficient, and fast to start.

Visual Overview

DIAGRAM
  ┌──────────────────────────────────────────────────┐
  │              OpenJDK Platform Evolution            │
  │                                                    │
  │  Loom ──────▶ Virtual threads + structured conc.  │
  │  Valhalla ──▶ Value classes + primitive generics   │
  │  Panama ────▶ FFM API + Vector API (SIMD)          │
  │  Amber ─────▶ Records + sealed + patterns          │
  │  Leyden ────▶ AOT + CDS (fast startup)             │
  └──────────────────────────────────────────────────┘

  How they compound:

  Simple code    ──▶ Loom (blocking style that scales)
       +
  Compact data   ──▶ Valhalla (flat, no boxing)
       +
  Fast compute   ──▶ Panama (SIMD + native interop)
       +
  Clean models   ──▶ Amber (records, sealed, patterns)
       +
  Fast startup   ──▶ Leyden (AOT + CDS)
       =
  High-performance, simple, cloud-ready Java

Key Takeaway

The major OpenJDK projects each evolve a different dimension of the platform. Loom delivers virtual threads and structured concurrency so simple blocking code scales to millions of tasks. Valhalla introduces value classes that the JVM can flatten inline, eliminating boxing. Panama bridges native code with the Foreign Function API and adds SIMD with the Vector API. Amber makes the language more expressive with records, sealed types, and pattern matching. Leyden targets fast startup through ahead-of-time compilation and class-data sharing.

These are not random features but coordinated bets. In a risk-pricing engine at National Bank of India, Loom handles a hundred thousand concurrent valuations, Valhalla will store prices in flat arrays, Panama vectorizes the math, Amber expresses the domain concisely, and Leyden makes it start in milliseconds. The combination makes a system that is simple, concurrent, efficient, and fast to start.

Understanding the roadmap changes how you design. If Loom is here, stop reaching for reactive frameworks by default. If Valhalla is coming, design value-like types anticipating flattening. If Panama exists, keep numeric work in Java instead of maintaining a separate C service.

Remember one sentence: Loom makes concurrency cheap, Valhalla makes data compact, Panama bridges native and SIMD, Amber cuts boilerplate, and Leyden makes startup instant, and together they compound into a platform where simple code is also high-performance code.

---

Share
Use ← → arrow keys to navigate