-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
System.exit does proper context hard exit. (#10363)
The `System.exit 42` component is treated the same way as any other Panic error - it does not interfere with other component evaluation: ![image](https://github.com/user-attachments/assets/516490b5-755f-453e-8dc9-744437dc51bd) After removing the `System.exit 42` component, the workflow works as expected. I have also tried opening the project with the component and then removing it.
- Loading branch information
Showing
7 changed files
with
166 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
engine/runtime/src/main/java/org/enso/interpreter/runtime/system/ExitException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.enso.interpreter.runtime.system; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; | ||
import com.oracle.truffle.api.TruffleStackTraceElement; | ||
import com.oracle.truffle.api.exception.AbstractTruffleException; | ||
import com.oracle.truffle.api.interop.ExceptionType; | ||
import com.oracle.truffle.api.interop.InteropLibrary; | ||
import com.oracle.truffle.api.library.ExportLibrary; | ||
import com.oracle.truffle.api.library.ExportMessage; | ||
import com.oracle.truffle.api.nodes.Node; | ||
import org.enso.interpreter.runtime.data.vector.ArrayLikeHelpers; | ||
|
||
/** Thrown when {@code System.exit} call was called during execution. */ | ||
@ExportLibrary(InteropLibrary.class) | ||
final class ExitException extends AbstractTruffleException { | ||
private final int exitCode; | ||
|
||
ExitException(int code, Node location) { | ||
super(location); | ||
this.exitCode = code; | ||
} | ||
|
||
@ExportMessage | ||
boolean isException() { | ||
return true; | ||
} | ||
|
||
@ExportMessage | ||
int getExceptionExitStatus() { | ||
return exitCode; | ||
} | ||
|
||
@ExportMessage | ||
ExceptionType getExceptionType() { | ||
return ExceptionType.EXIT; | ||
} | ||
|
||
@ExportMessage | ||
boolean hasExceptionMessage() { | ||
return true; | ||
} | ||
|
||
@ExportMessage | ||
String getExceptionMessage() { | ||
return getMessage(); | ||
} | ||
|
||
@TruffleBoundary | ||
@Override | ||
public String getMessage() { | ||
return "Exit was called with exit code " + exitCode + "."; | ||
} | ||
|
||
@ExportMessage | ||
RuntimeException throwException() { | ||
return this; | ||
} | ||
|
||
@ExportMessage | ||
boolean hasExceptionStackTrace() { | ||
return true; | ||
} | ||
|
||
@ExportMessage | ||
Object getExceptionStackTrace() { | ||
var node = this.getLocation(); | ||
var frame = TruffleStackTraceElement.create(node, node.getRootNode().getCallTarget(), null); | ||
return ArrayLikeHelpers.asVectorWithCheckAt(frame.getGuestObject()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters