31 | *
32 | * import java.lang.annotation.Documented;
33 | * import java.lang.annotation.ElementType;
34 | * import java.lang.annotation.Retention;
35 | * import java.lang.annotation.RetentionPolicy;
36 | * import java.lang.annotation.Target;
37 | *
38 | * {@literal @}Documented
39 | * {@literal @}Retention(RetentionPolicy.CLASS)
40 | * {@literal @}Target({ElementType.METHOD})
41 | * {@literal @}ContinuableAnnotation
42 | * public {@literal @}interface ContinuableMethod {
43 | * // The annotation to mark continuable methods
44 | * }
45 | *
46 | *
47 | *
48 | *
49 | * @author Valery Silaev
50 | *
51 | */
52 | @Documented
53 | @Retention(RetentionPolicy.CLASS)
54 | @Target(ElementType.ANNOTATION_TYPE)
55 | public @interface ContinuableAnnotation {
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/api/ccs.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2022 Valery Silaev (http://vsilaev.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.apache.commons.javaflow.api;
17 |
18 | import java.lang.annotation.Documented;
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | @Documented
25 | @Retention(RetentionPolicy.CLASS)
26 | @Target({ElementType.LOCAL_VARIABLE, ElementType.PARAMETER, ElementType.TYPE_USE})
27 | @ContinuableAnnotation
28 | public @interface ccs {}
29 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/api/continuable.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2022 Valery Silaev (http://vsilaev.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.apache.commons.javaflow.api;
17 |
18 | import java.lang.annotation.Documented;
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | @Documented
25 | @Retention(RetentionPolicy.CLASS)
26 | @Target({ElementType.METHOD})
27 | @ContinuableAnnotation
28 | public @interface continuable {}
29 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/ContinuableProxy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2022 Valery Silaev (http://vsilaev.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.apache.commons.javaflow.core;
17 |
18 | import java.lang.reflect.Proxy;
19 |
20 | /**
21 | * Marker interface for dynamic proxy classes like standard Java {@link Proxy} or CGLib Proxy.
22 | * Run-time instrumentation agent is capable to correctly decorate such proxies so continuable methods works correctly
23 | *
24 | * @author vsilaev
25 | *
26 | */
27 | public interface ContinuableProxy {}
28 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/ContinuationDeath.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.javaflow.core;
18 |
19 | /**
20 | * This exception is used to signal a control flow change that needs the
21 | * cooperation inside {@link StackRecorder}.
22 | *
23 | * 24 | * This class is only for javaflow internal code. 25 | *
26 | * 27 | * @author Kohsuke Kawaguchi 28 | */ 29 | final class ContinuationDeath extends Error { 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | private ContinuationDeath() {} 34 | 35 | public Throwable fillInStackTrace() { 36 | return this; 37 | } 38 | 39 | final static ContinuationDeath INSTANCE = new ContinuationDeath(); 40 | } 41 | -------------------------------------------------------------------------------- /net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/CustomContinuableProxy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-2022 Valery Silaev (http://vsilaev.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.apache.commons.javaflow.core; 17 | 18 | import java.lang.reflect.Proxy; 19 | 20 | /** 21 | * Generic interface for continuable dynamic proxy classes. 22 | * Unlike standard Java {@link Proxy} or CGLib Proxy where it's possible to resolve proxy -> handler 23 | * dependency via API, custom continuable proxies should provide implementation of this interface to get 24 | * corresponding "handler" from the proxied object, in the same manner as {@link Proxy#getInvocationHandler(Object)}. 25 | * 26 | * @author vsilaev 27 | * 28 | */ 29 | public interface CustomContinuableProxy { 30 | /** 31 | * Get a real continuable invocation handler for the proxy method descrived viamethodName
32 | * and methodDescription
.
33 | *
34 | * @param methodName name of the continuable method that is proxied
35 | * @param methodDescription arguments/return type of the method in internal JVM format
36 | * @return the continuable handler that processed invocation
37 | */
38 | public Object getInvocationHandler(String methodName, String methodDescription);
39 | }
40 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/EmptyStackException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.javaflow.core;
18 |
19 | /**
20 | * @author tcurdt
21 | *
22 | */
23 | public class EmptyStackException extends RuntimeException {
24 |
25 | private static final long serialVersionUID = 1L;
26 |
27 | public EmptyStackException(String message) {
28 | super(message);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/PlatformContinuationExecutor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2025 Valery Silaev (http://vsilaev.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.apache.commons.javaflow.core;
17 |
18 | final class PlatformContinuationExecutor {
19 | private PlatformContinuationExecutor() {
20 |
21 | }
22 |
23 | static ScopedContinuationExecutor current() {
24 | if (CHECK_THREAD) {
25 | Thread currentThread = Thread.currentThread();
26 | if (currentThread instanceof ScopedContinuationExecutor) {
27 | return (ScopedContinuationExecutor)currentThread;
28 | }
29 | }
30 | return ThreadLocalContinuationExecutor.INSTANCE;
31 | }
32 |
33 | private static final boolean CHECK_THREAD = Boolean.getBoolean("net.tascalate.javaflow.check-thread");
34 | }
35 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/ResumeParameter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2022 Valery Silaev (http://vsilaev.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.apache.commons.javaflow.core;
17 |
18 | public class ResumeParameter {
19 | private final Object value;
20 |
21 | private ResumeParameter(Object value) {
22 | this.value = value;
23 | }
24 |
25 | public static ResumeParameter value(Object value) {
26 | return null == value ? NULL_VALUE : new ResumeParameter(value);
27 | }
28 |
29 | public static ResumeParameter exit() {
30 | return EXIT;
31 | }
32 |
33 | final Object value() {
34 | return value;
35 | }
36 |
37 | void checkExit() {
38 |
39 | }
40 |
41 | private static final ResumeParameter NULL_VALUE = new ResumeParameter(null);
42 |
43 | private static final ResumeParameter EXIT = new ResumeParameter(null) {
44 | void checkExit() {
45 | throw ContinuationDeath.INSTANCE;
46 | }
47 | };
48 | }
49 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/ScopedContinuationExecutor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2025 Valery Silaev (http://vsilaev.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.apache.commons.javaflow.core;
17 |
18 | public interface ScopedContinuationExecutor {
19 | abstract public void runWith(StackRecorder stackRecorder, Runnable code);
20 | abstract public StackRecorder currentStackRecorder();
21 | }
22 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/Skip.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2022 Valery Silaev (http://vsilaev.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.apache.commons.javaflow.core;
17 |
18 | import java.lang.annotation.Documented;
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | @Documented
25 | @Retention(RetentionPolicy.RUNTIME)
26 | @Target({ElementType.TYPE})
27 | public @interface Skip {
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/SuspendResult.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2022 Valery Silaev (http://vsilaev.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.apache.commons.javaflow.core;
17 |
18 | public class SuspendResult {
19 |
20 | public static final SuspendResult CANCEL = new SuspendResult();
21 |
22 | public static final SuspendResult AGAIN = new SuspendResult();
23 |
24 | public static final SuspendResult EXIT = new SuspendResult();
25 |
26 | private final static SuspendResult NULL_VALUE = new SuspendResult() {
27 | public Object value() {
28 | return null;
29 | }
30 | };
31 |
32 | public Object value() {
33 | throw new UnsupportedOperationException();
34 | }
35 |
36 | public static SuspendResult valueOf(final Object value) {
37 | return null == value ? NULL_VALUE : new SuspendResult() {
38 | public Object value() {
39 | return value;
40 | }
41 | };
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/ThreadLocalContinuationExecutor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2025 Valery Silaev (http://vsilaev.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.apache.commons.javaflow.core;
17 |
18 | final class ThreadLocalContinuationExecutor implements ScopedContinuationExecutor {
19 |
20 | static final ScopedContinuationExecutor INSTANCE = new ThreadLocalContinuationExecutor();
21 |
22 | private static final ThreadLocal
32 | * When Continuation.suspend is called, all the methods in the stack frame needs
33 | * to be enhanced.
34 | *
35 | * @author tcurdt
36 | */
37 | public interface ResourceTransformer {
38 | byte[] transform(byte[] original);
39 | byte[] transform(byte[] original, String retransformClass);
40 | byte[] transform(byte[] original, String... retransformClasses);
41 | byte[] transform(byte[] original, Collection