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

fatal exception when specified default look and feel does not exist

XMLWordPrintable

    • generic, x86
    • generic, windows_xp

      Name: rmT116609 Date: 04/22/2004


      FULL PRODUCT VERSION :
      java version "1.4.2_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
      Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)

      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

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

      A DESCRIPTION OF THE PROBLEM :
      When the property swing.defaultlaf is set to a class that does not exist, Java opens a dialog box saying "Java Virtual Machine Launcher: fatal exception occured. Program will exit" and exits. I think this should be considered a bug since a wrong setting at the command line or in a file should not crash Java.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a file called swing.properties and put it in <java_home>\lib. The file contains a line

      swing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeelx

      Please note the additional x. Clearly such a class is not present and therefor the above message appears. If I remove the trailing x everything works fine, of course

      or

      Open cmd.exe.

      Run SwingSet2 as follows:

      C:\tmpjava>java -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel -jar
      \j2sdk1.4.2_04\demo\jfc\SwingSet2\SwingSet2.jar

      -> works great!

      Now do the same once more, but notice the incorrect look and feel class:

      C:\tmpjava>java -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeelX -jar
      \j2sdk1.4.2_04\demo\jfc\SwingSet2\SwingSet2.jar
      Exception in thread "main" java.lang.Error: can't load javax.swing.plaf.metal.Me
      talLookAndFeelX
              at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1091)
              at javax.swing.UIManager.initialize(UIManager.java:1181)
              at javax.swing.UIManager.maybeInitialize(UIManager.java:1164)
              at javax.swing.UIManager.getUI(UIManager.java:775)
              at javax.swing.JPanel.updateUI(JPanel.java:104)
              at javax.swing.JPanel.<init>(JPanel.java:64)
              at javax.swing.JPanel.<init>(JPanel.java:87)
              at javax.swing.JPanel.<init>(JPanel.java:95)
              at SwingSet2.<init>(SwingSet2.java:191)
              at SwingSet2.main(SwingSet2.java:243)

      The same error occurs when you create the file swing.properties and put it to <java_home>\lib. Insert a line swing-defaultlaf=...

      SwingSet will work perfectly if the fully qualified classname after swing.defaultlauf= exists, otherwise Java crashes.

      The same behaviour can be seen under Tiger Beta1

      As I have already pointed out, in my humble opinion Java should not crash if a specified look and feel does not exist but use the default one that would be used if swing.defaultlaf was not specified by the user at all.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      If the specified class cannot be instantiated, Java should behave as if the property had not been set and use another default look and feel
      ACTUAL -
      Java opens a dialog box saying "Java Virtual Machine Launcher: fatal exception occured. Program will exit" and exits

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Java opens a dialog box saying "Java Virtual Machine Launcher: fatal exception occured. Program will exit" and exits

      REPRODUCIBILITY :
      This bug can be reproduced always.
      (Incident Review ID: 240832)
      ======================================================================

            Unassigned Unassigned
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: