8218947: jdb threads command should print threadID in decimal, not hex
authorcjplummer
Tue, 19 Feb 2019 12:05:43 -0800
changeset 53827 0da72c89e368
parent 53826 d3213547a767
child 53828 9c44ab24b4a4
8218947: jdb threads command should print threadID in decimal, not hex Summary: print objectIDs in decimal. Reviewed-by: sspitsyn, dholmes, jcbeyler
src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Env.java
src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java
test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001.java
--- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Env.java	Tue Feb 19 19:04:55 2019 +0100
+++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Env.java	Tue Feb 19 12:05:43 2019 -0800
@@ -211,58 +211,14 @@
         ReferenceType clazz = ref.referenceType();
         long id = ref.uniqueID();
         if (clazz == null) {
-            return toHex(id);
+            return Long.toString(id);
         } else {
-            return MessageOutput.format("object description and hex id",
+            return MessageOutput.format("object description and id",
                                         new Object [] {clazz.name(),
-                                                       toHex(id)});
+                                                       Long.toString(id)});
         }
     }
 
-    /** Convert a long to a hexadecimal string. */
-    static String toHex(long n) {
-        char s1[] = new char[16];
-        char s2[] = new char[18];
-
-        /* Store digits in reverse order. */
-        int i = 0;
-        do {
-            long d = n & 0xf;
-            s1[i++] = (char)((d < 10) ? ('0' + d) : ('a' + d - 10));
-        } while ((n >>>= 4) > 0);
-
-        /* Now reverse the array. */
-        s2[0] = '0';
-        s2[1] = 'x';
-        int j = 2;
-        while (--i >= 0) {
-            s2[j++] = s1[i];
-        }
-        return new String(s2, 0, j);
-    }
-
-    /** Convert hexadecimal strings to longs. */
-    static long fromHex(String hexStr) {
-        String str = hexStr.startsWith("0x") ?
-            hexStr.substring(2).toLowerCase() : hexStr.toLowerCase();
-        if (hexStr.length() == 0) {
-            throw new NumberFormatException();
-        }
-
-        long ret = 0;
-        for (int i = 0; i < str.length(); i++) {
-            int c = str.charAt(i);
-            if (c >= '0' && c <= '9') {
-                ret = (ret * 16) + (c - '0');
-            } else if (c >= 'a' && c <= 'f') {
-                ret = (ret * 16) + (c - 'a' + 10);
-            } else {
-                throw new NumberFormatException();
-            }
-        }
-        return ret;
-    }
-
     static ReferenceType getReferenceTypeFromToken(String idToken) {
         ReferenceType cls = null;
         if (Character.isDigit(idToken.charAt(0))) {
--- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java	Tue Feb 19 19:04:55 2019 +0100
+++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java	Tue Feb 19 12:05:43 2019 -0800
@@ -235,7 +235,7 @@
         {"Not owned", "  Not owned"},
         {"Not waiting for a monitor", "  Not waiting for a monitor"},
         {"Nothing suspended.", "Nothing suspended."},
-        {"object description and hex id", "({0}){1}"},
+        {"object description and id", "({0}){1}"},
         {"Operation is not supported on the target VM", "Operation is not supported on the target VM"},
         {"operation not yet supported", "operation not yet supported"},
         {"Owned by:", "  Owned by: {0}, entry count: {1,number,integer}"},
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001.java	Tue Feb 19 19:04:55 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001.java	Tue Feb 19 12:05:43 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, 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
@@ -94,7 +94,13 @@
 
     static int numThreads = nsk.jdb.interrupt.interrupt001.interrupt001a.numThreads;
 
-    private static Pattern tidPattern = Pattern.compile("(0x[0-9a-f]+)");
+    /*
+     * Pattern for finding the thread ID in a line like the following:
+     *   (nsk.jdb.interrupt.interrupt001.interrupt001a$MyThread)651 Thread-0          cond. waiting
+     * Note we can't match on DEBUGGEE_THREAD because it includes a $, which Pattern
+     * uses to match the end of a line.
+     */
+    private static Pattern tidPattern = Pattern.compile("\\(.+" + MYTHREAD + "\\)(\\S+)");
 
     protected void runCases() {
         String[] reply;