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

type declaration and subpackage of the same name are permited

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: ngC57085 Date: 04/26/97



      Java compiler (JDK1.1.2) permits a package to contain a type declaration and a subpackage of the same name.

      JLS (7.1) says:

      "
      A package may not contain a type declaration and a subpackage of the same name,
      or a compile-time error results.
      "

      Next test is successfully compiled by jdk instead of error message.

      > javac -d . pkgs00602c.java
      > javac -d . pkgs00602.java
      > java -verify javasoft.sqe.tests.lang.pkgs006.pkgs00602.pkgs00602
      > echo $status
      95
      >

      ------------------------pkgs00602c--------------
      package javasoft.sqe.tests.lang.pkgs006.pkgs00602.pkgs00602a;

      public class pkgs00602c {
        public static int plus(int p1, int p2) {
           return p1+p2;
        }
      }
      --------------------------------------
      ------------------------pkgs00602--------------
      package javasoft.sqe.tests.lang.pkgs006.pkgs00602;

      import java.io.PrintStream;
      import javasoft.sqe.tests.lang.pkgs006.pkgs00602.pkgs00602a.pkgs00602c;

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

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


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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: