Skip to content

Commit 34cd81a

Browse files
jisedlacthurka
authored andcommitted
VisualVM Heap Viewer
1 parent 53eab06 commit 34cd81a

File tree

104 files changed

+15148
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+15148
-86
lines changed

visualvm/heapdump/manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ OpenIDE-Module: com.sun.tools.visualvm.heapdump/0
55
OpenIDE-Module-Install: com/sun/tools/visualvm/heapdump/Installer.class
66
OpenIDE-Module-Layer: com/sun/tools/visualvm/heapdump/resources/layer.xml
77
OpenIDE-Module-Localizing-Bundle: com/sun/tools/visualvm/heapdump/Bundle.properties
8-
OpenIDE-Module-Specification-Version: 1.2
8+
OpenIDE-Module-Specification-Version: 1.3
99

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
build.xml.data.CRC32=0c830f5b
1+
build.xml.data.CRC32=5428a1b3
22
build.xml.script.CRC32=c00ae7ac
3-
build.xml.stylesheet.CRC32=a56c6a5b@2.72.1
3+
build.xml.stylesheet.CRC32=a56c6a5b@2.73
44
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
55
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6-
nbproject/build-impl.xml.data.CRC32=0c830f5b
6+
nbproject/build-impl.xml.data.CRC32=5428a1b3
77
nbproject/build-impl.xml.script.CRC32=f1cff99d
8-
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.72.1
8+
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.73

visualvm/heapdump/nbproject/project.xml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333
<specification-version>1.0</specification-version>
3434
</run-dependency>
3535
</dependency>
36+
<dependency>
37+
<code-name-base>com.sun.tools.visualvm.heapviewer</code-name-base>
38+
<build-prerequisite/>
39+
<compile-dependency/>
40+
<run-dependency>
41+
<release-version>0</release-version>
42+
<specification-version>1.0</specification-version>
43+
</run-dependency>
44+
</dependency>
3645
<dependency>
3746
<code-name-base>com.sun.tools.visualvm.tools</code-name-base>
3847
<build-prerequisite/>
@@ -109,14 +118,6 @@
109118
<specification-version>9.11</specification-version>
110119
</run-dependency>
111120
</dependency>
112-
<dependency>
113-
<code-name-base>org.openide.loaders</code-name-base>
114-
<build-prerequisite/>
115-
<compile-dependency/>
116-
<run-dependency>
117-
<specification-version>7.67</specification-version>
118-
</run-dependency>
119-
</dependency>
120121
<dependency>
121122
<code-name-base>org.openide.modules</code-name-base>
122123
<build-prerequisite/>
@@ -125,14 +126,6 @@
125126
<specification-version>7.3.1</specification-version>
126127
</run-dependency>
127128
</dependency>
128-
<dependency>
129-
<code-name-base>org.openide.nodes</code-name-base>
130-
<build-prerequisite/>
131-
<compile-dependency/>
132-
<run-dependency>
133-
<specification-version>7.46</specification-version>
134-
</run-dependency>
135-
</dependency>
136129
<dependency>
137130
<code-name-base>org.openide.util</code-name-base>
138131
<build-prerequisite/>

visualvm/heapdump/src/com/sun/tools/visualvm/heapdump/impl/HeapDumpCategory.java

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,14 @@
2626
package com.sun.tools.visualvm.heapdump.impl;
2727

2828
import com.sun.tools.visualvm.core.snapshot.SnapshotCategory;
29+
import com.sun.tools.visualvm.core.ui.DataSourceWindowManager;
2930
import com.sun.tools.visualvm.heapdump.HeapDump;
3031
import java.io.File;
3132
import java.io.FileNotFoundException;
3233
import java.io.IOException;
3334
import java.io.RandomAccessFile;
34-
import java.util.logging.Level;
35-
import java.util.logging.Logger;
36-
import javax.swing.SwingUtilities;
3735
import javax.swing.filechooser.FileFilter;
38-
import org.netbeans.api.actions.Openable;
39-
import org.netbeans.api.progress.ProgressHandle;
40-
import org.netbeans.api.progress.ProgressHandleFactory;
41-
import org.openide.filesystems.FileObject;
42-
import org.openide.filesystems.FileUtil;
43-
import org.openide.loaders.DataObject;
4436
import org.openide.util.NbBundle;
45-
import org.openide.util.RequestProcessor;
4637

4738
/**
4839
*
@@ -51,10 +42,7 @@
5142
*/
5243
public class HeapDumpCategory extends SnapshotCategory<HeapDump> {
5344

54-
private static final Logger LOGGER =
55-
Logger.getLogger(HeapDumpCategory.class.getName());
56-
57-
private static final String HPROF_HEADER = "JAVA PROFILE 1.0";
45+
private static final String HPROF_HEADER = "JAVA PROFILE 1.0"; // NOI18N
5846
private static final long MIN_HPROF_SIZE = 1024*1024L;
5947
private static final String NAME = NbBundle.getMessage(HeapDumpCategory.class, "LBL_Heap_Dumps"); // NOI18N
6048
private static final String PREFIX = "heapdump"; // NOI18N
@@ -69,39 +57,7 @@ public boolean supportsOpenSnapshot() {
6957
}
7058

7159
public void openSnapshot(File file) {
72-
RequestProcessor.getDefault().post(new Runnable() {
73-
public void run() {
74-
ProgressHandle pHandle = null;
75-
try {
76-
pHandle = ProgressHandleFactory.createHandle(
77-
NbBundle.getMessage(HeapDumpCategory.class,
78-
"MSG_Opening_Heap_Dump")); // NOI18N
79-
pHandle.setInitialDelay(0);
80-
pHandle.start();
81-
try {
82-
FileObject fileObject = FileUtil.toFileObject(file);
83-
DataObject dobj = DataObject.find(fileObject);
84-
Openable openCookie = dobj.getLookup().lookup(Openable.class);
85-
openCookie.open();
86-
} catch (Exception e) {
87-
LOGGER.log(Level.INFO, "Error loading profiler snapshot", e); // NOI18N
88-
// TODO: enable once HeapDump module is a friend of Profiler API
89-
// SwingUtilities.invokeLater(new Runnable() {
90-
// public void run() {
91-
// ProfilerDialogs.displayError(
92-
// NbBundle.getMessage(HeapDumpCategory.class,
93-
// "MSG_Opening_Heap_Dump_failed")); // NOI18N
94-
// }
95-
// });
96-
}
97-
} finally {
98-
final ProgressHandle pHandleF = pHandle;
99-
SwingUtilities.invokeLater(new Runnable() {
100-
public void run() { if (pHandleF != null) pHandleF.finish(); }
101-
});
102-
}
103-
}
104-
});
60+
DataSourceWindowManager.sharedInstance().openDataSource(new HeapDumpImpl(file, null)); // TODO: instance should be created by HeapDumpProvider!
10561
}
10662

10763
protected boolean isSnapshot(File file) {

visualvm/heapdump/src/com/sun/tools/visualvm/heapdump/impl/HeapDumpView.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,16 @@
3333
import com.sun.tools.visualvm.core.ui.DataSourceView;
3434
import com.sun.tools.visualvm.core.ui.components.DataViewComponent;
3535
import com.sun.tools.visualvm.core.ui.components.ScrollableContainer;
36+
import com.sun.tools.visualvm.heapviewer.HeapViewer;
3637
import java.awt.BorderLayout;
3738
import java.io.File;
3839
import java.io.FileNotFoundException;
3940
import java.io.IOException;
4041
import java.util.logging.Logger;
41-
import javax.swing.JComponent;
4242
import javax.swing.JLabel;
4343
import javax.swing.JPanel;
44-
import javax.swing.JToolBar;
4544
import javax.swing.SwingConstants;
4645
import javax.swing.SwingUtilities;
47-
import org.netbeans.modules.profiler.heapwalker.v2.HeapWalker;
48-
import org.netbeans.modules.profiler.heapwalker.v2.ui.HeapWalkerWindow;
4946
import org.openide.util.NbBundle;
5047
import org.openide.util.RequestProcessor;
5148

@@ -137,21 +134,10 @@ private void loadHeap(final File file) {
137134
RequestProcessor.getDefault().post(new Runnable() {
138135
public void run() {
139136
try {
140-
final HeapWalker hw = new HeapWalker(file);
137+
final HeapViewer heapViewer = new HeapViewer(file);
141138
SwingUtilities.invokeLater(new Runnable() { public void run() {
142139
contentsPanel.remove(progressLabel);
143-
JComponent hwView = new HeapWalkerWindow(hw);
144-
try {
145-
JComponent fragmentWalker = (JComponent)hwView.getComponent(0);
146-
fragmentWalker.setOpaque(false);
147-
JToolBar toolBar = (JToolBar)fragmentWalker.getComponent(0);
148-
JComponent controllerPanel = (JComponent)fragmentWalker.getComponent(1);
149-
toolBar.setOpaque(false);
150-
((JComponent)toolBar.getComponent(0)).setOpaque(false);
151-
((JComponent)toolBar.getComponent(1)).setOpaque(false);
152-
controllerPanel.setOpaque(false);
153-
} catch (Exception e) {}
154-
contentsPanel.add(hwView, BorderLayout.CENTER);
140+
contentsPanel.add(heapViewer.getComponent(), BorderLayout.CENTER);
155141
contentsPanel.revalidate();
156142
contentsPanel.repaint();
157143
} });

visualvm/heapviewer/build.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
3+
<!-- for some information on what you could do (e.g. targets to override). -->
4+
<!-- If you delete this file and reopen the project it will be recreated. -->
5+
<project name="com.sun.tools.visualvm.heapviewer" default="netbeans" basedir=".">
6+
<description>Builds, tests, and runs the project com.sun.tools.visualvm.heapviewer.</description>
7+
<import file="nbproject/build-impl.xml"/>
8+
</project>

visualvm/heapviewer/manifest.mf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Manifest-Version: 1.0
2+
AutoUpdate-Show-In-Client: false
3+
AutoUpdate-Essential-Module: true
4+
OpenIDE-Module: com.sun.tools.visualvm.heapviewer/0
5+
OpenIDE-Module-Localizing-Bundle: com/sun/tools/visualvm/heapviewer/Bundle.properties
6+
OpenIDE-Module-Specification-Version: 1.0
7+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
*** GENERATED FROM project.xml - DO NOT EDIT ***
4+
*** EDIT ../build.xml INSTEAD ***
5+
-->
6+
<project name="com.sun.tools.visualvm.heapviewer-impl" basedir="..">
7+
<fail message="Please build using Ant 1.7.1 or higher.">
8+
<condition>
9+
<not>
10+
<antversion atleast="1.7.1"/>
11+
</not>
12+
</condition>
13+
</fail>
14+
<property file="nbproject/private/suite-private.properties"/>
15+
<property file="nbproject/suite.properties"/>
16+
<fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
17+
<property file="${suite.dir}/nbproject/private/platform-private.properties"/>
18+
<property file="${suite.dir}/nbproject/platform.properties"/>
19+
<macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
20+
<attribute name="name"/>
21+
<attribute name="value"/>
22+
<sequential>
23+
<property name="@{name}" value="${@{value}}"/>
24+
</sequential>
25+
</macrodef>
26+
<macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
27+
<attribute name="property"/>
28+
<attribute name="value"/>
29+
<sequential>
30+
<property name="@{property}" value="@{value}"/>
31+
</sequential>
32+
</macrodef>
33+
<property file="${user.properties.file}"/>
34+
<nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
35+
<nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
36+
<nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
37+
<fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
38+
<condition>
39+
<not>
40+
<contains string="${cluster.path.evaluated}" substring="platform"/>
41+
</not>
42+
</condition>
43+
</fail>
44+
<import file="${harness.dir}/build.xml"/>
45+
</project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build.xml.data.CRC32=af541590
2+
build.xml.script.CRC32=018997e7
3+
build.xml.stylesheet.CRC32=[email protected]
4+
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5+
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6+
nbproject/build-impl.xml.data.CRC32=af541590
7+
nbproject/build-impl.xml.script.CRC32=98bf6af8
8+
nbproject/build-impl.xml.stylesheet.CRC32=[email protected]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
javac.source=1.8
2+
license.file=../startup/src/com/sun/tools/visualvm/modules/startup/LICENSE.txt
3+
nbm.homepage=https://visualvm.github.io

0 commit comments

Comments
 (0)