JDK-4309057 : Swing 1.1.1 uses a faulty test for JVM version PJAVA
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.8
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2000-02-01
  • Updated: 2000-10-27
  • Resolved: 2000-10-27
Description

Name: skT88420			Date: 02/01/2000


pjava.exe version "3.1"

PersonalJava 3.1 introduces JDK1.2 security APIs into the JDK 1.1.8 base API
set.  Swing 1.1.1 happens to test for the existence of 1.2 security APIs in
order to determine what JVM version it is running under.  This test succeeds
and Swing believes it is running in a 1.2 JVM, but it is not - pJava 3.1 is
1.1.8 based with only 1.2 security APIs added.

The test is in javax.swing.SwingUtilities.  It tests for
Class.getProtectionDomain which is a 1.2 API.  However this API was also
introduced into pJava 3.1.

    static {
        try {
            // Test if method introduced in 1.2 is available.
            Method m = Class.class.getMethod("getProtectionDomain", null);
            is1dot2 = (m != null);
        } catch (NoSuchMethodException e) {
            is1dot2 = false;
        }

        // Warn if running wrong version of this class for this JDK.





          if (is1dot2) {
              System.err.println("warning: running 1.1 version of
SwingUtilities");
          }

    }


Running a simple Swing application under pJava 3.1 results in this exception:

warning: running 1.1 version of SwingUtilities
java.lang.NoSuchFieldException
        at java.lang.Class.getField()
        at javax.swing.KeyStroke.getKeyStroke()
        at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults()
        at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults()
        at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults()
        at javax.swing.UIManager.setLookAndFeel()
        at javax.swing.UIManager.setLookAndFeel()
        at javax.swing.UIManager.initializeDefaultLAF()
        at javax.swing.UIManager.initialize()
        at javax.swing.UIManager.maybeInitialize()
        at javax.swing.UIManager.getUI()
        at javax.swing.JButton.updateUI()
        at javax.swing.AbstractButton.init()
        at javax.swing.JButton.<init>()
        at javax.swing.JButton.<init>()
        at SwingTest.main() 
java.lang.Error: Unrecognized keycode name: VK_KP_LEFT
        at javax.swing.KeyStroke.getKeyStroke()
        at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults()
        at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults()
        at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults()
        at javax.swing.UIManager.setLookAndFeel()
        at javax.swing.UIManager.setLookAndFeel()
        at javax.swing.UIManager.initializeDefaultLAF()
        at javax.swing.UIManager.initialize()
        at javax.swing.UIManager.maybeInitialize()
        at javax.swing.UIManager.getUI()
        at javax.swing.JButton.updateUI()
        at javax.swing.AbstractButton.init()
        at javax.swing.JButton.<init>()
        at javax.swing.JButton.<init>()
        at SwingTest.main()
(Review ID: 100654) 
======================================================================

Comments
WORK AROUND Name: skT88420 Date: 02/01/2000 I fixed the problem by changing SwingUtilites to test for Class.getPackage which is 1.2 specific and has not been introduced to pJava: Method m = Class.class.getMethod("getPackage", null); ======================================================================
11-06-2004

EVALUATION We are no longer providing unbundled releases of swing for 1.1.x releases of the JDK. scott.violet@eng 2000-10-27
27-10-2000