Java Development

Lombok & JDK 25: The Ultimate 2025 Compatibility Guide

Your ultimate guide to ensuring Project Lombok is fully compatible with JDK 25. Learn to update configs, fix common errors, and leverage modern Java features.

D

Daniel Weber

Senior Java Engineer specializing in JVM performance, developer productivity tools, and modern Java.

6 min read4 views

Introduction: The Perennial Question of Compatibility

For over a decade, Project Lombok has been a Java developer's best friend, dutifully cleaning up our codebases by eradicating boilerplate for getters, setters, constructors, and more. It's a testament to its usefulness that it remains one of the most popular libraries in the Java ecosystem. However, with every new Java Development Kit (JDK) release, a familiar question echoes through development teams: "Will our tools, especially Lombok, still work?"

As we look towards 2025 and the arrival of JDK 25, this question is more relevant than ever. New JDK versions bring not just exciting language features but also potential changes to the Java Compiler API (Javac) and bytecode structure—the very mechanisms Lombok relies on to perform its magic. This guide is your definitive resource for ensuring a smooth, successful integration of Project Lombok with JDK 25. We'll cover everything from versioning and configuration to troubleshooting and the long-term role of Lombok in modern Java.

What's New in JDK 25? (And Why Lombok Cares)

While the final feature set of JDK 25 is still solidifying, we can anticipate the continuation of major projects that could influence Lombok. These include advancements in Project Amber (Pattern Matching, String Templates), Project Loom (Structured Concurrency), and Project Valhalla (Value Objects).

Why does this matter for a library like Lombok? Lombok isn't a typical dependency; it's an annotation processor that hooks directly into the compilation process. Changes to:

  • Compiler Internals: Any modification to the Abstract Syntax Tree (AST) or the internal APIs of Javac can break Lombok's ability to transform code. The Lombok team must constantly adapt to these changes.
  • Bytecode Generation: New language features often require new bytecode patterns. Lombok must ensure the code it generates is compatible and doesn't conflict with the compiler's output.
  • Language Semantics: As features like Records become more powerful or new constructs like Value Objects are introduced, the areas where Lombok provides value shift.

Understanding these potential interactions is key to appreciating the work required to maintain compatibility and to troubleshoot issues when they arise.

The Verdict: Is Lombok Ready for JDK 25?

Let's cut to the chase: Yes, the Project Lombok team is historically very proactive in supporting new JDK releases, and JDK 25 is no exception. Typically, experimental support for a new JDK is available in a pre-release version of Lombok even before the JDK itself reaches General Availability (GA).

However, "works" comes with an important caveat: you must use a version of Lombok specifically released to support JDK 25. Attempting to use an older version of Lombok with a brand-new JDK is a guaranteed recipe for compilation errors, as the processor won't understand the updated compiler internals. The cardinal rule is simple: When you update your JDK, you must also update Lombok.

Your Step-by-Step JDK 25 & Lombok Configuration Guide

Ready to get your project running on the latest and greatest? Follow these steps precisely to ensure a seamless experience.

Step 1: Use the Latest Lombok Version

This is the most critical step. Check the official Project Lombok changelog or their GitHub releases page to find the version that explicitly states support for JDK 25. As of early 2025, you'll likely be looking for a version such as 1.18.32 or newer. Using an older version like 1.18.28 will fail.

Step 2: Update Your Build Tool Configuration

Your `pom.xml` or `build.gradle.kts` file needs to be updated to point to the correct Lombok version. It's also crucial to correctly configure the `annotationProcessorPaths` to ensure the build system uses Lombok during compilation.

Maven (`pom.xml`)

Ensure your properties section defines the new JDK version and your Lombok dependency is correctly scoped.

<properties>
    <maven.compiler.source>25</maven.compiler.source>
    <maven.compiler.target>25</maven.compiler.target>
    <lombok.version>1.18.32</lombok.version> <!-- Use the version that supports JDK 25 -->
</properties>

<dependencies>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

Gradle (`build.gradle.kts`)

For Gradle, the configuration is just as straightforward. Define the version and add it to the `compileOnly` and `annotationProcessor` configurations.

plugins {
    java
}

java {
    sourceCompatibility = JavaVersion.VERSION_25
    targetCompatibility = JavaVersion.VERSION_25
}

val lombokVersion = "1.18.32" // Use the version that supports JDK 25

dependencies {
    compileOnly("org.projectlombok:lombok:$lombokVersion")
    annotationProcessor("org.projectlombok:lombok:$lombokVersion")

    testCompileOnly("org.projectlombok:lombok:$lombokVersion")
    testAnnotationProcessor("org.projectlombok:lombok:$lombokVersion")
}

Step 3: Don't Forget Your IDE Plugin

Your build might succeed, but your IDE might still show errors if its internal Lombok plugin is outdated. Lombok's magic works at two levels: compile-time (for the build) and IDE-time (for error highlighting and code completion). Ensure your IDE's Lombok plugin is updated to the latest version. For IntelliJ IDEA, go to `Settings/Preferences > Plugins` and check for updates. For VS Code and Eclipse, check their respective marketplaces.

Step 4: Navigating Common Pitfalls

  • `NoArgsConstructor` errors: If you see errors related to missing constructors on a class with final fields, remember that Lombok's `@NoArgsConstructor` can't initialize them. Use `@RequiredArgsConstructor` or initialize them inline. This isn't new to JDK 25, but it's a frequent stumbling block.
  • `delombok` issues: If you use `delombok` to generate plain Java source code, ensure your build process is using the JDK 25-compatible version of the tool. Mismatched versions can lead to malformed or incorrect code.
  • Module Path Complications: If your project uses the Java Platform Module System (JPMS), ensure your `module-info.java` is correctly configured. You'll need a `requires static lombok;` directive.

Lombok vs. Native Java: A 2025 Perspective

With each new Java release, the language natively adopts features that overlap with Lombok's functionality. This is a good thing! It shows the language is evolving. Here’s how they stack up in the era of JDK 25.

Lombok Annotations vs. Native Java Features
FeatureThe Lombok WayThe Native Java WayWhen to Use Which
Immutable Data Carrier`@Value` or `@Data` with `@AllArgsConstructor``public record Person(String name, int age) {}`For simple, immutable data transfer objects (DTOs), Records are superior. They are concise, semantic, and a core language feature.
Object Builder`@Builder`Manual static inner class builder pattern.Lombok's `@Builder` is still king for complex object creation, especially for mutable classes or when you need advanced configurations like custom setters or default values. It's far less verbose than a manual implementation.
Getters & Setters`@Getter` / `@Setter`Manually written methods.For mutable domain objects (JPA entities, etc.), Lombok is the clear winner for reducing boilerplate. There is no native equivalent for auto-generating standard getters and setters.
Resource Management`@Cleanup``try-with-resources` statementAlways prefer `try-with-resources`. It's a fundamental, safer, and more universally understood language construct for managing resources that implement `AutoCloseable`.

The Future of Lombok in an Evolving Java Landscape

Is Lombok becoming obsolete? Absolutely not. While Records have rightfully taken over the use case for simple data carriers, Lombok continues to provide immense value in other areas:

  • Mutable Classes: For stateful objects, like JPA Entities or traditional domain models, `@Data`, `@Getter`, `@Setter`, and `@ToString` are indispensable.
  • Advanced Builders: `@Builder` offers customization that goes beyond simple object instantiation, making it a powerful tool for creating complex object graphs.
  • Utility Annotations: Features like `@Slf4j` for logging, `@SneakyThrows` for checked exceptions, and `@EqualsAndHashCode` with fine-grained control remain highly useful.

Lombok's role is shifting from a provider of fundamental features to a toolkit of powerful, productivity-enhancing utilities that fill the gaps left by the core language. As long as Java developers need to write mutable classes and complex builders, Lombok will have a place in their `pom.xml`.

Conclusion: A Powerful Partnership

Navigating the upgrade to a new JDK can seem daunting, but when it comes to Lombok and JDK 25, the path is clear. By diligently updating your Lombok dependency, build configurations, and IDE plugins, you can ensure these two powerful tools work together in harmony. The combination allows you to leverage the latest performance and language improvements from the JDK while keeping your codebase clean, concise, and maintainable with Lombok.

Embrace the update. The future of Java is bright, and with the right setup, Lombok is ready to come along for the ride, letting you focus on what truly matters: building great software.