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

Unexpected null pointer exception

XMLWordPrintable

    • sparc
    • solaris_7



      Name: dkC59003 Date: 12/21/99



      HotSpot Kestrel 1.3fcs-R (Solaris) fails the test nsk/regression/b4265661 from
      testbase_nsk. An unexpected NullPointerException occurs.
      Classic passes the test.

      Log and test sources follow:

      $ java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-R)
      Java HotSpot(TM) Client VM (build 1.3-R, interpreted mode)
      $ java b4265661
      Font specified in font.properties not found [-monotype-courier
      new-regular-r---*-%d-*-*-m-*-iso8859-1]
      ...
      Font specified in font.properties not found [-monotype-courier
      new-regular-r---*-%d-*-*-m-*-iso8859-1]
      Warning: Cannot convert string "crc-12" to type FontStruct
      java.lang.NullPointerException
              at b4265661.access$100(b4265661.java:9)
              at b4265661$MyWorker.construct(b4265661.java:46)
              at b4265661_sw$1.run(b4265661_sw.java:24)
              at java.lang.Thread.run(Thread.java:484)

      ---------------------------------------------------------------------- b4265661.java
      // File: @(#)b4265661.java 1.1 99/09/09
      // Copyright 09/09/99 Sun Microsystems, Inc. All Rights Reserved

      import java.io.PrintStream;
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class b4265661 extends JFrame {
          private String query ;

          public b4265661() {
              JPanel panel = new JPanel() ;

              addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                      System.exit(0);
                  }
              });

              getContentPane().add(panel) ;
              setBounds(200, 200, 640, 480);
              setVisible(true);
          }

          public MyWorker doSomething() {
              query = "Hello world";
              return new MyWorker();
          }

          public static void main(String argv[]) {
      System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
          }

          public static int run(String argv[], PrintStream out) {
              b4265661 wb = new b4265661();
      MyWorker mw = wb.doSomething();
      while (! mw.flag) {}
      if (mw.getValue() == null)
      return 2/*STATUS_FAILED*/;
      return 0/*STATUS_PASSED*/;
          }

          private class MyWorker extends b4265661_sw {
              public Object construct() {
                  System.out.println(query) ;
                  return query ;
              }
          }
      }
      --------------------------------------------------------------------- b4265661_sw.java
      // File: @(#)b4265661_sw.java 1.1 99/09/09
      // Copyright 09/09/99 Sun Microsystems, Inc. All Rights Reserved

      public abstract class b4265661_sw {
          public boolean flag = false;
          private Object value; // see getValue(), setValue()
          private Thread thread;

          protected synchronized Object getValue() {
      return value;
          }

          private synchronized void setValue(Object x) {
      value = x;
          }

          public abstract Object construct();

          public b4265661_sw() {

              Runnable doConstruct = new Runnable() {
                  public void run() {
                      try {
                          setValue(construct());
                      }
                      finally {
                          flag = true;
                      }

                  }
              };

              Thread t = new Thread(doConstruct);
              t.start();
          }
      }

      ======================================================================

            smitrovisunw Srdjan Mitrovic (Inactive)
            dkhukhrosunw Dmitry Khukhro (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: