Skip to content

Java FFI: Fix build collision when many builds/rules compile the same Java class - #2861

Open
xymus wants to merge 2 commits into
nitlang:masterfrom
xymus:fix-java-concurrent
Open

Java FFI: Fix build collision when many builds/rules compile the same Java class#2861
xymus wants to merge 2 commits into
nitlang:masterfrom
xymus:fix-java-concurrent

Conversation

@xymus

@xymus xymus commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

When building Java FFI clients with any concurrency, even with only make -j n, different rules could target compiling the same java file to class file in parallel. It causes failures when one tries to read a class while it's being written and still only a partial file.

For collisions between two builds sharing a build folder, we now compile the java file to a class file in a temporary directory per main target. This folder sits under the compile dir and gets cleared with it. Once the class file is compiled, we move it over to the normal build folder. The atomic move avoids clients reading partially generated files.

For collisions inside the same build, we pass -implicit:none so only the target of the command is being built, and none of its dependencies. This still allows us to build the java files in parallel but avoids the repeated writes.

xymus added 2 commits August 14, 2026 11:12
Returning lines allows the caller and printer to insert the tabs
automatically at the beginning of each line.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
…ava class

When building Java FFI clients with any concurrency, even with only
`make -j n`, different rules could target the same java file to class file in
parallel. It causes failures when one tries to read a class while it's
being written and still only a partial file.

For collisions between two builds sharing a build folder, we now compile
the java file to a class file in a temporary directory per main target.
This folder sits under the compile dir and gets cleared with it.
Once the class file is compiled, we move it over to the normal build folder.
The atomic move avoids clients reading partially generated files.

For collisions inside the same build, we pass `-implicit:none ` so only
the target of the command is being built, and none of its dependencies.
This still allows us to build the java files in parallel but avoids the
repeated writes.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

Test Results

    67 files     337 suites   16m 11s ⏱️
14 236 tests 13 689 ✅ 547 💤 0 ❌
14 622 runs  14 060 ✅ 562 💤 0 ❌

Results for commit 233cd6c.

♻️ This comment has been updated with latest results.

@xymus
xymus requested a review from privat August 17, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant