DS

Dan Smith

Things Dan Says on Podcasts

Where to Find Them

Dan Smith has been a guest on Inside Java .

Recently: “"Immutable Data Beyond Value Classes" [AtA]” on Inside Java (October 2026).

What They Said

They were discussing an incompatible change to how Java records initialise their fields. Asked about the compatibility cost, Dan describes the open-source survey the team ran, which found the change mostly broke code that was already buggy.

Inside Java · 2026-10-29 Permalink → Listen →
Inside Java Around 16:45 into the episode
Dan Smith

…about, check your nulls. And then everything gets implicitly assigned at the end. And so rather than putting super at the start of that thing, we'd like to move super to the end after the fields are assigned. And then they'll be assigned in that early phase, and they'll be set beforehand. Well,

Speaker 2

certainly speaking, it is incompatible. Change, right? Because if in the constructor I call.

Dan Smith

Yes. So yeah, we looked at a lot of open source code, looking for examples of records and whether this would be a concern. We found a handful of classes that would get a new compiler error. The vast majority. Nobody is trying to manipulate this. It's especially an odd thing to do in a record constructor. Yes. Because all you want to do is store your data in the fields. And so validation, maybe mapping your input to a normalized form or something, but you're not typically going to do something. So we found a handful of places where somebody had referred to this in the constructor. And more than half of them were actually bugs. Where somebody had, it was an example like, I'm doing some validation on my input. There's an error. Or maybe, not even, I don't check it. I hand it off to some static method somewhere that's going to do the validation and generate an error message if my thing is null or whatever. And they would pass this into that side static method that's doing the validation. And then if there is an error, the method is going to call toString to give you some diagnostic about where the error was located. And the toString is just going to print a record with all its fields being null because they haven't…

Speaker 2

we have to reiterate because in the compact constructor, the fields are assigned after the code that I write. So if the code that I write passes this off to some error reporting, then that error reporting will happen before. Like overall, I don't think it's a common problem. It doesn't happen…

Dan Smith

hard to diagnose. One example I've used to talk about static initialization, which also has this property where you can initialize one thing and then you're not done. You're not done with all your initialization, but some other code is running and it comes back and it tries to read something that…

Speaker 2

Yeah. Okay, so we straight a bit, we talked about the importance or that the fact that people would like to work more with data and rather would more like maybe to model data as data, which is inherently an immutable. It's

Speaker names come from our own diarization. The position is estimated from where the line sits in the episode.

Collections They Appear In