Ensure the coroutines debug agent attaches even with no stdlib #4588
+42
−54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alternative for #4565
With this change, we ensure that
AgentPremaindoes not touch any of thekotlin.*APIs when it's being attached to a process. This means that even if it's attached by a mistake to a pure Java process, it won't cause any harm.Most of the changes are limited to removing the
runCatchingantipattern, but one sad consequence is the inability to use the convenientthread { }function.An integration test was implemented, checking that a pure Java process completes successfully even with the debug agent attached to it.
The earlier version of the test performed the check even before the Java class got compiled. It was fine, given that the execution never even got to the main class and crashed during the debug agent attach. With the proposed change, however, it had to be significantly modified.