Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4432376

TTY: StringIndexOutOfBoundsException when displaying Threads with long names

XMLWordPrintable

    • beta2
    • x86
    • linux, windows_nt
    • Not verified



      Name: tb29552 Date: 03/30/2001


      java version "1.3.0_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_02)
      Java HotSpot(TM) Client VM (build 1.3.0_02, mixed mode)


      //////////////////////////////////////////////////////////////////////////////
      public class Test {
        public static void main(final String[] args) throws Exception {
          Thread t = new Thread() {

            public void run() {

      if (args.length > 0) {
      System.out.println("Thread.setName(" + args[0] + ")");
      setName(args[0]);
      }

      try {
      System.out.println("Waiting for a long, long time ...");
      Thread.sleep(Integer.MAX_VALUE);
      } catch (Throwable e) {
      e.printStackTrace();
      }
            }
          };
          t.start();
          t.join();
        }
      }
      //////////////////////////////////////////////////////////////////////////////

      aqua:akonstan> java -Xdebug -Xnoagent
      -Xrunjdwp:transport=dt_socket,address=5055,server=y,suspend=n Test "short name"
      Thread.setName(short name)
      Waiting for a long, long time ...

      //////////////////////////////////////////////////////////////////////////////
      aqua:akonstan> jdb -attach 5055
      Initializing jdb...
      main[1] threads
      Group system:
          (java.lang.ref.Reference$ReferenceHandler)0x6 Reference Handler cond. waiti
          (java.lang.ref.Finalizer$FinalizerThread)0x5 Finalizer cond. waiti
          (java.lang.Thread)0x4 Signal Dispatcher running
          (java.lang.Thread)0x3 CompileThread0 running
      Group main:
          (java.lang.Thread)0x1 main cond. waiti
          (Test$1)0x2 short name cond. waiti


      ///////////////////////////////////////////////////////////////////////////////

      aqua:akonstan> java -Xdebug -Xnoagent
      -Xrunjdwp:transport=dt_socket,address=5055,server=y,suspend=n Test "my thread
      with a very long long name (yes it sometimes make sense to have long names)"
      Thread.setName(my thread with a very long long name (yes it sometimes make sense
      to have long names))
      Waiting for a long, long time ...

      ///////////////////////////////////////////////////////////////////////////////

      aqua:akonstan> jdb -attach 5055
      Initializing jdb...
      main[1] threads
      Group system:
          (java.lang.ref.Reference$ReferenceHandler)0x6 Reference Handler
      Internal exception:
      java.lang.StringIndexOutOfBoundsException
      at java.lang.StringBuffer.insert(StringBuffer.java:811)
      at com.sun.tools.example.debug.tty.Commands.printThreadGroup(Commands.java:295)
      at com.sun.tools.example.debug.tty.Commands.commandThreads(Commands.java:303)
      at com.sun.tools.example.debug.tty.TTY.executeCommand(TTY.java:351)
      at com.sun.tools.example.debug.tty.TTY.<init>(TTY.java:625)
      at com.sun.tools.example.debug.tty.TTY.main(TTY.java:924)
      (Review ID: 119863)
      ======================================================================

            tbell Tim Bell
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: