3 ms·
In my opinion this is not a bug and there is no general fix for that without significant overhaul of the whole runtime and standard library. In my opinion the
by pshirshov 3y ago
In my opinion this is not a bug and there is no general fix for that without significant overhaul of the whole runtime and standard library.
In my opinion the author might need to read the vm and memory model spec and understand that such things are expected in Java.
There are real bugs in standard library singletons (e.g. concurrent Filesystem calls might fail during singleton initialization, while plugins are loaded). These bugs are being ignored for years.
The author must not expect any "fix" for this in foreseeable future, but they might expect being laughed at.
- marginalia_nu 3y agoEh, I don't think the author is to be ridiculed. We're all wrong from time to time, I'm wrong in most of what I say, I'm sure you've been wrong on occasions, this is fine. The author's views on how concurrency works is very common and taught in schools and textbooks, but also quite inadequate. Instead let's take this opportunity to talk and teach about the JMM and deepen the collective understanding of the many unintuitive behaviors of multi-threaded applications.
- haspok 3y agoMaybe there could be a JMM 2.0 where at least some of the unexpected behaviour is removed. Maybe even at the cost of performance. If something is misunderstood by >99% of the average programmer population then clearly it is not the best solution to the problem.
- marginalia_nu 3y agoIf that many programmers don't understand the JMM, it's because that many programmers haven't looked at it. It is the key to reasoning about Java concurrency. Any other model that is not the JMM is flat out wrong. It is virtually impossible to write correct concurrent Java without understanding the memory model.
- barrkel 3y agoA defensive copy is the cheap way to fix this. The bug is a potential security vulnerability since it can affect the value of interned strings, which can break other libraries.
- pshirshov 3y agoThat still has to be done ad-hoc and might kill performance for many usecases. This is not a bug, but a specified behavior.
- mmis1000 3y agoEven the example in article alone. Imagine someone intern a broken "script" string, and people trying to sanitize HTML script tags no longer find it.