38
38
import org .enso .editions .DefaultEdition ;
39
39
import org .enso .libraryupload .LibraryUploader .UploadFailedError ;
40
40
import org .enso .os .environment .chdir .WorkingDirectory ;
41
+ import org .enso .os .environment .jni .JVM ;
41
42
import org .enso .pkg .Contact ;
42
43
import org .enso .pkg .PackageManager ;
43
44
import org .enso .pkg .PackageManager$ ;
@@ -1404,10 +1405,9 @@ private boolean isJvmModeEnabled(CommandLine line) {
1404
1405
}
1405
1406
1406
1407
private void launchJvm (
1407
- CommandLine line , Map <String , String > props , File component , String javaPath )
1408
+ CommandLine line , Map <String , String > props , File component , String javaHome )
1408
1409
throws IOException , InterruptedException {
1409
1410
var commandAndArgs = new ArrayList <String >();
1410
- commandAndArgs .add (javaPath );
1411
1411
var jvmOptions = System .getenv ("JAVA_OPTS" );
1412
1412
if (jvmOptions != null ) {
1413
1413
for (var op : jvmOptions .split (" " )) {
@@ -1435,6 +1435,9 @@ private void launchJvm(
1435
1435
commandAndArgs .add (component .getPath ());
1436
1436
commandAndArgs .add ("-m" );
1437
1437
commandAndArgs .add ("org.enso.runner/org.enso.runner.Main" );
1438
+
1439
+ var jvm = JVM .create (javaHome , commandAndArgs .toArray (new String [0 ]));
1440
+ commandAndArgs .clear ();
1438
1441
var it = line .iterator ();
1439
1442
while (it .hasNext ()) {
1440
1443
var op = it .next ();
@@ -1456,16 +1459,11 @@ private void launchJvm(
1456
1459
}
1457
1460
}
1458
1461
commandAndArgs .addAll (line .getArgList ());
1459
- var pb = new ProcessBuilder ();
1460
- pb .inheritIO ();
1461
- pb .command (commandAndArgs );
1462
- var p = pb .start ();
1463
- var exitCode = p .waitFor ();
1464
- if (exitCode == 0 ) {
1465
- throw exitSuccess ();
1466
- } else {
1467
- throw doExit (exitCode );
1468
- }
1462
+
1463
+ jvm .executeMain ("org/enso/runner/Main" , commandAndArgs .toArray (new String [0 ]));
1464
+
1465
+ // the above call should never return
1466
+ throw doExit (1 );
1469
1467
}
1470
1468
1471
1469
private void launch (String [] args ) throws IOException , InterruptedException , URISyntaxException {
0 commit comments