/hg/icedtea-web: Rust launchers now spawn jvm
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Wed Oct 10 12:29:15 UTC 2018
changeset 15ec93640c20 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=15ec93640c20
author: Jiri Vanek <jvanek at redhat.com>
date: Wed Oct 10 14:29:03 2018 +0200
Rust launchers now spawn jvm
* rust-launcher/src/jvm_from_properties_resolver.rs: implemented new trait method (spawn_java_process). Stub only. Will panic
* rust-launcher/src/main.rs: java from found java_dir is launched. Process is awaited, its return returned.
* rust-launcher/src/os_access.rs: trait method of (spawn_java_process) add and implemented for linux.
diffstat:
ChangeLog | 7 +++++++
rust-launcher/src/jvm_from_properties_resolver.rs | 4 ++++
rust-launcher/src/main.rs | 6 ++++++
rust-launcher/src/os_access.rs | 20 ++++++++++++++++++++
4 files changed, 37 insertions(+), 0 deletions(-)
diffs (77 lines):
diff -r 88f126034b7b -r 15ec93640c20 ChangeLog
--- a/ChangeLog Tue Oct 02 18:32:02 2018 +0200
+++ b/ChangeLog Wed Oct 10 14:29:03 2018 +0200
@@ -1,3 +1,10 @@
+2018-10-10 Jiri Vanek <jvanek at redhat.com>
+
+ Rust launchers now spawn jvm
+ * rust-launcher/src/jvm_from_properties_resolver.rs: implemented new trait method (spawn_java_process). Stub only. Will panic
+ * rust-launcher/src/main.rs: java from found java_dir is launched. Process is awaited, its return returned.
+ * rust-launcher/src/os_access.rs: trait method of (spawn_java_process) add and implemented for linux.
+
2018-10-01 Jiri Vanek <jvanek at redhat.com>
* rust-launcher/src/main.rs: new method of (is_debug_on) based on cmd line determining verbosity. (main) return of is_debug_on used for os_access::Linux::new call.
diff -r 88f126034b7b -r 15ec93640c20 rust-launcher/src/jvm_from_properties_resolver.rs
--- a/rust-launcher/src/jvm_from_properties_resolver.rs Tue Oct 02 18:32:02 2018 +0200
+++ b/rust-launcher/src/jvm_from_properties_resolver.rs Wed Oct 10 14:29:03 2018 +0200
@@ -94,6 +94,10 @@
fn get_registry_jdk(&self) -> Option<std::path::PathBuf> {
None
}
+
+ fn spawn_java_process(&self, jre_dir: &std::path::PathBuf, args: &Vec<String>) -> std::process::Child {
+ panic!("not implemented");
+ }
}
#[test]
diff -r 88f126034b7b -r 15ec93640c20 rust-launcher/src/main.rs
--- a/rust-launcher/src/main.rs Tue Oct 02 18:32:02 2018 +0200
+++ b/rust-launcher/src/main.rs Wed Oct 10 14:29:03 2018 +0200
@@ -65,4 +65,10 @@
write!(&mut info2, "{}", "selected jre: ").expect("unwrap failed");
write!(&mut info2, "{}", java_dir.display()).expect("unwrap failed");
os.info(&info2);
+ let mut child = os.spawn_java_process(&java_dir, &(env::args().skip(1).collect()));
+ let ecode = child.wait().expect("failed to wait on child");
+ let code = ecode.code().expect("code should be always here");
+ std::process::exit(code)
}
+
+
diff -r 88f126034b7b -r 15ec93640c20 rust-launcher/src/os_access.rs
--- a/rust-launcher/src/os_access.rs Tue Oct 02 18:32:02 2018 +0200
+++ b/rust-launcher/src/os_access.rs Wed Oct 10 14:29:03 2018 +0200
@@ -5,6 +5,7 @@
fn log(&self, s: &str);
fn info(&self, s: &str);
fn get_registry_jdk(&self) -> Option<std::path::PathBuf>;
+ fn spawn_java_process(&self, jre_dir: &std::path::PathBuf, args: &Vec<String>) -> std::process::Child;
}
pub struct Linux {
@@ -31,4 +32,23 @@
fn get_registry_jdk(&self) -> Option<std::path::PathBuf> {
None
}
+
+ fn spawn_java_process(&self, jre_dir: &std::path::PathBuf, args: &Vec<String>) -> std::process::Child {
+ let mut bin_java = jre_dir.clone();
+ bin_java.push("bin");
+ bin_java.push("java");
+ let mut cmd = std::process::Command::new(&bin_java);
+ for ar in args.into_iter() {
+ cmd.arg(ar);
+ }
+ cmd.stdin(std::process::Stdio::inherit());
+ cmd.stdout(std::process::Stdio::inherit());
+ cmd.stderr(std::process::Stdio::inherit());
+ let res = cmd.spawn();
+ match res {
+ Ok(child) => child,
+ Err(_) => panic!("Error spawning JVM process, \
+ java executable: [{}], arguments: [{:?}]", bin_java.into_os_string().to_str().expect("path should unwrap"), args)
+ }
+ }
}
More information about the distro-pkg-dev
mailing list