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

JRE1.6.0_12 calling JTextComponent.getText() from isValid() throw exception:null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 6u10
    • client-libs
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      Java Plug-in 1.6.0_12
      Using JRE version 1.6.0_12 Java HotSpot(TM) Client VM

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      After migrating to JRE 1.6.0 update 12 plugin, swing related code in our application fails with exception: null - Null PointerException.

      This code was working till Jave plugin 1.6.0 update 11.
      basic: exception: null.
      java.lang.NullPointerException
      at javax.swing.text.JTextComponent.getText(Unknown Source)
      at UtilTextField.isValid(TestApplet.java:20)
      at java.awt.Component.invalidateIfValid(Unknown Source)
      at java.awt.Component.setLocale(Unknown Source)
      at javax.swing.JComponent.<init>(Unknown Source)
      at javax.swing.text.JTextComponent.<init>(Unknown Source)
      at javax.swing.JTextField.<init>(Unknown Source)
      at UtilTextField.<init>(TestApplet.java:17)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Provided simplified source code which could reproduce the problem.
      Just launch the html file which would inturn load the applet containing the problematic code. By using java plugin 1.6.0_12, the applet will fail to launch and in java console you should be able to see the exception.

      Trying the same in Java plugin 1.6.0_11 and earlier works fine without any issues.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The same piece of code should work on new plugins as well.
      While launching the sample html file provided with this report, an applet will be loaded with just a textfield present in it.
      ACTUAL -
      The html page shows "Error. click for details"
      In the java console, exception stack trace is seen

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Console log:
      Java Plug-in 1.6.0_12
      Using JRE version 1.6.0_12 Java HotSpot(TM) Client VM
      User home directory = C:\Documents and Settings\vmarimuthu

      ----------------------------------------------------
      c: clear console window
      f: finalize objects on finalization queue
      g: garbage collect
      h: display this help message
      l: dump classloader list
      m: print memory usage
      o: trigger logging
      q: hide console
      r: reload policy configuration
      s: dump system and deployment properties
      t: dump thread list
      v: dump thread stack
      x: clear classloader cache
      0-5: set trace level to <n>
      ----------------------------------------------------

      security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.
      security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.javaws
      security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.javaws
      security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.javaws,com.sun.deploy
      security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.javaws,com.sun.deploy
      security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
      security: property package.definition value null
      security: property package.definition new value com.sun.javaws
      security: property package.definition value com.sun.javaws
      security: property package.definition new value com.sun.javaws,com.sun.deploy
      security: property package.definition value com.sun.javaws,com.sun.deploy
      security: property package.definition new value com.sun.javaws,com.sun.deploy,com.sun.jnlp
      security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
      security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
      security: property package.definition value com.sun.javaws,com.sun.deploy,com.sun.jnlp
      security: property package.definition new value com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
      basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@df8f5e
      basic: exception: null.
      java.lang.NullPointerException
      at javax.swing.text.JTextComponent.getText(Unknown Source)
      at UtilTextField.isValid(TestApplet.java:20)
      at java.awt.Component.invalidateIfValid(Unknown Source)
      at java.awt.Component.setLocale(Unknown Source)
      at javax.swing.JComponent.<init>(Unknown Source)
      at javax.swing.text.JTextComponent.<init>(Unknown Source)
      at javax.swing.JTextField.<init>(Unknown Source)
      at UtilTextField.<init>(TestApplet.java:17)
      at TestApplet.<init>(TestApplet.java:7)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at java.lang.Class.newInstance0(Unknown Source)
      at java.lang.Class.newInstance(Unknown Source)
      at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
      at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
      Exception: java.lang.NullPointerException



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Source code:
      ------------------
      import javax.swing.JApplet;
      import javax.swing.JPanel;
      import javax.swing.JTextField;
      import javax.swing.text.PlainDocument;

      public class TestApplet extends JApplet {
      private JTextField fName = new UtilTextField();
      public void init() {
      JPanel content = new JPanel();
      content.add(fName);
      setContentPane(content);
      }
      }

      class UtilTextField extends JTextField{
      public UtilTextField(){
      super(new PlainDocument(), "", 10);
      }
      public boolean isValid(){
      String textStr = getText();
      //...we are analysing textStr to decide the return value
      return true;
      }
      }


      HTML file:
      -------------
      <HTML>
       <HEAD>
        <TITLE> Test JText component </TITLE>
       </HEAD>
      <applet code="TestApplet.class" archive="test.jar">
      </HTML>

      ---------- END SOURCE ----------

      Release Regression From : 6u12
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            anthony Anthony Petrov (Inactive)
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: