JDK-6618285 : Compiler does not recognize NimbusLookAndFeel() class
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u5
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-10-17
  • Updated: 2011-02-16
  • Resolved: 2007-12-12
Related Reports
Duplicate :  
Description
Reproducible on Solaris & XP. The following code cannot be compiled. Compiler complains NimbusLookAndFeel cannot be found.

import sun.swing.plaf.nimbus.NimbusLookAndFeel;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import com.sun.java.swing.plaf.motif.MotifLookAndFeel;
import javax.swing.*;

public class NimbusTest extends JFrame {

  public NimbusTest() {
    try {
      UIManager.setLookAndFeel(new NimbusLookAndFeel());
      setDefaultCloseOperation(EXIT_ON_CLOSE);

      JButton b1= new JButton();
      b1.setText("Button 1");
      getContentPane().add(b1, java.awt.BorderLayout.CENTER);

      pack();

    } catch (UnsupportedLookAndFeelException e) {
      e.printStackTrace();
    }
  }

  public static void main(String[] args) {
    java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
        new NimbusTest().setVisible(true);
      }
    });
  }
}

Error message:
NimbusTest.java:3: package sun.swing.plaf.nimbus does not exist
import sun.swing.plaf.nimbus.NimbusLookAndFeel;
                            ^
NimbusTest.java:12: cannot find symbol
symbol  : class NimbusLookAndFeel
location: class NimbusTest
      UIManager.setLookAndFeel(new NimbusLookAndFeel());

This is reproducible with 6u5b04 & b05.

Comments
EVALUATION We have moved Nimbus to com.sun.java.swing.plaf.nimbus package in bug 6616742 and excluded it from blocked packages list for the compiler. This is fix this restriction and allow code to access classes in the Nimbus package.
12-12-2007

EVALUATION Igor had the key: use this switch to compile: -XDignore.symbol.file trying to compile with dependencies on sun.swing used to produce warnings, whereas at the moment it appears to produce errors. Will investigate to see how we can just have warnings for nimbus.
13-11-2007

EVALUATION Very strange indeed! When I saw this bug, I decided to check it out since, obviously, it must be possible to close this bug as "Works for me", right? Well, strangely enough, that is not the case. If I modify the example to execute this code: for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { System.out.println("Name=" + laf.getName() + ", class=" + laf.getClassName()); } Then it prints out: Name=Metal, class=javax.swing.plaf.metal.MetalLookAndFeel Name=Nimbus, class=sun.swing.plaf.nimbus.NimbusLookAndFeel Name=CDE/Motif, class=com.sun.java.swing.plaf.motif.MotifLookAndFeel Name=GTK+, class=com.sun.java.swing.plaf.gtk.GTKLookAndFeel Ok, so next step is to determine whether NimbusLookAndFeel is actually in the jar. So I run: bash-3.00$ jar -tvf rt.jar | grep sun/swing/plaf/nimbus/NimbusLookAndFeel 817 Wed Oct 31 02:26:02 CST 2007 sun/swing/plaf/nimbus/NimbusLookAndFeel$1.class 2088 Wed Oct 31 02:26:02 CST 2007 sun/swing/plaf/nimbus/NimbusLookAndFeel.class Ok, last thing I can think of is that NimbusLookAndFeel is package private. So I tried putting NimbusTest in the sun/swing/plaf/nimbus package: bash-3.00$ jdk1.6.0_05/bin/javac -sourcepath src src/sun/swing/plaf/nimbus/NimbusTest.java src/sun/swing/plaf/nimbus/NimbusTest.java:15: cannot find symbol symbol : class NimbusLookAndFeel location: class sun.swing.plaf.nimbus.NimbusTest UIManager.setLookAndFeel(new NimbusLookAndFeel()); ^ 1 error So this is a very interesting error. Also interesting that we don't have this problem locally. All our demo and test apps seem to run fine. I downloaded the JDK from the Java 6 update N ea site.
13-11-2007

EVALUATION This sounds very strange, because Nimbus was integrated to 6u5 b02 assigned to Nimbus team
22-10-2007