Skip to content

Commit f6a5479

Browse files
committed
8231287: JMap should do a better job of reporting exception it catches
Retrhow any caught exception, and always print exceptions before exiting Reviewed-by: sspitsyn, phh
1 parent 680fceb commit f6a5479

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -182,9 +182,8 @@ public boolean writeHeapHprofBin(String fileName) {
182182
hgw.write(fileName);
183183
System.out.println("heap written to " + fileName);
184184
return true;
185-
} catch (IOException | RuntimeException exp) {
186-
System.err.println(exp.getMessage());
187-
return false;
185+
} catch (IOException exp) {
186+
throw new RuntimeException(exp);
188187
}
189188
}
190189

@@ -199,8 +198,7 @@ private boolean writeHeapGXL(String fileName) {
199198
System.out.println("heap written to " + fileName);
200199
return true;
201200
} catch (IOException exp) {
202-
System.err.println(exp.getMessage());
203-
return false;
201+
throw new RuntimeException(exp);
204202
}
205203
}
206204

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/Tool.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -116,6 +116,8 @@ protected void execute(String[] args) {
116116

117117
try {
118118
returnStatus = start(args);
119+
} catch (Throwable t) {
120+
t.printStackTrace(System.err);
119121
} finally {
120122
stop();
121123
}

test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public static void launch(String expectedMessage, List<String> toolArgs)
7373
System.out.println("jhsdb jmap stderr:");
7474
System.out.println(output.getStderr());
7575
System.out.println("###### End of all output:");
76-
output.shouldNotContain("null");
7776
output.shouldHaveExitValue(0);
7877
} catch (Exception ex) {
7978
throw new RuntimeException("Test ERROR " + ex, ex);

0 commit comments

Comments
 (0)