342cb6c500
Pair PATH tools from a compatible JDK and always forward its home to external preparers so Java 25 exporters run with a compatible runtime. Co-Authored-By: OpenCode gpt-6.1-sol <noreply@openai.com>
22 lines
779 B
Rust
22 lines
779 B
Rust
//! A fake Java tool for process-level JDK selection tests; no installed Java is needed.
|
|
use std::{env, fs, process};
|
|
|
|
fn main() {
|
|
let executable = env::current_exe().unwrap();
|
|
let bin = executable.parent().unwrap();
|
|
let tool = executable.file_stem().unwrap().to_str().unwrap();
|
|
let version = fs::read_to_string(bin.join(format!("{tool}.version"))).unwrap();
|
|
if env::args().nth(1).as_deref() == Some("-version") {
|
|
if tool == "javac" {
|
|
println!("javac {version}");
|
|
} else {
|
|
eprintln!("openjdk version \"{version}\"");
|
|
}
|
|
} else {
|
|
println!("{tool} {version}");
|
|
}
|
|
if let Ok(status) = fs::read_to_string(bin.join(format!("{tool}.exit"))) {
|
|
process::exit(status.parse().unwrap());
|
|
}
|
|
}
|