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

REGRESSION: JPasswordField NPEs if PL&F does not define

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux, solaris_2.5.1

      Description

      A DESCRIPTION OF THE REGRESSION :
      (Note: This code fails on mustang-b74, but that option is not available on this form.)

      For PL&F that do not define PasswordField.echoChar, a NullPointerException is thrown during construction of the component. In particular this affects XAWT.

      It appears that the fix for Bug 4985353 'XP and metal L&F: JPasswordField echo character should be DOT and not "*"' caused this regression.

      The two programs below demonstrate the problem.

      The first examples removes the property, showing the problem directly.

      The second example, when under XAWT, shows the problem with AWT TextFields. The XAWT peer/PL&F implementation has not had the property added .This program should run fine under Windows, MToolkit and most other toolkits).

      REPRODUCIBLE TESTCASE OR STEPS TO REPRODUCE:
      import javax.swing.JPasswordField;
      import javax.swing.UIManager;

      public class SimpleSwing {

          public static void main(String[] args) throws Exception {
              java.awt.EventQueue.invokeLater(new Runnable() { public void run() {
                          UIManager.getDefaults().remove("PasswordField.echoChar");
                          new JPasswordField("Text field");
              }});
          }
      }




      import java.awt.*;

      public class SimpleApp {
          public static void main(String[] args) {
              EventQueue.invokeLater(new Runnable() { public void run() {
                          TextField field = new TextField("Text field");
                          Frame frame = new Frame("XAWT text field");
                          frame.add(field);
                          frame.setSize(100, 100);
                          frame.setVisible(true);
              }});
          }
      }

      RELEASE LAST WORKED:
      5.0 Update 6

      RELEASE TEST FAILS:
      mustang-b72

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The first program should run and exit. The second program should open a small window with a text field.
      ACTUAL -
      $ java SimpleSwing
      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
              at javax.swing.JPasswordField.customSetUIProperty(JPasswordField.java:337)
              at javax.swing.LookAndFeel.installProperty(LookAndFeel.java:150)
              at javax.swing.plaf.basic.BasicPasswordFieldUI.installDefaults(BasicPasswordFieldUI.java:58)
              at javax.swing.plaf.basic.BasicTextUI.installUI(BasicTextUI.java:686)
              at javax.swing.plaf.basic.BasicTextFieldUI.installUI(BasicTextFieldUI.java:57)
              at javax.swing.JComponent.setUI(JComponent.java:613)
              at javax.swing.text.JTextComponent.setUI(JTextComponent.java:321)
              at javax.swing.text.JTextComponent.updateUI(JTextComponent.java:331)
              at javax.swing.JPasswordField.updateUI(JPasswordField.java:143)
              at javax.swing.text.JTextComponent.<init>(JTextComponent.java:305)
              at javax.swing.JTextField.<init>(JTextField.java:207)
              at javax.swing.JPasswordField.<init>(JPasswordField.java:116)
              at javax.swing.JPasswordField.<init>(JPasswordField.java:74)
              at SimpleSwing$1.run(SimpleSwing.java:9)
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
              at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

      $ java SimpleApp
      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
              at javax.swing.JPasswordField.customSetUIProperty(JPasswordField.java:337)
              at javax.swing.LookAndFeel.installProperty(LookAndFeel.java:150)
              at javax.swing.plaf.basic.BasicPasswordFieldUI.installDefaults(BasicPasswordFieldUI.java:58)
              at javax.swing.plaf.basic.BasicTextUI.installUI(BasicTextUI.java:686)
              at javax.swing.plaf.basic.BasicTextFieldUI.installUI(BasicTextFieldUI.java:57)
              at sun.awt.X11.XTextFieldPeer$AWTTextFieldUI.installUI(XTextFieldPeer.java:493)
              at javax.swing.JComponent.setUI(JComponent.java:613)
              at sun.awt.X11.XTextFieldPeer$XAWTTextField.updateUI(XTextFieldPeer.java:660)
              at javax.swing.text.JTextComponent.<init>(JTextComponent.java:305)
              at javax.swing.JTextField.<init>(JTextField.java:207)
              at javax.swing.JPasswordField.<init>(JPasswordField.java:116)
              at javax.swing.JPasswordField.<init>(JPasswordField.java:74)
              at sun.awt.X11.XTextFieldPeer$XAWTTextField.<init>(XTextFieldPeer.java:604)
              at sun.awt.X11.XTextFieldPeer.<init>(XTextFieldPeer.java:59)
              at sun.awt.X11.XToolkit.createTextField(XToolkit.java:757)
              at java.awt.TextField.addNotify(TextField.java:205)
              at java.awt.Container.addNotify(Container.java:2500)
              at java.awt.Window.addNotify(Window.java:528)
              at java.awt.Frame.addNotify(Frame.java:479)
              at java.awt.Window.show(Window.java:711)
              at java.awt.Component.show(Component.java:1406)
              at java.awt.Component.setVisible(Component.java:1359)
              at java.awt.Window.setVisible(Window.java:694)
              at SimpleApp$1.run(SimpleApp.java:10)
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
              at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)


      APPLICATION NAME: Roedy Green's "Fast File Finder" applet <http://mindprod.com/projects/filefinde&gt;OBSERVED APPLICATION IMPACT:
      This will brakes any application/applet using AWT TextField under XAWT, or using JPasswordField that has not been updated for the fix to Bug 4985353.

      Not good.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                shickeysunw Shannon Hickey (Inactive)
                Reporter:
                ttzhang Tao Zhang
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: