3 ms·
> Why hasn't this been done by anyone yet? That depends what you mean by "this." The Java spec requires you to support `new A()` by returning a fresh object or
by pron 4y ago
> Why hasn't this been done by anyone yet?
That depends what you mean by "this." The Java spec requires you to support `new A()` by returning a fresh object or throwing a VMError (like OutOfMemoryError). If by "this" you mean that allocations would succeed until some fixed amount of memory is exhausted, then, as others have pointed out, this has been done even in OpenJDK. If by "this" you mean that the allocation of some particular set of objects -- say, only those allocated during class initialisation -- would succeed regardless of memory consumption and all others would fail with an OutOfMemoryError, then I guess that it hasn't been done in that particular way because people haven't found it particularly useful as most Java programs would fail, but you can give it a try.
RTSJ, the specification for hard-realtime Java [1][2], actually goes further than that and supports both "static" memory (ImmortalMemory) and arenas (ScopedMemory). So if that's what you mean, then it has been done.
[1]: https://www.rtsj.org/specjavadoc/book_index.html https://www.rtsj.org/specjavadoc/book_index.html
[2]: https://www.aicas.com/download/rtsj/rtsj_76.pdf https://www.aicas.com/download/rtsj/rtsj_76.pdf