mirror of
https://github.com/corda/corda.git
synced 2025-06-15 13:48:14 +00:00
sketch of Runtime.exec() and Calendar; misc bugfixes
This commit is contained in:
@ -1,5 +1,11 @@
|
||||
package java.lang;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileDescriptor;
|
||||
|
||||
public class Runtime {
|
||||
private static final Runtime instance = new Runtime();
|
||||
|
||||
@ -25,6 +31,26 @@ public class Runtime {
|
||||
}
|
||||
}
|
||||
|
||||
public Process exec(String command) {
|
||||
int[] process = new int[4];
|
||||
exec(command, process);
|
||||
return new MyProcess(process[0], process[1], process[2], process[3]);
|
||||
}
|
||||
|
||||
public Process exec(String[] command) {
|
||||
int[] process = new int[4];
|
||||
exec(command, process);
|
||||
return new MyProcess(process[0], process[1], process[2], process[3]);
|
||||
}
|
||||
|
||||
private static native void exec(String command, int[] process);
|
||||
|
||||
private static native void exec(String[] command, int[] process);
|
||||
|
||||
private static native int exitValue(int pid);
|
||||
|
||||
private static native int waitFor(int pid);
|
||||
|
||||
private static native void load(String name, boolean mapName);
|
||||
|
||||
public native void gc();
|
||||
@ -32,4 +58,50 @@ public class Runtime {
|
||||
public native void exit(int code);
|
||||
|
||||
public native long freeMemory();
|
||||
|
||||
private static class MyProcess extends Process {
|
||||
private int pid;
|
||||
private final int in;
|
||||
private final int out;
|
||||
private final int err;
|
||||
private int exitCode;
|
||||
|
||||
public MyProcess(int pid, int in, int out, int err) {
|
||||
this.pid = pid;
|
||||
this.in = in;
|
||||
this.out = out;
|
||||
this.err = err;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
public int exitValue() {
|
||||
if (pid != 0) {
|
||||
exitCode = Runtime.exitValue(pid);
|
||||
}
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
public InputStream getInputStream() {
|
||||
return new FileInputStream(new FileDescriptor(in));
|
||||
}
|
||||
|
||||
public OutputStream getOutputStream() {
|
||||
return new FileOutputStream(new FileDescriptor(out));
|
||||
}
|
||||
|
||||
public InputStream getErrorStream() {
|
||||
return new FileInputStream(new FileDescriptor(err));
|
||||
}
|
||||
|
||||
public int waitFor() throws InterruptedException {
|
||||
if (pid != 0) {
|
||||
exitCode = Runtime.waitFor(pid);
|
||||
pid = 0;
|
||||
}
|
||||
return exitCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user