# jdx body

IDE equivalent: Open the method

Show the body of a member: the verbatim source slice with 1-based line numbers plus provenance (artifact, file, lines). Takes a member reference (e.g. 'com.example.Point#getX()', "Gson#toJson(Object)"). An under-specified name with several overloads exits 2 with candidates. Without paired sources the query names the decompiler tasks instead of guessing. Exits 1 when the member or its sources are unknown, 2 when ambiguous, 4 when the workspace cannot be resolved.

## Usage

```text
jdx body [<options>] <ref>
```

## Example

```console
$ jdx body 'com.google.gson.Gson#toJson(Object)' --coord com.google.code.gson:gson:2.14.0
com.google.gson.Gson#toJson(java.lang.Object)
  source: gson-2.14.0-sources.jar · com/google/gson/Gson.java:542-547
  public String toJson(Object src) {
    if (src == null) {
      return toJson(JsonNull.INSTANCE);
    }
    return toJson(src, src.getClass());
  }
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
next: jdx show com.google.gson.Gson
```

## Options

| Option | Description |
|---|---|
| `--context=<int>` | Surrounding source lines shown each side of the member (default 0). |
| `--line-numbers` | Prefix each shown line with its 1-based number. |
| `--max-lines=<int>` | Maximum body lines shown (default 200); the rest become a truncation footer. |
| `--engine=(vineflower\|javap)` | Disassembly engine: vineflower forces reconstruction even when sources are paired (default serves sources, falling back to vineflower); javap shows the raw bytecode instead. |
| `--with-doc` | Include the member's javadoc beside the body. |
| `--with-signature` | Prepend the resolved bytecode signature header to the body. |
| `--jars=<text>` | Binary roots: jar files, class directories or globs (repeatable). Merge in front of the selected workspace's roots. |
| `-w, --workspace=<text>` | Use a named workspace (see jdx ws). Explicit --jars merge in front of it. |
| `--no-jdk` | Do not include the running JDK's stdlib (included by default). |
| `--coord=<text>` | Maven coordinate root group:artifact:version (repeatable). Resolved from ~/.gradle/caches and ~/.m2 first; with --fetch, downloaded from Maven repositories into <cache-dir>/m2 with checksum verification. Merges in front of the workspace. |
| `--repo=<text>` | Maven repository base URL for --coord fetches (repeatable, e.g. --repo https://repo.example.com/maven2). Tried in flag order before Maven Central, which stays last as the fallback. Must be an http(s) URL. |
| `--fetch` | Allow downloading --coord artifacts (and their -sources.jar) from Maven repositories (Central by default, --repo to add mirrors). Without it, coordinates resolve from the local caches only. |
| `--json` | Emit machine-readable JSON instead of human-readable text (same information, D-007). |
| `--no-color` | Disable ANSI colors even on a TTY (piped output is always plain). |
| `--no-daemon` | Force in-process execution: do not forward this query to the background daemon even when its socket answers (PROPOSAL.md §14.1). |
| `-h, --help` | Show this message and exit |

## Arguments

| Argument | Description |
|---|---|
| `<ref>` | Member reference to show the body of (full or short form). |

## Full help text

```console
$ jdx body --help
Usage: jdx body [<options>] <ref>

  Show the body of a member: the verbatim source slice with 1-based line numbers plus provenance (artifact, file, lines). Takes a member reference (e.g. 'com.example.Point#getX()', "Gson#toJson(Object)"). An under-specified name with several overloads exits 2 with candidates. Without paired sources the query names the decompiler tasks instead of guessing. Exits 1 when the member or its sources are unknown, 2 when ambiguous, 4 when the workspace cannot be resolved.

Options:
  --context=<int>              Surrounding source lines shown each side of the member (default 0).
  --line-numbers               Prefix each shown line with its 1-based number.
  --max-lines=<int>            Maximum body lines shown (default 200); the rest become a truncation footer.
  --engine=(vineflower|javap)  Disassembly engine: vineflower forces reconstruction even when sources are paired (default serves sources, falling back to vineflower); javap shows the raw bytecode instead.
  --with-doc                   Include the member's javadoc beside the body.
  --with-signature             Prepend the resolved bytecode signature header to the body.
  --jars=<text>                Binary roots: jar files, class directories or globs (repeatable). Merge in front of the selected workspace's roots.
  -w, --workspace=<text>       Use a named workspace (see jdx ws). Explicit --jars merge in front of it.
  --no-jdk                     Do not include the running JDK's stdlib (included by default).
  --coord=<text>               Maven coordinate root group:artifact:version (repeatable). Resolved from ~/.gradle/caches and ~/.m2 first; with --fetch, downloaded from Maven repositories into <cache-dir>/m2 with checksum verification. Merges in front of the workspace.
  --repo=<text>                Maven repository base URL for --coord fetches (repeatable, e.g. --repo https://repo.example.com/maven2). Tried in flag order before Maven Central, which stays last as the fallback. Must be an http(s) URL.
  --fetch                      Allow downloading --coord artifacts (and their -sources.jar) from Maven repositories (Central by default, --repo to add mirrors). Without it, coordinates resolve from the local caches only.
  --json                       Emit machine-readable JSON instead of human-readable text (same information, D-007).
  --no-color                   Disable ANSI colors even on a TTY (piped output is always plain).
  --no-daemon                  Force in-process execution: do not forward this query to the background daemon even when its socket answers (PROPOSAL.md §14.1).
  -h, --help                   Show this message and exit

Arguments:
  <ref>  Member reference to show the body of (full or short form).
```

## Learn more

Guide: [Reading code](https://mohammadmd1383.github.io/jdx/docs/reading-code/) · [All commands](https://mohammadmd1383.github.io/jdx/docs/reference/)
