←back to thread

204 points mfiguiere | 1 comments | | HN request time: 0.21s | source
Show context
cogman10 ◴[] No.43539883[source]
Hmm, not a bad approach.

I think the one thing that'd be nice is if I could somehow tell the JVM from a class that this class is open for final mutation rather than needing special flags passed into the JVM or special manifests in the Jar. It's often pretty clear to me, as a dev, what I when I need something to have final mutation (generally only with serialization objects).

For example,

    @FinalMutatableByReflection
    class Foo {
      final String bar;
    }
That'd allow me to transition code by just adding an annotation where it needs to be while also getting the benefit that final is really final everywhere else in code that isn't working with serialization.
replies(4): >>43540109 #>>43540145 #>>43541506 #>>43542330 #
owlstuffing ◴[] No.43541506[source]
The issue is that many essential libraries and tools rely on setting internal final fields. I assume that's why the options around this have remained open-ended.

The problem with these various "integrity by default" options is that, in most cases, granting access to one effectively grants access to all. For instance, JNI, agent libraries, and JPMS options can each be used to bypass restrictions, making the separation between them largely illusory. Integrity, as framed here, is ultimately binary.

The unfortunate reality of the "integrity by default" crusade is that applications relying on libraries and tools that modify internals will continue to do so. The JDK hasn’t filled any gaps—it has only made an already delicate situation worse.

replies(3): >>43541774 #>>43541788 #>>43542336 #
pron ◴[] No.43541788[source]
First, it's not a "crusade" but the steps necessary to deliver the features Java's users demand. Second, the prevalence of the use of JDK internals has dropped drastically, and demonstrably so. For example, many programs broke before internals were encapsulated during the upgrade from 8 to 9; 99% of the causes were libraries relying on internals, which had changed. Access to internals was closed off in JDK 16, although, as you say, it can be selectively allowed. And yet, between JDK 17 and JDK 23, changes of similar magnitude to the JDK internals caused nearly no upgrade problems. Upgrading the JDK now is smoother and easier than it's been in the last two decades. Why? Because there's been a large reduction in libraries' access to internals.

I think Java's handling of this transition compares very favourably to how other languages have handled similar transitions from some old model to a new one (or evolution in general) in terms of balancing the needs of both old and new projects.

replies(2): >>43542139 #>>43553477 #
cogman10 ◴[] No.43542139[source]
I can attest to how easy it's become to update jdks for our org.

8->11 was really a pain in the neck. 11->17 had some pain, but mostly was nothing serious.

17->21 has been painless.

And I have some projects running on 24 already with no problems.

The feature delivery has been great and we are getting pretty close to not needing to do anything but update the jdk to move forward.

Now, if only I could get devs to stop using lombok....

replies(5): >>43542341 #>>43542997 #>>43543123 #>>43543525 #>>43545478 #
1. xxs ◴[] No.43545478[source]
>Now, if only I could get devs to stop using lombok....

that's actually not too hard. It has happened to get them all converted to avid opponents of lombok.