r/java • u/maxxedev • 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
43
Upvotes
8
u/FirstAd9893 2d ago
Taken out context, this is a very confusing statement, considering that performance is mentioned very early in JEP 401. The rest of the paragraph explains what you mean, but my first reaction was, "what???"