RFR: 8376052: Use AttachOperationFailedException rather than AttachNotSupportedException in findTargetProcessTmpDirectory() [v2]

Yasumasa Suenaga ysuenaga at openjdk.org
Sun Jan 25 11:02:34 UTC 2026


On Sun, 25 Jan 2026 08:24:39 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>>> Can you please provide an example where IOException is thrown? 
>> 
>> I could not produce IOException, but it might occur if filesystem is broken.
>> AccessDeniedException would happen as following. We can see it easy on attach to rootless container.
>> 
>> # ./jcmd 1 VM.version
>> 1:
>> java.nio.file.AccessDeniedException: /proc/1/root/tmp
>>         at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
>>         at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:108)
>>         at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:113)
>>         at java.base/sun.nio.fs.UnixFileSystemProvider.isSameFile(UnixFileSystemProvider.java:391)
>>         at java.base/java.nio.file.Files.isSameFile(Files.java:1418)
>>         at jdk.attach/sun.tools.attach.VirtualMachineImpl.findTargetProcessTmpDirectory(VirtualMachineImpl.java:280)
>>         at jdk.attach/sun.tools.attach.VirtualMachineImpl.findSocketFile(VirtualMachineImpl.java:236)
>>         at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:87)
>>         at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:56)
>>         at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:201)
>>         at jdk.jcmd/sun.tools.jcmd.JCmd.executeCommandForPid(JCmd.java:113)
>>         at jdk.jcmd/sun.tools.jcmd.JCmd.main(JCmd.java:97)
>> 
>> 
>>> It would be useful to get an example or two of when MonitorException is thrown. 
>> 
>> As I said before, I cannot find out the location to throw MonitorException in JDK source around attach mechanism, but it might happen if the user uses custom attach provider. Anyway it is checked exception, so it shouldn't ignore or raise assertion error.
>
> Okay, I think we can go with wrapping these exceptions with AttachOperationFailedException.
> 
> Are you planning to re-flow/cleanup findTargetProcessTmpDirectory as part of this PR?

@AlanBateman 
I updated this PR:
- Throw `AssertionError` if `URISyntaxException` happens.
- Updated comment lines (at most 80 chars)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29355#discussion_r2725375537


More information about the serviceability-dev mailing list