JDK-4509039 : compiler rejects using of same named top-level and static nested
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2001-10-01
  • Updated: 2001-11-08
  • Resolved: 2001-11-08
Related Reports
Duplicate :  
Description

Name: ngR10089			Date: 10/01/2001


 
In the case when a top-level class and a static nested class, declared in 
another class from the same packade, have the same name, Java compiler 
jdk1.4.0beta3-b81 rejects or permits using of the top-level class 
depending on the order of references to these same named classes.

To reproduce the bug compile 3 sources below:

> javac -d . Actions.java CallableSystemAction.java ToolbarButton.java

After that the compilation of bad.java in which the reference to class using 
static nested class precedes the reference to top-level class reports an error.

> javac -d . bad.java
bad.java:7: cannot resolve symbol
symbol  : class ToolbarButton  
location: package awt
	core.awt.ToolbarButton b;
                ^
1 error
>

Another source file in which the reference to the top-level class precedes the 
reference to the class using static nested class is compiled successfully.

> javac -d . good.java
>

> java -version
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b81)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b81, mixed mode)


-----------------ToolbarButton.java------------------
package core.awt;

public class ToolbarButton  {
}
----------------------------------------------------
-----------------Actions.java------------------
package core.awt;

public class Actions {
	public static class ToolbarButton  {
	}
}
----------------------------------------------------
-----------------CallableSystemAction.java------------------
package core.util.actions;

import core.awt.*;

public class CallableSystemAction {
	Actions.ToolbarButton tb;
}
----------------------------------------------------
-----------------bad.java------------------
package t;

public class bad extends core.util.actions.CallableSystemAction {
}

class bad1 {
	core.awt.ToolbarButton b;
}
----------------------------------------------------
-----------------good.java------------------
package t;

class good1 {
	core.awt.ToolbarButton b;
}

public class good extends core.util.actions.CallableSystemAction {
}
----------------------------------------------------

======================================================================

Comments
EVALUATION A bug. ###@###.### 2001-10-02
02-10-2001