Open sebthom opened 1 year ago
As a workaround I am now doing:
@:native("java.lang.Process")
extern class Java9Process {
public function pid(): haxe.Int64;
}
@:access(sys.io.Process.proc)
public function getPid(sys.io.Process p) {
var pid:Int = -1;
#if java
try { pid = process.getPid(); } catch (ex:Dynamic) { } // works on Java 8 (except Windows)
if (pid == -1) try { // works on Java 9+ incl. Windows
var p:Java9Process = cast process.proc;
pid = cast(p.pid(), Int);
} catch (ex:Dynamic) { }
#else
pid = p.getPid();
#end
return pid;
}
sys.io.Process.getPid()
relies on reflecting on an internalpid
field which is only available for Java on Linux. As of Java 9 thejava.lang.Process
class was extended by along pid()
method returning the pid of a process. It would be great ifsys.io.Process.getPid()
would delegate to thejava.lang.Process.pid()
for the jvm/java targets and only fallback to reflecting on the internalpid
file in case Java 8 is used.Executing
sys.io.Process.getPid()
on Java 11 or newer results in:Changing
sys.io.Process.getPid()
to:java
target, but emits the following warnings on Java 11:jvm
target:I also tried playing around with
untyped __java__
but could not get anyting working, also it does not seem to support the jvm target.Any help is greatly appreciated.