Skip to content

Commit 05cfd70

Browse files
docs(java-dedup): drop JaCoCo TCP server requirement
- Update Java dedup install and deduplication pages across versions 2.0.0, 3.0.0, and 4.0.0 to reflect the in-process JaCoCo API as the default coverage transport. - Remove the requirement to launch JaCoCo in tcpserver mode and to pass --pass-through-ports for the JaCoCo port. - Document the TCP server fallback for environments where the runtime API is unavailable, including KEPLOY_JACOCO_HOST and KEPLOY_JACOCO_PORT. Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
1 parent adea6f2 commit 05cfd70

4 files changed

Lines changed: 60 additions & 29 deletions

File tree

versioned_docs/version-2.0.0/server/sdk-installation/java.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,12 @@ import io.keploy.dedup.KeployDedupAgent;
5959
KeployDedupAgent.start();
6060
```
6161

62-
## Run with JaCoCo TCP Server Mode
62+
## Run with the JaCoCo Java Agent
6363

64-
Run the Java application with the JaCoCo runtime agent in `tcpserver` mode. Keploy uses the JaCoCo TCP port to reset and dump per-testcase coverage during replay.
64+
The SDK reads coverage in-process via JaCoCo's runtime API (`org.jacoco.agent.rt.RT.getAgent()`), so attaching the JaCoCo agent is enough — no TCP server flags, no port choice:
6565

6666
```bash
67-
java -javaagent:/path/to/jacocoagent.jar=address=127.0.0.1,port=36320,destfile=target/jacoco-keploy.exec,output=tcpserver \
68-
-jar target/app.jar
67+
java -javaagent:/path/to/jacocoagent.jar -jar target/app.jar
6968
```
7069

7170
If your compiled application classes are not under `target/classes` or `build/classes/java/main`, set `KEPLOY_JAVA_CLASS_DIRS`:
@@ -74,17 +73,26 @@ If your compiled application classes are not under `target/classes` or `build/cl
7473
export KEPLOY_JAVA_CLASS_DIRS=/absolute/path/to/target/classes
7574
```
7675

76+
If the in-process API is unavailable in your environment, the SDK transparently falls back to JaCoCo's TCP server mode. To use the fallback explicitly, launch JaCoCo in `tcpserver` mode and configure `KEPLOY_JACOCO_HOST` / `KEPLOY_JACOCO_PORT` (defaults: `127.0.0.1:36320`):
77+
78+
```bash
79+
java -javaagent:/path/to/jacocoagent.jar=address=127.0.0.1,port=36320,output=tcpserver \
80+
-jar target/app.jar
81+
```
82+
7783
## Replay with Dedup
7884

79-
Run Keploy in test mode with dynamic deduplication enabled and pass through the JaCoCo TCP port:
85+
Run Keploy in test mode with dynamic deduplication enabled:
8086

8187
```bash
8288
keploy test \
83-
-c "java -javaagent:/path/to/jacocoagent.jar=address=127.0.0.1,port=36320,destfile=target/jacoco-keploy.exec,output=tcpserver -jar target/app.jar" \
89+
-c "java -javaagent:/path/to/jacocoagent.jar -jar target/app.jar" \
8490
--dedup \
85-
--pass-through-ports 36320
91+
--language java
8692
```
8793

94+
If you are using the JaCoCo TCP fallback, also pass `--pass-through-ports <jacoco-port>` so Keploy does not try to mock the coverage-control connection.
95+
8896
After replay, run:
8997

9098
```bash

versioned_docs/version-3.0.0/server/sdk-installation/java.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,12 @@ import io.keploy.dedup.KeployDedupAgent;
6363
KeployDedupAgent.start();
6464
```
6565

66-
## Run with JaCoCo TCP Server Mode
66+
## Run with the JaCoCo Java Agent
6767

68-
Run the Java application with the JaCoCo runtime agent in `tcpserver` mode. Keploy uses the JaCoCo TCP port to reset and dump per-testcase coverage during replay.
68+
The SDK reads coverage in-process via JaCoCo's runtime API (`org.jacoco.agent.rt.RT.getAgent()`), so attaching the JaCoCo agent is enough — no TCP server flags, no port choice:
6969

7070
```bash
71-
java -javaagent:/path/to/jacocoagent.jar=address=127.0.0.1,port=36320,destfile=target/jacoco-keploy.exec,output=tcpserver \
72-
-jar target/app.jar
71+
java -javaagent:/path/to/jacocoagent.jar -jar target/app.jar
7372
```
7473

7574
If your compiled application classes are not under `target/classes` or `build/classes/java/main`, set `KEPLOY_JAVA_CLASS_DIRS`:
@@ -78,17 +77,26 @@ If your compiled application classes are not under `target/classes` or `build/cl
7877
export KEPLOY_JAVA_CLASS_DIRS=/absolute/path/to/target/classes
7978
```
8079

80+
If the in-process API is unavailable in your environment, the SDK transparently falls back to JaCoCo's TCP server mode. To use the fallback explicitly, launch JaCoCo in `tcpserver` mode and configure `KEPLOY_JACOCO_HOST` / `KEPLOY_JACOCO_PORT` (defaults: `127.0.0.1:36320`):
81+
82+
```bash
83+
java -javaagent:/path/to/jacocoagent.jar=address=127.0.0.1,port=36320,output=tcpserver \
84+
-jar target/app.jar
85+
```
86+
8187
## Replay with Dedup
8288

83-
Run Keploy in test mode with dynamic deduplication enabled and pass through the JaCoCo TCP port:
89+
Run Keploy in test mode with dynamic deduplication enabled:
8490

8591
```bash
8692
keploy test \
87-
-c "java -javaagent:/path/to/jacocoagent.jar=address=127.0.0.1,port=36320,destfile=target/jacoco-keploy.exec,output=tcpserver -jar target/app.jar" \
93+
-c "java -javaagent:/path/to/jacocoagent.jar -jar target/app.jar" \
8894
--dedup \
89-
--pass-through-ports 36320
95+
--language java
9096
```
9197

98+
If you are using the JaCoCo TCP fallback, also pass `--pass-through-ports <jacoco-port>` so Keploy does not try to mock the coverage-control connection.
99+
92100
After replay, run:
93101

94102
```bash

versioned_docs/version-4.0.0/keploy-cloud/deduplication.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,20 @@ public class App {
6161
}
6262
```
6363

64-
Java dynamic deduplication uses JaCoCo runtime coverage, so start the application with the JaCoCo agent in TCP server mode:
64+
Java dynamic deduplication uses JaCoCo runtime coverage. The SDK reads coverage in-process via JaCoCo's runtime API (`org.jacoco.agent.rt.RT.getAgent()`), so attaching the JaCoCo Java agent is enough — no TCP server flags, no `--pass-through-ports`:
6565

6666
```bash
67-
java -javaagent:/path/to/org.jacoco.agent-runtime.jar=address=127.0.0.1,port=36320,destfile=target/jacoco-keploy.exec,output=tcpserver \
67+
java -javaagent:/path/to/org.jacoco.agent-runtime.jar -jar target/app.jar
68+
```
69+
70+
If the in-process API is unavailable for some reason (for example, an isolated classloader), the SDK transparently falls back to JaCoCo's TCP server mode. To force the fallback, launch JaCoCo in `tcpserver` mode and tell Keploy to leave that port alone:
71+
72+
```bash
73+
java -javaagent:/path/to/org.jacoco.agent-runtime.jar=address=127.0.0.1,port=36320,output=tcpserver \
6874
-jar target/app.jar
6975
```
7076

71-
The default JaCoCo endpoint is `127.0.0.1:36320`. You can override it with `KEPLOY_JACOCO_HOST` and `KEPLOY_JACOCO_PORT`, or with the JVM properties `keploy.jacoco.host` and `keploy.jacoco.port`. Add the JaCoCo port to `--pass-through-ports` when running Keploy so coverage-control traffic is not recorded or mocked.
77+
The default JaCoCo endpoint for the fallback is `127.0.0.1:36320`. You can override it with `KEPLOY_JACOCO_HOST` and `KEPLOY_JACOCO_PORT`, or with the JVM properties `keploy.jacoco.host` and `keploy.jacoco.port`. When using the fallback, add the JaCoCo port to `--pass-through-ports` so coverage-control traffic is not mocked.
7278

7379
**2. Build Configuration**
7480

@@ -96,11 +102,10 @@ COPY target/classes /app/target/classes
96102
COPY jacocoagent.jar /app/jacocoagent.jar
97103
```
98104

99-
Then run the app with JaCoCo enabled:
105+
Then run the app with the JaCoCo agent attached:
100106

101107
```bash
102-
java -javaagent:/app/jacocoagent.jar=address=127.0.0.1,port=36320,destfile=/tmp/jacoco-keploy.exec,output=tcpserver \
103-
-jar /app/app.jar
108+
java -javaagent:/app/jacocoagent.jar -jar /app/app.jar
104109
```
105110

106111
Keploy and the Java SDK exchange per-test coverage signals over `/tmp/coverage_control.sock` and `/tmp/coverage_data.sock`. For Docker and Docker Compose, bind-mount host `/tmp` into the application container so both processes see the same socket paths.
@@ -112,15 +117,17 @@ For hardened Docker runs, the Java dedup sample is validated with a non-root run
112117
For Docker, run:
113118

114119
```bash
115-
keploy test -c "docker compose up" --containerName containerName --dedup --pass-through-ports 36320
120+
keploy test -c "docker compose up" --containerName containerName --dedup --language java
116121
```
117122

118123
For Native, run:
119124

120125
```bash
121-
keploy test -c "java -javaagent:/path/to/org.jacoco.agent-runtime.jar=address=127.0.0.1,port=36320,destfile=target/jacoco-keploy.exec,output=tcpserver -jar target/app.jar" --dedup --pass-through-ports 36320
126+
keploy test -c "java -javaagent:/path/to/org.jacoco.agent-runtime.jar -jar target/app.jar" --dedup --language java
122127
```
123128

129+
If the SDK falls back to the JaCoCo TCP server, also pass `--pass-through-ports <jacoco-port>` so Keploy does not try to mock the coverage-control connection.
130+
124131
This will generate a `dedupData.yaml` file.
125132

126133
After this, run:

versioned_docs/version-4.0.0/server/sdk-installation/java.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,12 @@ import io.keploy.dedup.KeployDedupAgent;
6363
KeployDedupAgent.start();
6464
```
6565

66-
## Run with JaCoCo TCP Server Mode
66+
## Run with the JaCoCo Java Agent
6767

68-
Run the Java application with the JaCoCo runtime agent in `tcpserver` mode. Keploy uses the JaCoCo TCP port to reset and dump per-testcase coverage during replay.
68+
The SDK reads coverage in-process via JaCoCo's runtime API (`org.jacoco.agent.rt.RT.getAgent()`), so attaching the JaCoCo agent is enough — no TCP server flags, no port choice:
6969

7070
```bash
71-
java -javaagent:/path/to/jacocoagent.jar=address=127.0.0.1,port=36320,destfile=target/jacoco-keploy.exec,output=tcpserver \
72-
-jar target/app.jar
71+
java -javaagent:/path/to/jacocoagent.jar -jar target/app.jar
7372
```
7473

7574
If your compiled application classes are not under `target/classes` or `build/classes/java/main`, set `KEPLOY_JAVA_CLASS_DIRS`:
@@ -78,17 +77,26 @@ If your compiled application classes are not under `target/classes` or `build/cl
7877
export KEPLOY_JAVA_CLASS_DIRS=/absolute/path/to/target/classes
7978
```
8079

80+
If the in-process API is unavailable in your environment, the SDK transparently falls back to JaCoCo's TCP server mode. To use the fallback explicitly, launch JaCoCo in `tcpserver` mode and configure `KEPLOY_JACOCO_HOST` / `KEPLOY_JACOCO_PORT` (defaults: `127.0.0.1:36320`):
81+
82+
```bash
83+
java -javaagent:/path/to/jacocoagent.jar=address=127.0.0.1,port=36320,output=tcpserver \
84+
-jar target/app.jar
85+
```
86+
8187
## Replay with Dedup
8288

83-
Run Keploy in test mode with dynamic deduplication enabled and pass through the JaCoCo TCP port:
89+
Run Keploy in test mode with dynamic deduplication enabled:
8490

8591
```bash
8692
keploy test \
87-
-c "java -javaagent:/path/to/jacocoagent.jar=address=127.0.0.1,port=36320,destfile=target/jacoco-keploy.exec,output=tcpserver -jar target/app.jar" \
93+
-c "java -javaagent:/path/to/jacocoagent.jar -jar target/app.jar" \
8894
--dedup \
89-
--pass-through-ports 36320
95+
--language java
9096
```
9197

98+
If you are using the JaCoCo TCP fallback, also pass `--pass-through-ports <jacoco-port>` so Keploy does not try to mock the coverage-control connection.
99+
92100
After replay, run:
93101

94102
```bash

0 commit comments

Comments
 (0)