author | jcbeyler |
Wed, 14 Nov 2018 12:25:15 -0800 | |
changeset 52561 | 40098289d580 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
12047
diff
changeset
|
2 |
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
12047 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
package sun.tools.attach; |
|
26 |
||
27 |
import com.sun.tools.attach.VirtualMachine; |
|
28 |
import com.sun.tools.attach.VirtualMachineDescriptor; |
|
29 |
import com.sun.tools.attach.AttachNotSupportedException; |
|
30 |
import java.io.IOException; |
|
31 |
||
32 |
/* |
|
33 |
* An AttachProvider implementation for Bsd that uses a UNIX domain |
|
34 |
* socket. |
|
35 |
*/ |
|
26216
5e46c782b43c
8055230: Rename attach provider implementation class be platform neutral
mchung
parents:
25859
diff
changeset
|
36 |
public class AttachProviderImpl extends HotSpotAttachProvider { |
12047 | 37 |
|
26216
5e46c782b43c
8055230: Rename attach provider implementation class be platform neutral
mchung
parents:
25859
diff
changeset
|
38 |
public AttachProviderImpl() { |
12047 | 39 |
} |
40 |
||
41 |
public String name() { |
|
42 |
return "sun"; |
|
43 |
} |
|
44 |
||
45 |
public String type() { |
|
46 |
return "socket"; |
|
47 |
} |
|
48 |
||
49 |
public VirtualMachine attachVirtualMachine(String vmid) |
|
50 |
throws AttachNotSupportedException, IOException |
|
51 |
{ |
|
52 |
checkAttachPermission(); |
|
53 |
||
54 |
// AttachNotSupportedException will be thrown if the target VM can be determined |
|
55 |
// to be not attachable. |
|
56 |
testAttachable(vmid); |
|
57 |
||
26216
5e46c782b43c
8055230: Rename attach provider implementation class be platform neutral
mchung
parents:
25859
diff
changeset
|
58 |
return new VirtualMachineImpl(this, vmid); |
12047 | 59 |
} |
60 |
||
61 |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) |
|
62 |
throws AttachNotSupportedException, IOException |
|
63 |
{ |
|
64 |
if (vmd.provider() != this) { |
|
65 |
throw new AttachNotSupportedException("provider mismatch"); |
|
66 |
} |
|
67 |
// To avoid re-checking if the VM if attachable, we check if the descriptor |
|
68 |
// is for a hotspot VM - these descriptors are created by the listVirtualMachines |
|
69 |
// implementation which only returns a list of attachable VMs. |
|
70 |
if (vmd instanceof HotSpotVirtualMachineDescriptor) { |
|
71 |
assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); |
|
72 |
checkAttachPermission(); |
|
26216
5e46c782b43c
8055230: Rename attach provider implementation class be platform neutral
mchung
parents:
25859
diff
changeset
|
73 |
return new VirtualMachineImpl(this, vmd.id()); |
12047 | 74 |
} else { |
75 |
return attachVirtualMachine(vmd.id()); |
|
76 |
} |
|
77 |
} |
|
78 |
||
79 |
} |