Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4509039

compiler rejects using of same named top-level and static nested

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_8

      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 {
      }
      ----------------------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gafter Neal Gafter
              Reporter:
              nvgsunw Nvg Nvg (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: