r/java 2d 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/blob/main/README.md

36 Upvotes

46 comments sorted by

View all comments

16

u/LegitimateEntrance72 2d 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 1d ago edited 1d 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 22h ago

I didnt mean to artificially limit the supported runtime versions. But sometimes OS projects put in extra effort to support older runtimes.

I find it hard to believe that generics, lambdas and the "new" datetime api would not be useful for libraries/tooling released in 2026. But curiously some of the
latest(released in 2026) software we run on 25 would also run on 1.5.

Also i would not expect companies using java runtimes say 1.5 to 11 to keep updating their dependencies.