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

REGRESSION: Assertion failure in javax.swing.TransferHandler$TransferSupport.set

XMLWordPrintable

      A DESCRIPTION OF THE REGRESSION :
      When constructing certain Swing components, an assertion failure is caused. System assertions must be enabled (-esa) to see this, and if running under X, the DISPLAY environment variable must be set appropriately.

      The program below should create a JTextField and exit, but currently throws the assertion error.

      The problem appears to be caused by the initialisation of TransferHandler.DropHandler.support. That calls an otherwise unused constructor of TransferSupport with null arguments. The constructor then calls setDNDVariables.

      The constructor involved looks as if it is left over from DropHandler.support being recreating for every time handleDrag is called. A few lines of setDNDVariables. are worth noting:

                  assert event instanceof DropTargetDragEvent ||
                         event instanceof DropTargetDropEvent;
      ...
                  this.source = event;
      ...
                  if (source == null) {
                      return;
                  }

      It appears that the constructor involved should be replaced by a simple no-args version, and DropHandler.support initialised appropriately.

      (Note: this failure occurs on build 1.6.0-beta2-b77, but that is not available in the release combo.)

      REPRODUCIBLE TESTCASE OR STEPS TO REPRODUCE:
      class DNDAsserts {
          public static void main(String[] args) {
              new javax.swing.JTextField();
          }
      }

      Run with:

      java -esa DNDAsserts

      RELEASE LAST WORKED:
      5.0 Update 6

      RELEASE TEST FAILS:
      mustang-b72

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Creating Swing components should proceed without error.
      ACTUAL -
      Exception in thread "main" java.lang.AssertionError
              at javax.swing.TransferHandler$TransferSupport.setDNDVariables(TransferHandler.java:250)
              at javax.swing.TransferHandler$TransferSupport.<init>(TransferHandler.java:213)
              at javax.swing.TransferHandler$TransferSupport.<init>(TransferHandler.java:184)
              at javax.swing.TransferHandler$DropHandler.<init>(TransferHandler.java:1232)
              at javax.swing.TransferHandler$DropHandler.<init>(TransferHandler.java:1220)
              at javax.swing.TransferHandler.getDropTargetListener(TransferHandler.java:1036)
              at javax.swing.TransferHandler.access$200(TransferHandler.java:59)
              at javax.swing.TransferHandler$SwingDropTarget.<init>(TransferHandler.java:1135)
              at javax.swing.SwingUtilities.installSwingDropTargetAsNecessary(SwingUtilities.java:84)
              at javax.swing.JComponent.setTransferHandler(JComponent.java:3190)
              at javax.swing.plaf.basic.BasicTextUI.installDefaults2(BasicTextUI.java:279)
              at javax.swing.plaf.basic.BasicTextUI.installUI(BasicTextUI.java:687)
              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.text.JTextComponent.<init>(JTextComponent.java:305)
              at javax.swing.JTextField.<init>(JTextField.java:207)
              at javax.swing.JTextField.<init>(JTextField.java:148)
              at DNDAsserts.main(DNDAsserts.java:3)


      APPLICATION NAME: jEdit APPLICATION VERSION: 4.2final

      OBSERVED APPLICATION IMPACT:
      Minimal.

      End user applications are rarely run with system asserts enabled. However, if an application is run with -esa and hides error output, it may cause a mysterious. jEdit, for instance, gets stuck at the splash screen.

      Developers will need to use -esa -da:javax.swing.TransferHandler to check for further system asserts in Swing applications.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: