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

AWT code relies on Swing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 5.0
    • client-libs
    • x86
    • solaris_9

      A DESCRIPTION OF THE REGRESSION :
      With a recent JDK1.6.0 bug, there was a curious looking stack trace. On the stack was references to javax.swing components that I have never instantiated, called, referenced, or desired to use. ((See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6393307 for a stack trace showing the dependency.)

      All I ever wanted to use was the AWT classes.

      Now I see that (some) swing classes have been included in the AWT core design. In jdk1.5, i now see that "javax/swing/plaf/basic/BasicLookAndFeel", and "javax/swing/event/DocumentListener" are loaded irrespective of my desires to have them. In JDK1.6.0, i see that "javax.swing.JPasswordField" is also included in the things that the AWT calls for.

      So exactly how do i remove SWING and still use the AWT?

      REPRODUCIBLE TESTCASE OR STEPS TO REPRODUCE:
      remove the javax.swing classes from RT.JAR. run a pure AWT application. I think any one of the non-swing demo programs that is distributed with the JDK will do. I think ArcTest.java will do nicely.


      RELEASE LAST WORKED:
      5.0

      RELEASE TEST FAILS:
      mustang-b72

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Somehow, i expected, if i were to remove javax.swing from RT.JAR, i would be still able to run my application. Apparently this is not so. I do not know how long this has been going on, but when researching, my impression is that an application has to instantiate the swing classes before there are brought to use.

      In any case, I would not have expected any references to swing to appear since the application did not specifically call upon those set of classes. I dont expect the AWT to do so either, since the awt and swing are alleged to be separate bodies of work.
      ACTUAL -
      for JDK1.5:
      -------------------------------------------------------
      Exception in thread "AWT-XAWT" java.lang.NoClassDefFoundError: javax/swing/plaf/basic/BasicLookAndFeel
              at sun.awt.X11.XToolkit.initUIDefaults(Unknown Source)
              at sun.awt.X11.XToolkit.run(Unknown Source)
              at java.lang.Thread.run(Unknown Source)
      Experimental: JNI_OnLoad called.
      SerialPort_NMEA:SerialPort_NMEA
      GpsData_Device: jGPS/GpsData/DeviceDrivers/SerialPort/SerialPort_NMEA.class
                      NoClassDefFoundError javax/comm/SerialPortEventListener
      GpsData_Device: ignoring jGPS/GpsData/DeviceDrivers/SerialPort/SerialPort_NMEA.class
      BinaryDriver.open(); Unable to open/locate /dev/ttyUSB0
      Exception in thread "main" java.lang.NoClassDefFoundError: javax/swing/event/DocumentListener
              at sun.awt.X11.XTextFieldPeer.<init>(Unknown Source)
              at sun.awt.X11.XToolkit.createTextField(Unknown Source)
      --------------------------------------------------------------------
      For jdk1.6, i'm sure that i can recreate same.

      OBSERVED APPLICATION IMPACT:
      On a recent jdk1.6, beta release, the unwanted swing components crashed the application. On jdk1.6 beta, for a month, it stopped all progress in testing.


      CUSTOMER PROVIDED WORKAROUND :
      Interestingly enough, when i posed my problem on the "comp.lang.java.programmer" list the following answer was provided by Mr. Tom H.
      the problem, as it turns out, was in the toolkit that u folks was trying to substitute for Motif et al. The solution was to not use the XToolkit ( ie export AWT_TOOLKIT=MToolkit)

            son Oleg Sukhodolsky (Inactive)
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: