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

(thread) Thread.getStackTrace() returns null

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 5.0, 6u2
    • Fix Version/s: 7
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b16
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Not verified

      Backports

        Description

        With the following test program, NullPointerException will be
        thrown. That is not in line with the API.
        http://java.sun.com/javase/6/docs/api/java/lang/Thread.html#getStackTrace()

        TP:
        ----->
        public class STNull {
          public static void main(String[] args) throws Exception {
            while(true) {
              Thread t = new Thread();
              t.start();
              StackTraceElement[] stes = t.getStackTrace();
              System.out.println(stes.length);
            }
          }
        }
        <-----

        One of our customers reported NPE would be seen on Linux/EM64T below.

        ----->
        java version "1.5.0_12"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
        Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_12-b04, mixed mode)

        java version "1.6.0_02"
        Java(TM) SE Runtime Environment (build 1.6.0_02-b04)
        Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_02-b04, mixed mode)

        java version "1.7.0-ea"
        Java(TM) SE Runtime Environment (build 1.7.0-ea-b13)
        Java HotSpot(TM) 64-Bit Server VM (build 1.7.0-ea-b13, mixed mode)
        <-----

        I also reproduced this against both jdk 5.0 and jdk 6.0 on my Windows
        XP laptop as follows.

        ----->
        $ java -version
        java version "1.5.0_10"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
        Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing)

        $ java STNull
        0
        0
        0
        0
        0
        Exception in thread "main" java.lang.NullPointerException
                at STNull.main(STNull.java:7)

        $ /g/jdk60/bin/java -version
        java version "1.6.0"
        Java(TM) SE Runtime Environment (build 1.6.0-b105)
        Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode)

        $ /g/jdk60/bin/java STNull
        0
        0
        0
        0
        0
        0
        0
        0
        Exception in thread "main" java.lang.NullPointerException
                at STNull.main(STNull.java:7)
        <-----

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                chegar Chris Hegarty
                Reporter:
                xiaojuzh Xiaojun Zhang (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: