# HG changeset patch # User cjplummer # Date 1569699214 25200 # Node ID 31524b0167839fec628e37cae61fa2c570a6601e # Parent a819c684964b16236d4e971118f045eadb817120 8231287: JMap should do a better job of reporting exception it catches Summary: Retrhow any caught exception, and always print exceptions before exiting Reviewed-by: sspitsyn, phh diff -r a819c684964b -r 31524b016783 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java Fri Sep 27 17:50:09 2019 -0700 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java Sat Sep 28 12:33:34 2019 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -182,9 +182,8 @@ hgw.write(fileName); System.out.println("heap written to " + fileName); return true; - } catch (IOException | RuntimeException exp) { - System.err.println(exp.getMessage()); - return false; + } catch (IOException exp) { + throw new RuntimeException(exp); } } @@ -199,8 +198,7 @@ System.out.println("heap written to " + fileName); return true; } catch (IOException exp) { - System.err.println(exp.getMessage()); - return false; + throw new RuntimeException(exp); } } diff -r a819c684964b -r 31524b016783 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/Tool.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/Tool.java Fri Sep 27 17:50:09 2019 -0700 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/Tool.java Sat Sep 28 12:33:34 2019 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -116,6 +116,8 @@ try { returnStatus = start(args); + } catch (Throwable t) { + t.printStackTrace(System.err); } finally { stop(); } diff -r a819c684964b -r 31524b016783 test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java --- a/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java Fri Sep 27 17:50:09 2019 -0700 +++ b/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java Sat Sep 28 12:33:34 2019 -0700 @@ -73,7 +73,6 @@ System.out.println("jhsdb jmap stderr:"); System.out.println(output.getStderr()); System.out.println("###### End of all output:"); - output.shouldNotContain("null"); output.shouldHaveExitValue(0); } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex);