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

Null pointer exception with 107078-12 patch in SwingWorker

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 1.3.0
    • client-libs



      Name: rlT66838 Date: 08/25/99


      I'm seeing an intermittent null pointer exception when I run a
      program which uses the SwingWorker class from The Swing Connection
      web site:

        http://java.sun.com/products/jfc/tsc/archive/tech_topics_arch/swing_worker/SwingWorker.java

      It doesn't matter which compiler I've used: I tried javac from
      JDK 1.2.2 and JDK 1.3, and jikes. The problem only occurs when I
      use the JDK 1.3 java with HotSpot. It doesn't happen with the
      JDK 1.2.2 java, nor JDK 1.3 java with the -classic flag, nor JDK
      1.1.8.

      It only happens *sometimes* with JDK 1.3. Here's a transcript of
      some attempts showing three failures and one success:

      tiffany> /opt4/jdk1.3/bin/java WorkerBug
      java.lang.NullPointerException
              at WorkerBug.access$000(WorkerBug.java:5)
              at WorkerBug$MyWorker.construct(WorkerBug.java:34)
              at SwingWorker$2.run(SwingWorker.java:101)
              at java.lang.Thread.run(Thread.java:479)
      tiffany> /opt4/jdk1.3/bin/java WorkerBug
      java.lang.NullPointerException
              at WorkerBug.access$000(WorkerBug.java:5)
              at WorkerBug$MyWorker.construct(WorkerBug.java:34)
              at SwingWorker$2.run(SwingWorker.java:101)
              at java.lang.Thread.run(Thread.java:479)
      tiffany> /opt4/jdk1.3/bin/java WorkerBug
      Hello world
      tiffany> /opt4/jdk1.3/bin/java WorkerBug
      java.lang.NullPointerException
              at WorkerBug.access$000(WorkerBug.java:5)
              at WorkerBug$MyWorker.construct(WorkerBug.java:34)
              at SwingWorker$2.run(SwingWorker.java:101)
              at java.lang.Thread.run(Thread.java:479)
      tiffany>

      And here's the program:

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

      public class WorkerBug extends JFrame {
          private String query ;

          public WorkerBug() {
              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 void doSomething() {
              query = "Hello world" ;
              new MyWorker() ;
          }

          public static void main(String s[]) {
              WorkerBug wb = new WorkerBug() ;
              wb.doSomething() ;
          }

          private class MyWorker extends SwingWorker {
              public Object construct() {
                  System.out.println(query) ;
                  return query ;
              }
          }
      }

      And the JVM version:

      tiffany> /opt4/jdk1.3/bin/java -version
      java version "1.3beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
      Java(TM) HotSpot Client VM (build 1.3beta-O-release, 1.3beta-O-release, interpreted mode)
      tiffany> /opt4/jdk1.3/bin/java -fullversion
      java full version "1.3beta-O"
      tiffany>
      (Review ID: 94362)
      ======================================================================

            sswingtrsunw Swingtraq Swingtraq (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: