Skip to content

[Java] Add PlatformDetector for runtime classifier selection - #2173

Merged
edburns merged 3 commits into
edburns/1917-java-embed-rust-cli-runtime-dd-3039924-agentic-run-02from
copilot/edburns1917-java-embed-rust-cli-runtime-dd-3039924
Jul 30, 2026
Merged

[Java] Add PlatformDetector for runtime classifier selection#2173
edburns merged 3 commits into
edburns/1917-java-embed-rust-cli-runtime-dd-3039924-agentic-run-02from
copilot/edburns1917-java-embed-rust-cli-runtime-dd-3039924

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This PR implements task 4.2 of the Java embedded-runtime plan by adding a pure-Java platform detection utility that resolves os, arch, and Linux libc into the runtime classifier used to locate runtime.node. It also adds focused unit coverage for supported classifier resolution and fail-fast behavior on unsupported tuples.

  • Platform detection utility (com.github.copilot.ffi.PlatformDetector)

    • Added detectOs() mapping os.name to darwin | linux | win32.
    • Added detectArch() mapping os.arch aliases to x64 | arm64.
    • Added detectLinuxLibc() with ELF PT_INTERP parsing from /proc/self/exe (first 2KB):
      • "/ld-musl-"MUSL
      • "/ld-linux-"GLIBC
      • read/parse failure → UNKNOWN
    • Added table-driven detectClassifier() and allow-list enforcement for the 8 ADR-007 classifiers.
  • Classifier policy and fail-fast behavior

    • Non-Linux: <os>-<arch>
    • Linux + musl: linuxmusl-<arch>
    • Linux + glibc/unknown: linux-<arch>
    • Unsupported tuples throw immediately with a descriptive IllegalStateException.
  • Unit coverage (PlatformDetectorTest)

    • Added tests for OS/arch alias mapping (success + unsupported inputs).
    • Added ELF probe fixtures for glibc and musl PT_INTERP paths.
    • Added allow-list coverage for all 8 supported classifiers.
    • Added explicit unsupported-tuple and parse-failure edge-case assertions.
String os = PlatformDetector.detectOs();          // darwin | linux | win32
String arch = PlatformDetector.detectArch();      // x64 | arm64
PlatformDetector.LinuxLibc libc = PlatformDetector.detectLinuxLibc();
String classifier = PlatformDetector.detectClassifier(); // e.g. linux-x64

Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Copilot AI changed the title [WIP] Add PlatformDetector utility class for platform detection [Java] Add PlatformDetector for runtime classifier selection Jul 30, 2026
Copilot AI requested a review from edburns July 30, 2026 19:49
@github-actions

This comment has been minimized.

@edburns
edburns marked this pull request as ready for review July 30, 2026 20:08
@edburns
edburns requested a review from a team as a code owner July 30, 2026 20:08
Copilot AI review requested due to automatic review settings July 30, 2026 20:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

Malformed ELF metadata can bypass the fallback, and one test fails incorrectly on musl hosts.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds Java platform detection for selecting embedded native runtime classifiers.

Changes:

  • Maps OS, architecture, and Linux libc to eight supported classifiers.
  • Parses ELF PT_INTERP and adds focused unit coverage.
File summaries
File Description
PlatformDetector.java Implements platform, libc, and classifier detection.
PlatformDetectorTest.java Tests mappings, ELF parsing, and unsupported platforms.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Medium

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread java/sdk/src/main/java/com/github/copilot/ffi/PlatformDetector.java Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR adds PlatformDetector — a Java-internal utility for resolving the platform classifier used to locate the embedded runtime.node binary (part of the Java embedded-runtime plan, ADR-007).

Scope of change: Two new files, both under java/sdk/:

  • com/github/copilot/ffi/PlatformDetector.java (added)
  • com/github/copilot/ffi/PlatformDetectorTest.java (added)

No cross-SDK consistency issues found. This change is Java-specific infrastructure for embedding the Rust CLI runtime — a capability that does not exist in other language SDKs at the public API level. The other SDKs (Node.js, Python, Go, .NET, Rust) use different mechanisms to locate the CLI binary and do not need equivalent PlatformDetector utilities. No public SDK API surface was added or modified.

Generated by SDK Consistency Review Agent for #2173 · sonnet46 17.2 AIC · ⌖ 5.36 AIC · ⊞ 6.6K ·

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Ready to approve

The implementation matches the documented classifier policy and includes focused coverage for supported and malformed inputs.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@edburns
edburns merged commit 3fd38b6 into edburns/1917-java-embed-rust-cli-runtime-dd-3039924-agentic-run-02 Jul 30, 2026
27 checks passed
@edburns
edburns deleted the copilot/edburns1917-java-embed-rust-cli-runtime-dd-3039924 branch July 30, 2026 21:35
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.

[Java] Embed Rust CLI runtime 4.2: Platform detection utility

3 participants