You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e7196ea
Browse filesBrowse the repository at this point in the historyBrowse files
A grammar-driven translator and a model are each wrong in different
places: j2py never hallucinates structure but tracks no types, so
everything type-dependent comes out broken in predictable ways. The
plugin pairs them -- run the parser, then repair the known gaps.
plugin/ holds the plugin (skill java2python, command /j2p:translate),
and the repository root doubles as a marketplace so it installs with
`claude plugin install j2p@java2python`. scripts/j2py.sh resolves the
translator from $J2PY_HOME, else the checkout it ships in, else a j2py
on PATH, preferring a checkout so local edits are what run. It looks
for uv at ~/.local/bin as well as on PATH, which a non-interactive
shell often lacks.
The skill's substance is the list of what j2py cannot get right
without types, each item verified against real output: string
concatenation, dropped imports and unmapped library types, Java's
truncating %, fields that become shared class attributes, and
collapsed overloads.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FfdD42ztfjZth9nXpRduKE
"description": "The java2python Claude Code plugin: translate Java source to Python with the j2py compiler.",
5
+
"owner": {
6
+
"name": "jbrette",
7
+
"url": "https://github.com/jbrette/java2python"
8
+
},
9
+
"plugins": [
10
+
{
11
+
"name": "j2p",
12
+
"description": "Translate Java source to Python with the java2python (j2py) compiler, then repair what a grammar-driven translator cannot get right on its own. The parser handles structure, control flow and operators; the model fixes what needs type knowledge, such as string concatenation, the Java standard library and integer remainder.",
Copy file name to clipboardExpand all lines: CLAUDE.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,4 +53,18 @@ Configuration (`config/__init__.py`): `Config` wraps an ordered list of config m
53
53
54
54
Runtime helpers: when the visitor sees certain constructs it sets a flag on the module (`needsBsrFunc` for `>>>`, `needsJavaDivFunc` for `/` and `/=`, `needsSyncHelpers`, `needsAbstractHelpers`), and a module prologue handler in `mod/basic.py` inlines the source of the matching function from `mod/include/` into the output. Java `/` becomes `jdiv(a, b)`, which truncates toward zero for ints, because types aren't tracked. Interfaces become `ABC` subclasses with `@abstractmethod`.
55
55
56
-
Output post-processing: `moduleOutputHandlers` includes `basic.outputSubs`, which applies the regex pairs in `<typeName>OutputSubs` (e.g. `moduleOutputSubs` in `config/default.py`, which maps `System.out.println` to `print`) to the generated text.
56
+
## Claude Code plugin
57
+
58
+
`plugin/` is a Claude Code plugin named `j2p` (manifest in
59
+
`plugin/.claude-plugin/plugin.json`; the repository root is also a marketplace
60
+
via `.claude-plugin/marketplace.json`). It ships the `java2python` skill and
61
+
the `/j2p:translate` command, both of which shell out to
62
+
`plugin/scripts/j2py.sh`. That script resolves the translator from
63
+
`$J2PY_HOME`, else this checkout (preferring `uv run`, falling back to
64
+
`python3 bin/j2py`), else a `j2py` on `PATH`. `claude plugin validate .`
65
+
checks both manifests. The skill's value is the list of things j2py cannot
66
+
get right without types -- keep it in sync with the real behavior.
67
+
68
+
## Output post-processing
69
+
70
+
`moduleOutputHandlers` includes `basic.outputSubs`, which applies the regex pairs in `<typeName>OutputSubs` (e.g. `moduleOutputSubs` in `config/default.py`, which maps `System.out.println` to `print`) to the generated text.
"description": "Translate Java source to Python with the java2python (j2py) compiler, then repair what a grammar-driven translator cannot get right on its own. The parser handles structure, control flow and operators; the model fixes what needs type knowledge, such as string concatenation, the Java standard library and integer remainder.",
Translate Java to Python from inside Claude Code, using the
4
+
[java2python](https://github.com/jbrette/java2python) compiler for the
5
+
structure and the model for the parts that need type knowledge.
6
+
7
+
## What is in it
8
+
9
+
| Component | Name | Purpose |
10
+
| --- | --- | --- |
11
+
| Skill |`java2python`| Loads when a task involves translating Java to Python. Explains how to run j2py and, more importantly, what to check in its output. |
12
+
| Command |`/j2p:translate <file>`| Translate a named file, directory or snippet now. |
13
+
| Script |`scripts/j2py.sh`| Runs the translator, finding it wherever it lives. |
0 commit comments