diff --git a/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java b/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java index 64192a47e5c..d73ff4bb48b 100644 --- a/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java @@ -26,6 +26,7 @@ package sun.tools.attach; import com.sun.tools.attach.AgentLoadException; import com.sun.tools.attach.AttachNotSupportedException; +import com.sun.tools.attach.AttachOperationFailedException; import com.sun.tools.attach.spi.AttachProvider; import java.io.File; @@ -253,7 +254,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { return f; } - private String findTargetProcessTmpDirectory(long pid) throws AttachNotSupportedException, IOException { + private String findTargetProcessTmpDirectory(long pid) throws IOException { final var tmpOnProcPidRoot = PROC.resolve(Long.toString(pid)).resolve(ROOT_TMP); /* We need to handle at least 4 different cases: @@ -279,7 +280,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { } else if (Files.isSameFile(tmpOnProcPidRoot, TMPDIR)) { return TMPDIR.toString(); } else { - throw new AttachNotSupportedException("Unable to access the filesystem of the target process"); + throw new AttachOperationFailedException("Unable to access the filesystem of the target process"); } } catch (IOException ioe) { try { @@ -297,7 +298,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { throw ioe; } catch (MonitorException | URISyntaxException e) { // Other exceptions (happened at MonitoredHost) would be wrapped with AttachNotSupportedException - throw new AttachNotSupportedException("Unable to find target proces", e); + throw new AttachOperationFailedException("Unable to find target proces", e); } } } diff --git a/src/jdk.attach/share/classes/com/sun/tools/attach/AttachOperationFailedException.java b/src/jdk.attach/share/classes/com/sun/tools/attach/AttachOperationFailedException.java index cbc4410907c..3f26c02c304 100644 --- a/src/jdk.attach/share/classes/com/sun/tools/attach/AttachOperationFailedException.java +++ b/src/jdk.attach/share/classes/com/sun/tools/attach/AttachOperationFailedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,4 +50,18 @@ public class AttachOperationFailedException extends IOException { public AttachOperationFailedException(String message) { super(message); } + + /** + * Constructs an AttachOperationFailedException with + * the specified cause. + * + * @param message the detail message. + * @param cause the cause of this exception. + * + * @since 27 + */ + public AttachOperationFailedException(String message, Throwable cause) { + super(message, cause); + } + }