< prev index next >

application/org.openjdk.jmc.browser.attach/src/main/java/org/openjdk/jmc/browser/attach/LocalJVMToolkit.java

Print this page




 249                                                         }
 250                                                         if (inMemURL != null) {
 251                                                                 connectable = MGMNT_AGENT_STARTED;
 252                                                         }
 253 
 254                                                         // This used to leak one \BaseNamedObjects\hsperfdata_* Section handle on Windows
 255                                                         address = AttachToolkit.importFromPid(pid);
 256                                                 } finally {
 257                                                         // Although the current implementation of LocalMonitoredVm for Windows doesn't do much here, we should always call detach.
 258                                                         mvm.detach();
 259                                                 }
 260                                         } catch (Exception x) {
 261                                                 // ignore
 262                                         }
 263                                         connDesc = createDescriptor(name, jvmArgs, vmid, connectable, type, jvmArch, address, version, isDebug);
 264                                         return connDesc;
 265                                 }
 266                         });
 267                         return future.get(TIMEOUT_THRESHOLD, TimeUnit.SECONDS);
 268                 } catch (Exception e) {
 269                         BrowserAttachPlugin.getPluginLogger().log(Level.WARNING, "Failed to create descriptor for jvm with PID " + vmid, e);
 270                         return null;
 271                 }
 272         }
 273 
 274         /*
 275          * Try to attach to get info from the AttachNotSupportedException.
 276          */
 277         private static JVMArch getArch(Integer vmid) throws IOException {
 278                 JVMArch jvmArch = JVMArch.OTHER;
 279                 List<VirtualMachineDescriptor> vms = VirtualMachine.list();
 280                 if (vms != null) {
 281                         for (VirtualMachineDescriptor vmd : vms) {
 282                                 if (vmid == Integer.parseInt(vmd.id())) {
 283                                         try {
 284                                                 VirtualMachine vm = VirtualMachine.attach(vmd);
 285                                                 try {
 286                                                         jvmArch = JVMArch.getJVMArch(vm.getSystemProperties());
 287                                                 } finally {
 288                                                         vm.detach();
 289                                                 }




 249                                                         }
 250                                                         if (inMemURL != null) {
 251                                                                 connectable = MGMNT_AGENT_STARTED;
 252                                                         }
 253 
 254                                                         // This used to leak one \BaseNamedObjects\hsperfdata_* Section handle on Windows
 255                                                         address = AttachToolkit.importFromPid(pid);
 256                                                 } finally {
 257                                                         // Although the current implementation of LocalMonitoredVm for Windows doesn't do much here, we should always call detach.
 258                                                         mvm.detach();
 259                                                 }
 260                                         } catch (Exception x) {
 261                                                 // ignore
 262                                         }
 263                                         connDesc = createDescriptor(name, jvmArgs, vmid, connectable, type, jvmArch, address, version, isDebug);
 264                                         return connDesc;
 265                                 }
 266                         });
 267                         return future.get(TIMEOUT_THRESHOLD, TimeUnit.SECONDS);
 268                 } catch (Exception e) {
 269                         BrowserAttachPlugin.getPluginLogger().log(Level.WARNING, "Failed to create descriptor for jvm with PID " + vmid, e); //$NON-NLS-1$
 270                         return null;
 271                 }
 272         }
 273 
 274         /*
 275          * Try to attach to get info from the AttachNotSupportedException.
 276          */
 277         private static JVMArch getArch(Integer vmid) throws IOException {
 278                 JVMArch jvmArch = JVMArch.OTHER;
 279                 List<VirtualMachineDescriptor> vms = VirtualMachine.list();
 280                 if (vms != null) {
 281                         for (VirtualMachineDescriptor vmd : vms) {
 282                                 if (vmid == Integer.parseInt(vmd.id())) {
 283                                         try {
 284                                                 VirtualMachine vm = VirtualMachine.attach(vmd);
 285                                                 try {
 286                                                         jvmArch = JVMArch.getJVMArch(vm.getSystemProperties());
 287                                                 } finally {
 288                                                         vm.detach();
 289                                                 }


< prev index next >