As well known, we utilized the following 'lazy initialization' pattern extensively in our codebase to save memory:
However, even since JDK7, ArrayList has gone through refactoring to keep from allocating
memory for 10 elements in advance, if the instance was created by default constructor and the allocation of memory
is only done when some element is really added in future. Namely, ArrayList has the lazy initialization feature built-in.
E.g., see https://stackoverflow.com/questions/33688753/jdk-api-documentation-is-incorrect-for-arraylist-constructor-is-that-a-bug
for details. You can also browse the source code of ArrayList to confirm.
Needless to say, the lazy initialization pattern has serious NPE issue if it is not coded carefully (which is tedious and error-prone per se).
As an active Hibernate v6 contributor, I am troubled by such NPE issue again and again.
Is it a good timing to get rid of the above lazy initialization pattern for now?
Hopefully my message is good food for thought. No finger pointing. Just curious.