Conversation
…filtering Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds Java FFI platform detection and native runtime extraction/caching.
Changes:
- Detects OS, architecture, and Linux libc classifiers.
- Resolves and atomically caches
runtime.node. - Adds Maven-filtered version metadata and unit-test fixtures.
Show a summary per file
| File | Description |
|---|---|
java/pom.xml |
Enables version resource filtering. |
java/src/main/resources/copilot-runtime.properties |
Supplies artifact version metadata. |
java/src/main/java/com/github/copilot/ffi/PlatformDetector.java |
Implements platform classification. |
java/src/main/java/com/github/copilot/ffi/NativeRuntimeLoader.java |
Implements runtime resolution and caching. |
java/src/main/java/com/github/copilot/ffi/NativeRuntimeLoaderException.java |
Defines loader failures. |
java/src/test/java/com/github/copilot/ffi/PlatformDetectorTest.java |
Tests platform detection. |
java/src/test/java/com/github/copilot/ffi/NativeRuntimeLoaderTest.java |
Tests loader behavior. |
java/src/test/resources/native/linux-x64/runtime.node |
Provides a stub native resource. |
Review details
Comments suppressed due to low confidence (1)
java/src/main/java/com/github/copilot/ffi/PlatformDetector.java:265
- These two individually valid 32-bit values are added as an
int, so a malformedPT_INTERPcan overflowend, bypass the bounds check, and causeArrayIndexOutOfBoundsException. That unchecked exception escapesdetectLinuxLibc()instead of producingUNKNOWN; compute and validate the end offset as alongbefore casting.
int start = (int) pOffset;
int end = start + (int) pFileSize;
if (end > size) {
- Files reviewed: 8/8 changed files
- Comments generated: 7
- Review effort level: Medium
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cross-SDK Consistency Review ✅This PR adds No cross-SDK consistency issues found. Here's why:
The PR is well-scoped to a Java-specific need and does not introduce any cross-language API inconsistencies.
|
|
@copilot review |
Reviewed the current state of the PR. All CI workflows pass on commit Addressed in the previous commit (
No new issues found. Formatting passes ( |
Implements the
PlatformDetectorutility (task 4.2) andNativeRuntimeLoader(task 4.3) in the newcom.github.copilot.ffipackage. Tasks 4.1/4.2 were previously merged as empty commits, so this PR delivers both.PlatformDetector (
ffi/PlatformDetector.java)Pure-Java classifier detection for selecting the correct
runtime.nodebinary:os.name→darwin | linux | win32os.archaliases →x64 | arm64/proc/self/exe, parses ELFPT_INTERPsegment for musl (/ld-musl-) vs. glibc (/ld-linux-)detectClassifier()→ one of 8 validated classifiers (linux-x64,linuxmusl-arm64,darwin-x64,win32-x64, …); unsupported tuples fail fastNativeRuntimeLoader (
ffi/NativeRuntimeLoader.java)Resolves
runtime.nodevia:COPILOT_CLI_PATHenv var (returned as-is)native/<classifier>/runtime.node→ extracted to~/.copilot/runtime-cache/<version>/<classifier>/runtime.nodeExtraction is atomic: write to a UUID-named temp file in the same directory,
Files.move(ATOMIC_MOVE). If another process wins the race, accepts the winner after a regular/non-empty check. No file locks. No execute bit set (JNAdlopendoesn't require it). Abandoned temp files cleaned infinally.Version is read from
copilot-runtime.properties(Maven resource-filtered${project.version}). A missing, blank, or unfiltered placeholder is a hard error.Supporting changes
copilot-runtime.properties—version=${project.version}, filtered at build timepom.xml— Maven<resources>block enables filtering for that one file onlyNativeRuntimeLoaderException— typed checked exception for all failure modesnative/linux-x64/runtime.node(stub binary for unit tests)