Can't yield from within an instance created by reflection
Øystein Myhre Andersen
o.myhre at gmail.com
Tue Apr 6 11:51:39 UTC 2021
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();
}
}
Execution results in:
java.lang.IllegalStateException: Pinned: NATIVE
at java.base/java.lang.Continuation.onPinned(Continuation.java:508)
at java.base/java.lang.Continuation.onPinned0(Continuation.java:498)
at java.base/java.lang.Continuation.yield0(Continuation.java:468)
at java.base/java.lang.Continuation.yield(Continuation.java:431)
at simula2/a_simple_LoomTest.PinnedError.<init>(PinnedError.java:9)
at
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:83)
at
java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at
java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:498)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:479)
at simula2/a_simple_LoomTest.PinnedError$1.run(PinnedError.java:17)
at java.base/java.lang.Continuation.enter0(Continuation.java:396)
at java.base/java.lang.Continuation.enter(Continuation.java:389) TST
at java.base/java.lang.Continuation.run(Continuation.java:330)
at simula2/a_simple_LoomTest.PinnedError.main(PinnedError.java:21)
More information about the loom-dev
mailing list