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

javac permits subpackage and type declaration of the same name

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      kestrel
    • CPU:
      sparc
    • OS:
      solaris_7
    • Verification:
      Verified

      Description



      Name: ngC57085 Date: 10/13/99



      Java compiler jdk1.3.0J successfully compiles next JCK-122 test,
      checking existence of a subpackage and a type declaration of the same name,

      lang/PKGS/pkgs006/pkgs00604/pkgs00604.html

      instead of an error message:

      > java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-J)
      Java HotSpot (TM) Client VM (build 1.3-J, interpreted mode)

      > javac -d . pkgs00604c.java
      > javac -d . pkgs00604.java
      >

      Note that Java compiler jdk1.3.0I reports an error message:

      > java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-I)
      Java HotSpot (TM) Client VM (build 1.3-I, interpreted mode)

      > javac -d . pkgs00604c.java
      > javac -d . pkgs00604.java
      pkgs00604.java:22: javasoft.sqe.tests.lang.pkgs006.pkgs00604.pkgs00604a clashes
      with package of same name
      class pkgs00604a {
      ^
      1 error
      >

      -----------------pkgs00604c.java------------------
      //File: @(#)pkgs00604c.java 1.1 97/04/26
      //Copyright 04/26/97 Sun Microsystems, Inc. All Rights Reserved
       
      package javasoft.sqe.tests.lang.pkgs006.pkgs00604.pkgs00604a;


      public class pkgs00604c {
        public static int plus(int p1, int p2) {
           return p1+p2;
        }
      }
      ----------------------------------------------------
      -----------------pkgs00604.java------------------
      //File: @(#)pkgs00604.java 1.1 97/04/26
      //Copyright 04/26/97 Sun Microsystems, Inc. All Rights Reserved
       
      package javasoft.sqe.tests.lang.pkgs006.pkgs00604;

      import java.io.PrintStream;
      import javasoft.sqe.tests.lang.pkgs006.pkgs00604.pkgs00604a.*;

      public class pkgs00604 {
        public static void main(String argv[]) {
           System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
        }
        public static int run(String argv[],PrintStream out) {
           if ( pkgs00604a.sum (1,2) != 3 ) {
              out.println("failed");
              return 2/*STATUS_FAILED*/;
           }
           return 0/*STATUS_PASSED*/;
        }
      }

      class pkgs00604a {
        public static int sum(int p1, int p2) {
           return p1+p2;
        }
      }
      ----------------------------------------------------

      This is regression in Java compiler.

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

        Attachments

          Activity

            People

            Assignee:
            wmaddoxsunw William Maddox (Inactive)
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: