United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4309057 Swing 1.1.1 uses a faulty test for JVM version PJAVA
JDK-4309057 : Swing 1.1.1 uses a faulty test for JVM version PJAVA

Details
Type:
Bug
Submit Date:
2000-02-01
Status:
Closed
Updated Date:
2000-10-27
Project Name:
JDK
Resolved Date:
2000-10-27
Component:
client-libs
OS:
windows_nt
Sub-Component:
javax.swing
CPU:
x86
Priority:
P4
Resolution:
Won't Fix
Affected Versions:
1.1.8
Fixed Versions:

Related Reports

Sub Tasks

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
EVALUATION

We are no longer providing unbundled releases of swing for 1.1.x releases of the JDK.
scott.violet@eng 2000-10-27
                                     
2000-10-27
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);
======================================================================
                                     
2004-06-11



Hardware and Software, Engineered to Work Together