Skip to content

Conversation

@dkhalanskyjb
Copy link
Collaborator

Alternative for #4565

With this change, we ensure that AgentPremain does not touch any of the kotlin.* 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 runCatching antipattern, but one sad consequence is the inability to use the convenient thread { } 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.

With this change, we ensure that `AgentPremain` does not touch
any of the `kotlin.*` 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 non-idiomatic
`runCatching` calls, but one sad consequence is the inability
to use the convenient `thread { }` 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, which was fine, given that
the execution never even got to the main class and crashed during
the debug agent attach, so it had to be significantly changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants