Can't yield from within an instance created by reflection

Øystein Myhre Andersen o.myhre at gmail.com
Tue Apr 6 14:29:58 UTC 2021


That's a pity to remove such a basic feature. I am working on an open
source project to implement Simula using Java. As you probably know, Simula
was a great inspiration to James Gosling when he defined Java. Kristen
Nygaard and Ole-Johan Dahl strongly believed that basic concepts were the
thing. And I see Delimited Continuations as an important basic concept.
Simula introduced Quasi-parallel systems to define discrete event
simulation. You want to use it for virtual threads but it is possible that
there are somebody out there who will use it for eg artificial
intelligence. Why stop that opportunity - I will use it to implement Simula
coroutines ( QPS Sequencing).


By the way, I have also written an implementation that uses
oversynchronized threads. Platform threads works well but virtual threads
do not. There is something wrong there. I will return when it has been
analyzed more thoroughly.


If you are interested, the Simula project can be found here:
   https://portablesimula.github.io/github.io/



On Tue, Apr 6, 2021 at 2:55 PM Alan Bateman <Alan.Bateman at oracle.com> wrote:

> On 06/04/2021 12:51, Øystein Myhre Andersen wrote:
> > From: Øystein Myhre Andersen.
> >
> > Can't yield from within an instance created by reflection
> >
> > Is it meant to be like that, or will it be changed in the future?
> >
> > The following code sample illustrates the problem:
> >
> > class PinnedError {
> >     static final ContinuationScope scope=new ContinuationScope("TST");
> >
> >     public PinnedError(String id) {
> >        Continuation.yield(scope);
> >     }
> >
> >     public static void main(String[] args) {
> >        Continuation cont=new Continuation(scope,new Runnable() {
> >           public void run() {
> >              try {
> >                 Constructor<PinnedError> constr =
> > PinnedError.class.getConstructor(new Class[] { String.class });
> >                 constr.newInstance("Name");
> >              } catch (Exception e) { e.printStackTrace(); }
> >        }});
> >
> >        cont.run();
> >     }
> > }
>
> Just to add to Rémi's comments, this isn't an issue when using virtual
> threads. It's only an issue when using the Continuation API directly
> from a platform thread. The plan is to make this JDK internal soon, it's
> not meant to be exposed.
>
> -Alan
>


More information about the loom-dev mailing list