Skip to content

Commit ca63df0

Browse files
committed
dependency cleanup - org.graalvm.visualvm.jvm no longer depends on org.graalvm.visualvm.heapdump and org.graalvm.visualvm.threaddump
1 parent 6ce0307 commit ca63df0

File tree

11 files changed

+55
-67
lines changed

11 files changed

+55
-67
lines changed

visualvm/application/manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ OpenIDE-Module: org.graalvm.visualvm.application/2
55
OpenIDE-Module-Layer: org/graalvm/visualvm/application/resources/layer.xml
66
OpenIDE-Module-Install: org/graalvm/visualvm/application/Installer.class
77
OpenIDE-Module-Localizing-Bundle: org/graalvm/visualvm/application/resources/Bundle.properties
8-
OpenIDE-Module-Specification-Version: 2.2
8+
OpenIDE-Module-Specification-Version: 2.3
99

visualvm/application/src/org/graalvm/visualvm/application/jvm/DefaultJvm.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ public void setDumpOnOOMEnabled(boolean enabled) {
146146
throw new UnsupportedOperationException();
147147
}
148148

149-
public File takeHeapDump() throws IOException {
149+
public boolean takeHeapDump(File outoutFile) throws IOException {
150150
throw new UnsupportedOperationException();
151151
}
152152

153-
public File takeThreadDump() throws IOException {
153+
public String takeThreadDump() {
154154
throw new UnsupportedOperationException();
155155
}
156156

visualvm/application/src/org/graalvm/visualvm/application/jvm/Jvm.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,14 @@ public boolean is110() {
315315
public abstract boolean isTakeHeapDumpSupported();
316316

317317
/**
318-
* Takes heap dump of target JVM.
319-
* @return returns {@link File} where heap dump is stored.
318+
* Dumps the heap to the <tt>outputFile</tt> file in the same
319+
* format as the hprof heap dump.
320+
* @param outputFile {@link File} where heap dump will be stored
321+
* @return <CODE>true</CODE> if heap dump was created,
322+
* <CODE>false</CODE> otherwise
320323
* @throws java.io.IOException I/O error
321324
*/
322-
public abstract File takeHeapDump() throws IOException;
325+
public abstract boolean takeHeapDump(File outputFile) throws IOException;
323326

324327
/**
325328
* Tests if it is possible to obtain thread dump from target JVM.
@@ -330,10 +333,9 @@ public boolean is110() {
330333

331334
/**
332335
* Takes thread dump of target JVM.
333-
* @throws java.io.IOException i/O error
334336
* @return Returns {@link String} of the thread dump from target JVM.
335337
*/
336-
public abstract File takeThreadDump() throws IOException;
338+
public abstract String takeThreadDump();
337339

338340
/**
339341
* Takes heap histogram of target Application.

visualvm/graalvm/nbproject/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<compile-dependency/>
1313
<run-dependency>
1414
<release-version>2</release-version>
15-
<specification-version>2.2</specification-version>
15+
<specification-version>2.3</specification-version>
1616
</run-dependency>
1717
</dependency>
1818
<dependency>

visualvm/graalvm/src/org/graalvm/visualvm/graalvm/svm/SVMJVMImpl.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.File;
2828
import java.io.IOException;
2929
import java.nio.file.FileSystems;
30+
import java.nio.file.Files;
3031
import java.nio.file.Path;
3132
import java.nio.file.Paths;
3233
import java.nio.file.StandardWatchEventKinds;
@@ -300,7 +301,7 @@ public boolean isTakeHeapDumpSupported() {
300301
return false;
301302
}
302303

303-
public File takeHeapDump() throws IOException {
304+
public boolean takeHeapDump(File outputFile) throws IOException {
304305
if (!isTakeHeapDumpSupported()) {
305306
throw new UnsupportedOperationException();
306307
}
@@ -317,14 +318,16 @@ public File takeHeapDump() throws IOException {
317318
}
318319
watchService.close();
319320
if (name == null) {
320-
return null;
321+
return false;
321322
}
322-
File dumpFile = applicationCwd.resolve(name).toFile();
323-
waitDumpDone(dumpFile);
324-
return dumpFile;
323+
Path dumpPath = applicationCwd.resolve(name);
324+
Path outputPath = outputFile.toPath();
325+
waitDumpDone(dumpPath);
326+
Files.move(dumpPath, outputPath);
327+
return true;
325328
} catch (InterruptedException ex) {
326329
watchService.close();
327-
return null;
330+
return false;
328331
}
329332
}
330333

@@ -348,7 +351,7 @@ public boolean isTakeThreadDumpSupported() {
348351
return false;
349352
}
350353

351-
public File takeThreadDump() throws IOException {
354+
public String takeThreadDump() {
352355
throw new UnsupportedOperationException();
353356
}
354357

@@ -437,17 +440,17 @@ void notifyListeners(final MonitoredData data) {
437440
}
438441
}
439442

440-
private void waitDumpDone(File name) {
443+
private void waitDumpDone(Path name) throws IOException {
441444
long size;
442-
long newSize = name.length();
445+
long newSize = Files.size(name);
443446
do {
444447
size = newSize;
445448
try {
446449
Thread.sleep(1000);
447450
} catch (InterruptedException ex) {
448451
return;
449452
}
450-
newSize = name.length();
453+
newSize = Files.size(name);
451454
} while (size != newSize);
452455
}
453456

visualvm/heapdump/nbproject/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<compile-dependency/>
1313
<run-dependency>
1414
<release-version>2</release-version>
15-
<specification-version>2.1</specification-version>
15+
<specification-version>2.3</specification-version>
1616
</run-dependency>
1717
</dependency>
1818
<dependency>

visualvm/heapdump/src/org/graalvm/visualvm/heapdump/impl/HeapDumpProvider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ public void run() {
9494
pHandle.setInitialDelay(0);
9595
pHandle.start();
9696
try {
97-
File file = jvm.takeHeapDump();
98-
if (file != null && file.isFile()) {
97+
File snapshotDir = application.getStorage().getDirectory();
98+
String name = HeapDumpSupport.getInstance().getCategory().createFileName();
99+
File file = new File(snapshotDir,name);
100+
if (jvm.takeHeapDump(file) && file.isFile()) {
99101
final HeapDumpImpl heapDump = new HeapDumpImpl(file, application);
100102
application.getRepository().addDataSource(heapDump);
101103
if (openView) DataSource.EVENT_QUEUE.post(new Runnable() {

visualvm/jvm/nbproject/project.xml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<compile-dependency/>
1313
<run-dependency>
1414
<release-version>2</release-version>
15-
<specification-version>2.2</specification-version>
15+
<specification-version>2.3</specification-version>
1616
</run-dependency>
1717
</dependency>
1818
<dependency>
@@ -24,24 +24,6 @@
2424
<specification-version>2.0</specification-version>
2525
</run-dependency>
2626
</dependency>
27-
<dependency>
28-
<code-name-base>org.graalvm.visualvm.heapdump</code-name-base>
29-
<build-prerequisite/>
30-
<compile-dependency/>
31-
<run-dependency>
32-
<release-version>2</release-version>
33-
<specification-version>2.0</specification-version>
34-
</run-dependency>
35-
</dependency>
36-
<dependency>
37-
<code-name-base>org.graalvm.visualvm.threaddump</code-name-base>
38-
<build-prerequisite/>
39-
<compile-dependency/>
40-
<run-dependency>
41-
<release-version>2</release-version>
42-
<specification-version>2.0</specification-version>
43-
</run-dependency>
44-
</dependency>
4527
<dependency>
4628
<code-name-base>org.graalvm.visualvm.tools</code-name-base>
4729
<build-prerequisite/>

visualvm/jvm/src/org/graalvm/visualvm/jvm/JVMImpl.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
import org.graalvm.visualvm.application.Application;
3232
import org.graalvm.visualvm.application.jvm.HeapHistogram;
3333
import org.graalvm.visualvm.core.datasupport.Stateful;
34-
import org.graalvm.visualvm.heapdump.HeapDumpSupport;
35-
import org.graalvm.visualvm.threaddump.ThreadDumpSupport;
3634
import org.graalvm.visualvm.tools.attach.AttachModel;
3735
import org.graalvm.visualvm.tools.attach.AttachModelFactory;
3836
import org.graalvm.visualvm.tools.jmx.JmxModel;
@@ -406,23 +404,20 @@ public boolean isTakeHeapDumpSupported() {
406404
return false;
407405
}
408406

409-
public File takeHeapDump() throws IOException {
407+
public boolean takeHeapDump(File dumpFile) throws IOException {
410408
if (!isTakeHeapDumpSupported()) {
411409
throw new UnsupportedOperationException();
412410
}
413-
File snapshotDir = application.getStorage().getDirectory();
414-
String name = HeapDumpSupport.getInstance().getCategory().createFileName();
415-
File dumpFile = new File(snapshotDir,name);
416411
AttachModel attach = getAttach();
417412
if (attach != null) {
418413
if (attach.takeHeapDump(dumpFile.getAbsolutePath())) {
419-
return dumpFile;
414+
return true;
420415
}
421416
}
422417
if (getJmxModel().takeHeapDump(dumpFile.getAbsolutePath())) {
423-
return dumpFile;
418+
return true;
424419
}
425-
return null;
420+
return false;
426421
}
427422

428423
public boolean isTakeThreadDumpSupported() {
@@ -436,7 +431,7 @@ public boolean isTakeThreadDumpSupported() {
436431
return getSAAgent() != null;
437432
}
438433

439-
public File takeThreadDump() throws IOException {
434+
public String takeThreadDump() {
440435
AttachModel attach = getAttach();
441436
String threadDump = null;
442437

@@ -461,13 +456,7 @@ public File takeThreadDump() throws IOException {
461456
}
462457
threadDump = NbBundle.getMessage(JVMImpl.class, "MSG_ThreadDumpfailed"); // NOI18N
463458
}
464-
File snapshotDir = application.getStorage().getDirectory();
465-
String name = ThreadDumpSupport.getInstance().getCategory().createFileName();
466-
File dumpFile = new File(snapshotDir,name);
467-
OutputStream os = new FileOutputStream(dumpFile);
468-
os.write(threadDump.getBytes("UTF-8")); // NOI18N
469-
os.close();
470-
return dumpFile;
459+
return threadDump;
471460
}
472461

473462
public HeapHistogram takeHeapHistogram() {

visualvm/threaddump/nbproject/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<compile-dependency/>
1313
<run-dependency>
1414
<release-version>2</release-version>
15-
<specification-version>2.1</specification-version>
15+
<specification-version>2.3</specification-version>
1616
</run-dependency>
1717
</dependency>
1818
<dependency>

0 commit comments

Comments
 (0)