Java Technology Home Page
Help PagesA-Z Index

Java Developer Connection(SM)
Bug Database

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide


Top 25 Bugs

Top 25 RFE's

Recently Closed Bugs

Bug Parade Home



  Bug Watch
 


Bug Votes

Empty Vote
Empty Vote
Empty Vote

This bug is closed. You cannot vote for it.

To clear a vote, click a radio button and

Bug Id 4309057
Votes 0
Synopsis Swing 1.1.1 uses a faulty test for JVM version PJAVA
Category java:classes_swing
Reported Against 1.1.8
Release Fixed  
State Closed, will not be fixed
Related Bugs  
Submit Date Feb 01, 2000
Description




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)


webbug aw
Workaround




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);

Evaluation
We are no longer providing unbundled releases of swing for 1.1.x releases of
the JDK.
xxxxx@xxxxx 2000-10-27
Your Comments & Work-arounds

Include a link with my name & email   

SAT AUG 11 10:46 A.M. 2001
theforken

It really works !!
Just for the beginners :
1) Extract the src.zip (from the swing-1.1.1fcs 
distribution)
2) in javax/swing you'll find the SwingUtilities.java file
3) Open it your favorite editor
4) Comment line 677 Method m = Class.class.getMethod
("getProtectionDomain", null);
5) Insert the line Method m = Class.class.getMethod
("getPackage", null); just after the old one.
6) Save and compile.
7) Copy the Swingall.jar archive in the root of the 
exstracter src.zip (ie the same level of the javax and com 
dirs).
8) Jarize it (jar uvf swingall.jar 
javax\swing\SwingUtilities.class)

Have fun with Swing

Erik

WED AUG 29 02:33 A.M. 2001
Alexander123
>We are no longer providing unbundled releases of swing for
>1.1.x releases of the JDK.

Actually, you are - 
http://java.sun.com/products/jfc/download.html

It would be so easy to fix this bug and post the new 
swingall.jar, please, please do so!

WED AUG 29 01:35 P.M. 2001
rgc3679
Yes, I agree with Alexander - please make this simple change
and distribute.

Thanks Erik - the work around works great. It's cool to run
Swing apps on the iPAQ!

--BobC

WED NOV 28 05:14 P.M. 2001
Angeliqueeee
Thanks heaps for this post Eric!!  Helped me get my program 
swinging! :) 



Print Button
[ This page was updated: 8-Apr-2002 ]
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary | Help Pages
For answers to common questions and further contact
information please see the java.sun.com Help Pages.

Unless otherwise licensed, code in all technical materials herein
(including articles, FAQs, samples) is provided under this License.
Sun Microsystems, Inc.
Copyright © 1995-2002 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.