TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

JEP 506: Scoped Values final for Java 25

34 pointsby ludovicianul30 days ago

4 comments

Pet_Ant29 days ago
So it sort of looks like a DSL for a variant of ThreadLocal that gives you an idea of the lifeline of variable instead of just being global. Apparently with virtual threads they are expecting an increase in the number of running (virtual) threads several orders of magnitude larger than what was previously seen and that with ThreadLocals would just be too much.<p>So the have added this:<p>&gt; ScopedVaule.where(CONTEXT, context).run(() -&gt; Application.handle(request, response));<p>Which stores the object referenced by `context` to the ScopedValue container `CONTEXT` ^ for the duration of the thread running `Application.handle(request,response)`.<p>Not really sexy, but I understand how you might really benefit if you are processing lots of data, but for most enterprise CRUD apps this seems inapplicable.<p>^ I think this a &quot;monad&quot;? I&#x27;m not a functional programmer.
评论 #43700019 未加载
bhawks29 days ago
Implicit parameter smuggling by any mechanism is just too much magic in my experience. Golang&#x27;s context.Context solves the same problem, but explicitly in a way that has been widely adopted through their language ecosystem.<p>That said - in Java I do think it would be near impossible for the ecosystem to adopt a similar mechanic, so from a practical standpoint this may be the only way to reliably propagate context.
评论 #43704692 未加载
djenndhxhd29 days ago
Tramp parameters are a common occurrence, if not avoided with care.<p>I see value in this proposal
skerit29 days ago
Interesting proposal, I can see myself using this.