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

javac cannot distinguish the same name for a class and a package.

    XMLWordPrintable

Details

    • sparc
    • generic

    Description

      The following mail sent to javabugs describes the problem completely -
      I've verified the results.


      >From: Gerald Vogt <###@###.###>
      This does not look like form output to me.

      BUG REPORT JDK 1.0.2 javac Solaris 2.4 Sparc

      javac cannot distinguish the same name for a class and a package. If
      there is a class compiled with the same name as a package the
      definitions in the package are not accessable.

      Example: 3 files

      ---- node.java

      package my.test;

      public class node {
          public static final int AB = 0;
      }

      ---- test.java

      package my;

      public class test
      {
      }

      ---- t.java

      class Main {
        public static void main (String args[])
        {
          System.out.println("AB is " + my.test.node.AB);
        }
      }

      ----

      Compile with:

        setenv CLASSPATH ./classes
        javac -d classes node.java
        javac -d classes test.java
        javac -d classes t.java

      The last statement prints the following error:

      t.java:4: No variable node defined in class my.test.
          System.out.println("AB is " + my.test.node.AB);

      --
      Gerald Vogt E-Mail: ###@###.###
      WWW: <http://www.isa.de/~vogt>
      PGP pubkey at keyservers or via WWW!

      Attachments

        Activity

          People

            tturnidgsunw Todd Turnidge (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: