diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java index 15091d310d5..121038a6d72 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2022, 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 @@ -501,7 +501,7 @@ class Commands { void commandThreadGroup(StringTokenizer t) { if (!t.hasMoreTokens()) { - MessageOutput.println("Threadgroup name not specified."); + ThreadInfo.setThreadGroup(null); // reset to default (top level ThreadGroup) return; } String name = t.nextToken(); diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java index 8ba3c42c83a..adec7aa98cf 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2022, 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 @@ -312,7 +312,6 @@ public class TTYResources extends java.util.ListResourceBundle { {"Thread has been resumed", "Thread has been resumed"}, {"Thread not suspended", "Thread not suspended"}, {"thread group number description name", "{0,number,integer}. {1} {2}"}, - {"Threadgroup name not specified.", "Threadgroup name not specified."}, {" option not valid until the VM is started with the run command", " option not valid until the VM is started with the run command"}, {"Threads must be suspended", "Threads must be suspended"}, @@ -354,7 +353,7 @@ public class TTYResources extends java.util.ListResourceBundle { "\n" + "run [class [args]] -- start execution of application's main class\n" + "\n" + - "threads [threadgroup] -- list threads\n" + + "threads [threadgroup] -- list threads in threadgroup. Use current threadgroup if none specified.\n" + "thread -- set default thread\n" + "suspend [thread id(s)] -- suspend threads (default: all)\n" + "resume [thread id(s)] -- resume threads (default: all)\n" + @@ -377,7 +376,8 @@ public class TTYResources extends java.util.ListResourceBundle { "fields -- list a class's fields\n" + "\n" + "threadgroups -- list threadgroups\n" + - "threadgroup -- set current threadgroup\n" + + "threadgroup -- set current threadgroup to \n" + + "threadgroup -- set current threadgroup back to the top level threadgroup\n" + "\n" + "stop [go|thread] [] \n" + " -- set a breakpoint\n" + diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java index 1f0dd4a3e22..330fc33a820 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2022, 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 @@ -302,7 +302,6 @@ public class TTYResources_ja extends java.util.ListResourceBundle { {"Thread has been resumed", "\u30B9\u30EC\u30C3\u30C9\u304C\u518D\u958B\u3057\u307E\u3057\u305F"}, {"Thread not suspended", "\u30B9\u30EC\u30C3\u30C9\u306F\u4E2D\u65AD\u3057\u3066\u3044\u307E\u305B\u3093"}, {"thread group number description name", "{0,number,integer}. {1} {2}"}, - {"Threadgroup name not specified.", "\u30B9\u30EC\u30C3\u30C9\u30B0\u30EB\u30FC\u30D7\u540D\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, {" option not valid until the VM is started with the run command", "\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3001VM\u304Crun\u30B3\u30DE\u30F3\u30C9\u3067\u958B\u59CB\u3055\u308C\u308B\u307E\u3067\u7121\u52B9\u3067\u3059"}, {"Threads must be suspended", "\u30B9\u30EC\u30C3\u30C9\u3092\u4E2D\u65AD\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java index 88c1cd3e878..6c4be977705 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2022, 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 @@ -302,7 +302,6 @@ public class TTYResources_zh_CN extends java.util.ListResourceBundle { {"Thread has been resumed", "\u5DF2\u6062\u590D\u7EBF\u7A0B"}, {"Thread not suspended", "\u672A\u6302\u8D77\u7EBF\u7A0B"}, {"thread group number description name", "{0,number,integer}\u3002{1} {2}"}, - {"Threadgroup name not specified.", "\u672A\u6307\u5B9A\u7EBF\u7A0B\u7EC4\u540D\u3002"}, {" option not valid until the VM is started with the run command", "\u5728\u4F7F\u7528 run \u547D\u4EE4\u542F\u52A8 VM \u524D\uFF0C \u9009\u9879\u65E0\u6548"}, {"Threads must be suspended", "\u5FC5\u987B\u6302\u8D77\u7EBF\u7A0B"}, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroup/threadgroup002/threadgroup002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroup/threadgroup002/threadgroup002.java index cb8004643d3..72bbf358474 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroup/threadgroup002/threadgroup002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroup/threadgroup002/threadgroup002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2022, 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 @@ -29,11 +29,15 @@ * VM Testbase keywords: [jpda, jdb] * VM Testbase readme: * DECSRIPTION - * This is a test for jdb 'threadgroup ' command. + * This is a test for jdb 'threadgroup ' command and + * also for the 'threadgroup' command with no argument. * The main thread creates 3 threadgroups of 5 threads each. * All threads are locked in their 'run' method on a lock that the main - * thread holds. The test passes if jdb correctly switches between - * three user-defined threadgroups using 'threadgroup' command. + * thread holds. The test then makes sure jdb correctly switches between + * the three user-defined threadgroups using 'threadgroup' command. It then + * resets the current threadgroup back to the default top level threadgroup + * by using the 'threadgroup' command with no argument. It then tests that + * all 3 created threadgroups can be found in the 'threads' output. * COMMENTS * This test functionally equals to nsk/jdb/threadgroup/threadgroup001 * test and replaces it. @@ -45,6 +49,7 @@ * nsk.jdb.threadgroup.threadgroup002.threadgroup002 * -arch=${os.family}-${os.simpleArch} * -waittime=5 + * -verbose * -debugee.vmkind=java * -transport.address=dynamic * -jdb=${test.jdk}/bin/jdb @@ -100,6 +105,15 @@ public class threadgroup002 extends JdbTest { } } + // Test switching back to the default top level group. + reply = jdb.receiveReplyFor(JdbCommand.threadgroup); + reply = jdb.receiveReplyFor(JdbCommand.threads); + grep = new Paragrep(reply); + count = grep.find(threadgroup002a.THREADGROUP_NAME); + if (count != threadgroup002a.numThreadGroups) { + failure("jdb cannot switch to default top level threadgroup"); + } + jdb.contToExit(1); } }