|
42 | 42 | import java.awt.GridBagLayout;
|
43 | 43 | import java.awt.Insets;
|
44 | 44 | import java.text.NumberFormat;
|
| 45 | +import java.util.ArrayList; |
45 | 46 | import java.util.Collection;
|
46 | 47 | import java.util.Comparator;
|
| 48 | +import java.util.List; |
47 | 49 | import java.util.Map;
|
48 | 50 | import java.util.Properties;
|
49 | 51 | import java.util.Set;
|
|
58 | 60 | import org.graalvm.visualvm.lib.jfluid.heap.HeapSummary;
|
59 | 61 | import org.graalvm.visualvm.lib.jfluid.heap.Instance;
|
60 | 62 | import org.graalvm.visualvm.lib.jfluid.heap.JavaClass;
|
| 63 | +import org.graalvm.visualvm.lib.jfluid.heap.ObjectArrayInstance; |
| 64 | +import org.graalvm.visualvm.lib.profiler.heapwalk.details.api.DetailsSupport; |
61 | 65 | import org.graalvm.visualvm.lib.ui.components.ProfilerToolbar;
|
62 | 66 | import org.graalvm.visualvm.lib.ui.swing.renderer.LabelRenderer;
|
63 | 67 | import org.openide.util.NbBundle;
|
@@ -299,6 +303,48 @@ private static long computeStartupTime(Heap heap) {
|
299 | 303 | return -1;
|
300 | 304 | }
|
301 | 305 |
|
| 306 | + private List<String> computeVMArgs(Heap heap) { |
| 307 | + List<String> vmArgsList = new ArrayList(); |
| 308 | + JavaClass vmManagementClass = heap.getJavaClassByName("sun.management.VMManagementImpl"); // NOI18N |
| 309 | + |
| 310 | + if (vmManagementClass != null) { |
| 311 | + if (vmManagementClass.getInstancesCount()>0) { |
| 312 | + Instance vmManagement = (Instance) vmManagementClass.getInstancesIterator().next(); |
| 313 | + Object vma = vmManagement.getValueOfField("vmArgs"); |
| 314 | + |
| 315 | + if (vma instanceof Instance) { |
| 316 | + Instance vmargs = (Instance) vma; |
| 317 | + Object list = vmargs.getValueOfField("list"); |
| 318 | + Object arr; |
| 319 | + Object size = null; |
| 320 | + |
| 321 | + if (list instanceof Instance) { |
| 322 | + arr = ((Instance)list).getValueOfField("a"); |
| 323 | + } else { |
| 324 | + size = vmargs.getValueOfField("size"); |
| 325 | + arr = vmargs.getValueOfField("elementData"); |
| 326 | + } |
| 327 | + if (arr instanceof ObjectArrayInstance) { |
| 328 | + ObjectArrayInstance vmArgsArr = (ObjectArrayInstance) arr; |
| 329 | + int length = vmArgsArr.getLength(); |
| 330 | + List<Instance> elements = vmArgsArr.getValues(); |
| 331 | + |
| 332 | + if (size instanceof Integer) { |
| 333 | + length = ((Integer)size).intValue(); |
| 334 | + } |
| 335 | + for (int i = 0; i < length; i++) { |
| 336 | + Instance arg = elements.get(i); |
| 337 | + |
| 338 | + vmArgsList.add(DetailsSupport.getDetailsString(arg, heap)); |
| 339 | + } |
| 340 | + return vmArgsList; |
| 341 | + } |
| 342 | + } |
| 343 | + } |
| 344 | + } |
| 345 | + return null; |
| 346 | + } |
| 347 | + |
302 | 348 | private static String getTime(long millis) {
|
303 | 349 | // Hours
|
304 | 350 | long hours = millis / 3600000;
|
|
0 commit comments