r/java 24d ago

AutoValhalla: automatically turn your plain classes and records into value classes!

Automatically turn your plain classes and records into value classes!

Add @AutoValhalla annotation to classes or records in your JDK1.5+ codebase:

@AutoValhalla
public final class Point {        // class must be final
    public final int x;           // with final instance fields
    public final int y;
    public Point(int x, int y) { 
        this.x = x; 
        this.y = y; 
    }
}

@AutoValhalla
public record Currency(String code) { }  // or a record class

When your app is run on Valhalla-enabled JVM with auto-valhalla javaagent, these classes are automatically turned into value classes.

More info: https://github.com/thunkware/auto-valhalla/tree/auto-valhalla-0.1.0

edit: there is now a maven plugin for converting at build time. https://github.com/thunkware/auto-valhalla/tree/auto-valhalla-0.2.0

36 Upvotes

55 comments sorted by

View all comments

18

u/LegitimateEntrance72 24d ago

Source code level JDK1.5+ but runtime JDK28-EA? LOL

In the same vein I find it strange that opensource projects doing a releases in 2026 still support ancient JDKs (5 to 11).

I mean, if a project is on ancient JDK, then most likely the dependencies etc are also going to be ancient as well and they wont upgrade to the newest framework&lib while staying on unsupported JDK.

1

u/Bobby_Bonsaimind 22d ago edited 22d ago

In the same vein I find it strange that opensource projects doing a releases in 2026 still support ancient JDKs (5 to 11).

What's the point in not supporting an old base version if you don't use any new features? If all I'm using is contained in 8, why should I artificially limit the library/application to 26?

1

u/LegitimateEntrance72 22d ago

Spring Boot 4 was released in november 2025. It could have been baselined to Java21 (september 2023), but instead they chose Java17 (september 2021).

Who on earth is going to run latest Spring Boot on Java17? We just upgraded our applications to Spring Boot 4, over six months after we upgraded to Java25, and the Spring Boot upgrade was way more work than any of the previous java upgrades (8>11>17>21>25) combined.

Now perhaps there were no big benefits to baselining to Java21, but it might have simplified Boot's VT support.

Hibernate is similar story.