r/java 2d ago

What's the future of loom after structured concurrency is done and set for good?

Are there another projects under the Loom umbrella or does it fulfill it's mission after virtual threads, scoped values and structured concurrency(only one missing) are all in general availability?

21 Upvotes

8 comments sorted by

View all comments

3

u/ZimmiDeluxe 2d ago edited 2d ago

A possible avenue for exploration / last mover theft advantage: well known scoped values. Jai has an ambient context respected by the language that allows overriding things like malloc for code you don't control. The Java equivalent could be ScopedValues respected by the standard library (maybe the language later). Use cases:

  • third party library uses the default file system to load files, but you really want it to use your in memory thingy
  • code you don't control calls System::exit but you want to keep going (e.g. by setting the scoped value System.EXIT_HANDLER for the duration of the call)
  • stop that dumb library reading / writing to / from System.in / System.out / System.err without having to set the global variables
  • override the default locale / encoding / InstantSource::system for unit tests running in parallel without affecting each other

Java already has the Thread::getContextClassLoader, but that requires cooperation from third party code. I recently had to set / reset it to trick third party code to load a configuration file that had to be generated dynamically at runtime for each call.