8364281: Reduce JNI usage in Linux attach provider #26712
+95
−292
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.
Reduce the usage of JNI in the Linux attach provider by making more use of the
Path
API.Path
API to read file permissionsPath
API to write to and read from Unix domain socketsAfter this the sole usage of JNI in the Linux attach provider will be to send a signal using
kill
.I ran the tier1 and serviceability test suites and they both pass. I verified I can attach to and attach using a locally built JDK. I didn't do any Docker related tests.
I split the changes into two commits:
UserPrincipal
,Set
, ...)I hope this makes it easier to review and verify the changes preserve the semantics.
To the best of my knowledge
uid_t
is an unsigned 32 bit integer.VM#geteuid()
returns it aslong
, unsigned. HoweverUnixUserPrincipals#fromUid
expects anint
, I believe casting is the correct way to convert in this case.I tried to keep unrelated changes to
VirtualMachineImpl
to a minimum. I did however replace all usages ofjava.io.File
withjava.nio.file.Path
and made two methodsstatic
. We could get rid of thesocket_path
instance variable if we instead usesocket_address
to flag a disconnect.Ultimately the same changes can be applied to the macOS an AIX implementations.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26712/head:pull/26712
$ git checkout pull/26712
Update a local copy of the PR:
$ git checkout pull/26712
$ git pull https://git.openjdk.org/jdk.git pull/26712/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26712
View PR using the GUI difftool:
$ git pr show -t 26712
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26712.diff
Using Webrev
Link to Webrev Comment