Skip to content

Commit a7f4f17

Browse files
committed
Merge branch 'master' into graal
2 parents 9cbda49 + 9e5669d commit a7f4f17

File tree

12 files changed

+577
-383
lines changed

12 files changed

+577
-383
lines changed

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/ClassNode.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ protected Object getValue(DataType type, Heap heap) {
105105

106106
if (type == DataType.OBJECT_ID) return getJavaClass().getJavaClassId();
107107

108+
if (type == DataType.INSTANCES_WRAPPER) return new InstancesWrapper.Simple(getJavaClass(), getInstancesCount()) {
109+
@Override
110+
public Iterator<Instance> getInstancesIterator() {
111+
return ClassNode.this.getInstancesIterator();
112+
}
113+
};
114+
108115
return super.getValue(type, heap);
109116
}
110117

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/InstancesContainer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
9797

9898
protected Object getValue(DataType type, Heap heap) {
9999
if (type == DataType.CLASS) return getJavaClass();
100+
101+
if (type == DataType.INSTANCES_WRAPPER) return new InstancesWrapper.Simple(getJavaClass(), getCount()) {
102+
@Override
103+
public Iterator<Instance> getInstancesIterator() {
104+
return Objects.this.getInstancesIterator();
105+
}
106+
};
100107

101108
return super.getValue(type, heap);
102109
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
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+
26+
package org.graalvm.visualvm.heapviewer.java;
27+
28+
import java.util.Iterator;
29+
import org.graalvm.visualvm.lib.jfluid.heap.Instance;
30+
import org.graalvm.visualvm.lib.jfluid.heap.JavaClass;
31+
32+
/**
33+
*
34+
* @author Jiri Sedlacek
35+
*/
36+
public abstract class InstancesWrapper {
37+
38+
public abstract JavaClass getJavaClass();
39+
40+
public abstract int getInstancesCount();
41+
42+
public abstract Iterator<Instance> getInstancesIterator();
43+
44+
45+
public static abstract class Simple extends InstancesWrapper {
46+
47+
private final JavaClass jclass;
48+
49+
private final int instancesCount;
50+
51+
52+
public Simple(JavaClass jclass, int instancesCount) {
53+
this.jclass = jclass;
54+
this.instancesCount = instancesCount;
55+
}
56+
57+
58+
@Override
59+
public final JavaClass getJavaClass() {
60+
return jclass;
61+
}
62+
63+
@Override
64+
public final int getInstancesCount() {
65+
return instancesCount;
66+
}
67+
68+
}
69+
70+
}

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaFieldsPlugin.java

Lines changed: 33 additions & 75 deletions
Large diffs are not rendered by default.

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaFieldsProvider.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.graalvm.visualvm.heapviewer.model.Progress;
4545
import org.graalvm.visualvm.heapviewer.ui.UIThresholds;
4646
import org.graalvm.visualvm.heapviewer.utils.NodesComputer;
47-
import static org.graalvm.visualvm.heapviewer.utils.NodesComputer.integerIterator;
4847
import org.graalvm.visualvm.heapviewer.utils.ProgressIterator;
4948
import org.openide.util.NbBundle;
5049
import org.openide.util.lookup.ServiceProvider;
@@ -129,14 +128,18 @@ public boolean supportsNode(HeapViewerNode parent, Heap heap, String viewID) {
129128

130129

131130
protected List<FieldValue> getFields(HeapViewerNode parent, Heap heap) {
131+
return getFields(parent, heap, includeInstanceFields, includeStaticFields);
132+
}
133+
134+
static List<FieldValue> getFields(HeapViewerNode parent, Heap heap, boolean instanceFields, boolean staticFields) {
132135
Instance instance = HeapViewerNode.getValue(parent, DataType.INSTANCE, heap);
133136
if (instance == null) return null;
134137

135-
if (includeStaticFields == includeInstanceFields) {
138+
if (staticFields == instanceFields) {
136139
List<FieldValue> fields = new ArrayList(instance.getFieldValues());
137140
fields.addAll(instance.getStaticFieldValues());
138141
return fields;
139-
} else if (includeInstanceFields) {
142+
} else if (instanceFields) {
140143
return instance.getFieldValues();
141144
} else {
142145
return instance.getStaticFieldValues();

0 commit comments

Comments
 (0)