Access to Continuation.yield and ContinuationScope

August Nagro augustnagro at gmail.com
Thu Nov 25 22:25:57 UTC 2021


Hi Raul,

I've found that you can replicate the same behavior of jl.Continuation
using a Reentrant lock on a virtual thread.

For example, see Coroutine.java in

https://github.com/AugustNagro/java-async-await


On Thu, Nov 25, 2021, 11:22 AM Raul Raja Martinez <raulraja at gmail.com>
wrote:

> Thanks!, that worked for my local tests.
>
> Are there any plans to bring back Continuation and ContinuationScope to
> public status to `java.lang` or similar or is the plan that this is going
> to remain internal?
> I'm aware of other libs in the space that also depend on their public
> status to perform operations unrelated to concurrency but related to the
> power of shifting control by yielding a scope in the continuation.
>
> thanks!
>
> On Thu, Nov 25, 2021 at 2:37 AM Glavo <zjx001202 at gmail.com> wrote:
>
> > You can add the --add-opens option at runtime, like this:
> >
> > java --add-opens java.base/jdk.internal.vm=ALL-UNNAMED <your-main-class>
> >
> >
> > Raul Raja Martinez <raulraja at gmail.com> 于2021年11月25日周四 上午7:56写道:
> >
> >> Hello everyone,
> >>
> >> First, thank you for LOOM and the extraordinary work done here. I'm
> >> excited
> >> to see this coming to a final release.
> >>
> >> I have been using LOOM builds up until recently, building abstractions
> >> directly on top of what used to be `java.lang.Continuation` and the
> >> `Continuation.yield` capabilities. I have noticed in the latest build
> >> these
> >> became internal in the jdk.internal.vm package.
> >>
> >> When I link against those I get errors like:
> >>
> >> java.lang.IllegalAccessError: superclass access check failed: class
> >> fx.Continuation$package$$anon$1 (in unnamed module @0x1f75bcda) cannot
> >> access class jdk.internal.vm.ContinuationScope (in module java.base)
> >> because module java.base does not export jdk.internal.vm to unnamed
> module
> >> @0x1f75bcda
> >>
> >> I wondered if there is a way to create and use Continuation.yield in
> this
> >> latest build, and if not, how would I go about implementing a use case
> >> like
> >> this currently expressed in Scala.
> >>
> >> https://gist.github.com/raulraja/5bd7ffaf4f9fc44bf99fefc14a5e640e
> >>
> >> Thank you!
> >>
> >> Raul.
> >>
> >
>
> --
> --
> Raúl Raja Martínez
> Co-founder @ 47 Degrees
> h: http://raulraja.com
> w: http://47deg.com
> t: http://twitter.com/raulraja
>


More information about the loom-dev mailing list