Skip to content

Commit 8af0fd4

Browse files
committed
Refactor Core / Proxy Agents; Fixes & optimizations for providers; Fixes for run-time ClassLoader to work with JDK 17 and modular class loading
1 parent 4013d00 commit 8af0fd4

File tree

92 files changed

+598
-593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+598
-593
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
[![Maven Central](https://img.shields.io/maven-central/v/net.tascalate.javaflow/net.tascalate.javaflow.parent.svg)](https://search.maven.org/artifact/net.tascalate.javaflow/net.tascalate.javaflow.parent/2.6.4/pom) [![GitHub release](https://img.shields.io/github/release/vsilaev/tascalate-javaflow.svg)](https://github.com/vsilaev/tascalate-javaflow/releases/tag/2.6.4) [![license](https://img.shields.io/github/license/vsilaev/tascalate-javaflow.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)
1+
[![Maven Central](https://img.shields.io/maven-central/v/net.tascalate.javaflow/net.tascalate.javaflow.parent.svg)](https://search.maven.org/artifact/net.tascalate.javaflow/net.tascalate.javaflow.parent/2.7.0/pom) [![GitHub release](https://img.shields.io/github/release/vsilaev/tascalate-javaflow.svg)](https://github.com/vsilaev/tascalate-javaflow/releases/tag/2.7.0) [![license](https://img.shields.io/github/license/vsilaev/tascalate-javaflow.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)
22

33
# IMPORTANT NOTICE FOR RELEASE 2.5.0!!!
4-
Java 9+ is fully supported now, all artefacts are modular multi-release JAR-s that works correctly with Java versions 1.6 to 11. The library code was tested with JDK 11, and all features of the Java 11 bytecode (including nest of inner classes) works correctly.
4+
Java 9+ is fully supported now, all artefacts are modular multi-release JAR-s that works correctly with Java versions 1.6 to 17. The library code was tested with JDK 17, and all features of the Java 17 bytecode (including nest of inner classes) works correctly.
55

66
# IMPORTANT NOTICE FOR RELEASE 2.3.0!!!
77
- `net.tascalate.javaflow.extras` artifact is withdrawn, its code serves as a basis for the project [Tascalate JavaFlow Util](https://github.com/vsilaev/tascalate-javaflow-util)
@@ -29,7 +29,7 @@ You have to add the following configuration to enable build-time instrumentation
2929
<dependency>
3030
<groupId>net.tascalate.javaflow</groupId>
3131
<artifactId>net.tascalate.javaflow.api</artifactId>
32-
<version>2.6.4</version>
32+
<version>2.7.0</version>
3333
</dependency>
3434
<!-- Add-on for Java 8 and above -->
3535
<dependency>
@@ -46,15 +46,15 @@ You have to add the following configuration to enable build-time instrumentation
4646
<groupId>org.apache.maven.plugins</groupId>
4747
<artifactId>maven-compiler-plugin</artifactId>
4848
<configuration>
49-
<!-- versions 1.6 -- 11 are supported -->
49+
<!-- versions 1.6 -- 17 are supported -->
5050
<source>1.6</source>
5151
<target>1.6</target>
5252
</configuration>
5353
</plugin>
5454
<plugin>
5555
<groupId>net.tascalate.javaflow</groupId>
5656
<artifactId>net.tascalate.javaflow.tools.maven</artifactId>
57-
<version>2.6.4</version>
57+
<version>2.7.0</version>
5858
<executions>
5959
<execution>
6060
<phase>process-classes</phase>
@@ -67,7 +67,7 @@ You have to add the following configuration to enable build-time instrumentation
6767
</plugins>
6868
</build>
6969
```
70-
Note that if you are using continuations with Java 1.8 lambdas then you need to add [Tascalate JavaFlow instrumentation agent](https://github.com/vsilaev/tascalate-javaflow/releases/download/2.6.4/javaflow.instrument-continuations.jar) at run-time as command-line option, while lambda-related classes are generated by JVM on the fly and there is no other way to instrument them. If this is not an option, then you can de-sugar all lambdas with [RetroLambda](https://github.com/luontola/retrolambda) Maven plugin at build-time (RetroLambda output is supported by Tascalate JavaFlow 2.3.2 or higher).
70+
Note that if you are using continuations with Java 1.8 lambdas then you need to add [Tascalate JavaFlow instrumentation agent](https://github.com/vsilaev/tascalate-javaflow/releases/download/2.7.0/javaflow.instrument-continuations.jar) at run-time as command-line option, while lambda-related classes are generated by JVM on the fly and there is no other way to instrument them. If this is not an option, then you can de-sugar all lambdas with [RetroLambda](https://github.com/luontola/retrolambda) Maven plugin at build-time (RetroLambda output is supported by Tascalate JavaFlow 2.3.2 or higher).
7171

7272
Please refer to [pom.xml](https://github.com/vsilaev/tascalate-javaflow-examples/blob/master/net.tascalate.javaflow.examples.common/pom.xml) in examples project for typical Maven configuration
7373

@@ -78,7 +78,7 @@ There is a separate Ant task for applying JavaFlow instrumentation at build-time
7878
It's possibe to instrument compiled Java classes as below:
7979
```xml
8080
<target name="instrument-classes" description="JavaFlow Instrumentation" depends="compile">
81-
<taskdef name="javaflow" classname="org.apache.commons.javaflow.ant.AntRewriteTask"
81+
<taskdef name="javaflow" classname="org.apache.commons.javaflow.tools.ant.AntRewriteTask"
8282
classpathref="ant-lib-classpath"/>
8383
<echo message="JavaFlow instrumentation of compiled classes in ${classes.dir}" />
8484
<javaflow srcdir="${classes.dir}" destdir="${i-classes.dir}" classpathref="classpath"/>
@@ -87,7 +87,7 @@ It's possibe to instrument compiled Java classes as below:
8787
... as well as re-write packaged JAR file:
8888
```xml
8989
<target name="instrument-jar" description="JavaFlow Instrumentation" depends="jar">
90-
<taskdef name="javaflow" classname="org.apache.commons.javaflow.ant.AntRewriteTask"
90+
<taskdef name="javaflow" classname="org.apache.commons.javaflow.tools.ant.AntRewriteTask"
9191
classpathref="ant-lib-classpath"/>
9292
<echo message="JavaFlow instrumentation of compiled classes in ${jar.dir}/${ant.project.name}.jar" />
9393
<javaflow srcdir="${jar.dir}" destdir="${i-jar.dir}" classpathref="classpath"/>
@@ -96,7 +96,7 @@ It's possibe to instrument compiled Java classes as below:
9696
You may download a complete [examples project setup](https://github.com/vsilaev/tascalate-javaflow-examples/releases/download/1.0.10/tascalate-javaflow-ant-project-setup1.zip) from [the latest release](https://github.com/vsilaev/tascalate-javaflow-examples/releases/tag/1.0.10) for complete configuration template. Please pay attention to <code>ant-lib</code> folder with Ant TaskDef and <code>lib</code> folders with compile-/runtime-dependencies.
9797

9898
# Java Instrumentation Agent (Runt-time Instrumentation)
99-
As an alternative to compile-time bytecode instrumentation, you MAY use [Tascalate JavaFlow Instrumentation Agent](https://github.com/vsilaev/tascalate-javaflow/releases/download/2.6.4/javaflow.instrument-continuations.jar) from [the latest release](https://github.com/vsilaev/tascalate-javaflow/releases/tag/2.6.4) to enable continuations support at class-loading time. Please note, that if you are using Java 8 and creating continuable lambda functions (either anonymous or/and as method references), and you don't replace them with tools like [RetroLambda](https://github.com/luontola/retrolambda) as mentioned above, then you SHOULD use this instrumentation agent always: as long as Java run-time generates implementation of functional interfaces on the fly there is no other option to instrument them. To enable Tascalate JavaFlow Instrumentation Agent please add the following arguments to Java command line:
99+
As an alternative to compile-time bytecode instrumentation, you MAY use [Tascalate JavaFlow Instrumentation Agent](https://github.com/vsilaev/tascalate-javaflow/releases/download/2.7.0/javaflow.instrument-continuations.jar) from [the latest release](https://github.com/vsilaev/tascalate-javaflow/releases/tag/2.7.0) to enable continuations support at class-loading time. Please note, that if you are using Java 8 and creating continuable lambda functions (either anonymous or/and as method references), and you don't replace them with tools like [RetroLambda](https://github.com/luontola/retrolambda) as mentioned above, then you SHOULD use this instrumentation agent always: as long as Java run-time generates implementation of functional interfaces on the fly there is no other option to instrument them. To enable Tascalate JavaFlow Instrumentation Agent please add the following arguments to Java command line:
100100
```bash
101101
java -javaagent:<path-to-jar>/javaflow.instrument-continuations.jar <rest-of arguments>
102102
```
@@ -105,22 +105,22 @@ The agent JAR file includes all necessary dependencies and requires no additiona
105105
Another useful application of the instrumentation agent is to apply it for debugging code within your IDE of choice. Just specify the "-javaagent" option listed above in your IDE debug/run configuration and you will be able to perform quick "debug-fix" loops without executing full project rebuild.
106106

107107
# Command-line tools
108-
It's possible to use a stand-alone command-line utility [JavaFlowRewriteJar.jar](https://github.com/vsilaev/tascalate-javaflow/releases/download/2.6.4/JavaFlowRewriteJar.jar) to instrument JAR archives containing continuable classes. Please use the following command:
108+
It's possible to use a stand-alone command-line utility [JavaFlowRewriteJar.jar](https://github.com/vsilaev/tascalate-javaflow/releases/download/2.7.0/JavaFlowRewriteJar.jar) to instrument JAR archives containing continuable classes. Please use the following command:
109109

110110
```bash
111111
java -jar JavaFlowRewriteJar.jar src1.jar dst1.jar src2.jar dst2.jar...
112112
```
113113
Note, that the source and the destination should be different files.
114114

115115
# CDI Support
116-
To work correctly in CDI environment continuable methods should be advised only by continuation-aware CDI proxies (interceptors, scope proxies, etc). Obviously, generation of these proxies is out of our control. Plus, major CDI containers (JBoss Weld and Apache OpenWebBeans) generates such proxies dynamically at run-time. Therefore if you plan to use Tascalate JavaFlow continuations with managed beans' methods then it's necessary to instrument CDI-specific proxies with [javaflow.instrument-cdi-proxy.jar](https://github.com/vsilaev/tascalate-javaflow/releases/download/2.6.4/javaflow.instrument-cdi-proxy.jar) Java Agent:
116+
To work correctly in CDI environment continuable methods should be advised only by continuation-aware CDI proxies (interceptors, scope proxies, etc). Obviously, generation of these proxies is out of our control. Plus, major CDI containers (JBoss Weld and Apache OpenWebBeans) generates such proxies dynamically at run-time. Therefore if you plan to use Tascalate JavaFlow continuations with managed beans' methods then it's necessary to instrument CDI-specific proxies with [javaflow.instrument-proxies.jar](https://github.com/vsilaev/tascalate-javaflow/releases/download/2.7.0/javaflow.instrument-proxies.jar) Java Agent:
117117
```bash
118-
java -javaagent:<path-to-jar>/javaflow.instrument-cdi-proxy.jar <rest-of arguments>
118+
java -javaagent:<path-to-jar>/javaflow.instrument-proxies.jar <rest-of arguments>
119119
```
120120
Please note, that CDI-specific agent neither requires javaflow.instrument-continuations.jar to operate correctly nor provides class file transformers for continuable methods. So if your project runs with CDI environment AND uses Java 8 lambdas then you have to add 2 Java agents, every serving different purpose:
121121
```bash
122122
java -javaagent:<path-to-jar>/javaflow.instrument-continuations.jar \
123-
-javaagent:<path-to-jar>/javaflow.instrument-cdi-proxy.jar \
123+
-javaagent:<path-to-jar>/javaflow.instrument-proxies.jar \
124124
<rest-of arguments>
125125
```
126126
CDI functionality is tested with JBoss Weld 2.x - 3.1.7, 4.0.x and Apache OpenWebBeans 1.6.x - 2.0.23. Contribution for other CDI/CDI-like containers (Spring, Google Guice, etc) is welcome.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>net.tascalate.javaflow.agent.common</name>
4+
<comment>Continuations / CoRoutines library for Java 1.5 - 1.8, incl. build tools &amp; CDI support.
5+
This project is based on completely re-worked Apache Jakarta Commons JavaFlow library. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
6+
<projects>
7+
<project>net.tascalate.javaflow.providers.asm5</project>
8+
<project>net.tascalate.javaflow.spi</project>
9+
</projects>
10+
<buildSpec>
11+
<buildCommand>
12+
<name>org.eclipse.jdt.core.javabuilder</name>
13+
<arguments>
14+
</arguments>
15+
</buildCommand>
16+
<buildCommand>
17+
<name>org.eclipse.m2e.core.maven2Builder</name>
18+
<arguments>
19+
</arguments>
20+
</buildCommand>
21+
</buildSpec>
22+
<natures>
23+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
24+
<nature>org.eclipse.jdt.core.javanature</nature>
25+
</natures>
26+
</projectDescription>

net.tascalate.javaflow.tools.instrument/pom.xml renamed to net.tascalate.javaflow.agent.common/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<relativePath>../</relativePath>
99
</parent>
1010

11-
<artifactId>net.tascalate.javaflow.tools.instrument</artifactId>
11+
<artifactId>net.tascalate.javaflow.agent.common</artifactId>
1212
<packaging>jar</packaging>
1313

14-
<name>Tascalate JavaFlow / Tools / Common Instrumentation Agent Code</name>
14+
<name>Tascalate JavaFlow / Agent / Common Instrumentation Agent Code</name>
1515

1616
<properties>
1717
<license.header>../HEADER-ORIGINAL.txt</license.header>

net.tascalate.javaflow.tools.instrument/src/main/java/module-info.java renamed to net.tascalate.javaflow.agent.common/src/main/java/module-info.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
module net.tascalate.javaflow.tools.instrument {
16+
module net.tascalate.javaflow.agent.common {
1717
requires transitive java.instrument;
1818

1919
requires org.slf4j;
2020

2121
requires transitive net.tascalate.javaflow.spi;
2222

23-
exports org.apache.commons.javaflow.instrumentation.common;
23+
exports org.apache.commons.javaflow.agent.common;
2424
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2019 Valery Silaev (http://vsilaev.com)
2+
* Copyright 2013-2021 Valery Silaev (http://vsilaev.com)
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.apache.commons.javaflow.instrumentation.common;
16+
package org.apache.commons.javaflow.agent.common;
1717

1818
import java.lang.instrument.ClassFileTransformer;
1919
import java.lang.instrument.IllegalClassFormatException;

0 commit comments

Comments
 (0)