Skip to content

Commit 2e6f0db

Browse files
Merge pull request #1963 from codeflash-ai/docs/java-docs-update
update init docs for java
2 parents 56d8579 + 3bbdb26 commit 2e6f0db

1 file changed

Lines changed: 13 additions & 43 deletions

File tree

docs/getting-started/java-installation.mdx

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ keywords:
1515
]
1616
---
1717

18-
Codeflash supports Java projects using Maven or Gradle build systems. It uses a two-stage tracing approach to capture method arguments and profiling data from running Java programs, then optimizes the hottest functions.
18+
Codeflash supports optimizing Java projects using Maven or Gradle build systems. It works in two main ways:
19+
1. Codeflash can optimize new java code written in a Pull Request through Github Actions.
20+
2. Codeflash can optimize real workloads end to end. It uses a two-stage tracing approach to capture method arguments and profiling data from running Java program, then optimizes the hottest functions with that data.
1921

2022
### Prerequisites
2123

@@ -32,16 +34,16 @@ Good to have (optional):
3234
<Steps>
3335
<Step title="Install Codeflash CLI">
3436

35-
Codeflash CLI is a Python tool. Install it with pip:
37+
Codeflash uses Python to run its CLI. You can use uv as a package manager and installer for Python programs.
38+
To install uv, run the following or [see these instructions](https://docs.astral.sh/uv/getting-started/installation/)
3639

37-
```bash
38-
pip install codeflash
39-
```
40-
41-
Or with uv:
40+
```bash
41+
curl -LsSf https://astral.sh/uv/install.sh | sh
42+
```
43+
Then install Codeflash as a uv tool.
4244

4345
```bash
44-
uv pip install codeflash
46+
uv tool install codeflash
4547
```
4648

4749
</Step>
@@ -56,30 +58,12 @@ codeflash init
5658
This will:
5759
- Detect your build tool (Maven/Gradle)
5860
- Find your source and test directories
59-
- Create a `codeflash.toml` configuration file
60-
61-
</Step>
62-
<Step title="Verify setup">
63-
64-
Check that the configuration looks correct:
65-
66-
```bash
67-
cat codeflash.toml
68-
```
69-
70-
You should see something like:
71-
72-
```toml
73-
[tool.codeflash]
74-
module-root = "src/main/java"
75-
tests-root = "src/test/java"
76-
language = "java"
77-
```
61+
- Update your pom.xml or gradle settings with codeflash java library. The java library instruments your code and verifies correctness.
7862

7963
</Step>
8064
<Step title="Run your first optimization">
8165

82-
Trace and optimize a running Java program:
66+
Trace and optimize a Java program:
8367

8468
```bash
8569
codeflash optimize java -jar target/my-app.jar
@@ -94,27 +78,13 @@ codeflash optimize mvn exec:java -Dexec.mainClass="com.example.Main"
9478
Codeflash will:
9579
1. Profile your program using JFR (Java Flight Recorder)
9680
2. Capture method arguments using a bytecode instrumentation agent
97-
3. Generate JUnit replay tests from the captured data
81+
3. Generate JUnit replay tests from the captured data to create a micro-benchmark.
9882
4. Rank functions by performance impact
9983
5. Optimize the most impactful functions
10084

10185
</Step>
10286
</Steps>
10387

104-
## How it works
105-
106-
Codeflash uses a **two-stage tracing** approach for Java:
107-
108-
1. **Stage 1 — JFR Profiling**: Runs your program with Java Flight Recorder enabled to collect accurate method-level CPU profiling data. JFR has ~1% overhead and doesn't affect JIT compilation.
109-
110-
2. **Stage 2 — Argument Capture**: Runs your program again with a bytecode instrumentation agent that captures method arguments using Kryo serialization. Arguments are stored in an SQLite database.
111-
112-
The traced data is used to generate **JUnit replay tests** that exercise your functions with real-world inputs. Codeflash uses these tests alongside any existing unit tests to verify correctness and benchmark optimization candidates.
113-
114-
<Info>
115-
Your program runs **twice** — once for profiling, once for argument capture. This separation ensures profiling data isn't distorted by serialization overhead.
116-
</Info>
117-
11888
## Supported build tools
11989

12090
| Build Tool | Detection | Test Execution |

0 commit comments

Comments
 (0)