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

single static import and a top level type with the same name allowed

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      rc
    • CPU:
      generic
    • OS:
      generic

      Description

      Name: izR10247 Date: 09/24/2003



      The Static import specification (JSR 201, draft of 08 Sep, 2003)
      Section "Full Proposal" reads:
      "If a single-static-import declaration imports a member whose simple
       name is n, and the compilation unit also declares a top level type
       whose simple name is n, a compile-time error occurs."

      However, a compile-time error does not occur for the
      described situation when current 1.5.0-b20 implementation
      of J2SE is used.
       
      To reproduce this bug please run the following test
      using Make.sh shell script:
      --------------- A.java source begin -----------------
      package p;

      public class A {

          public static int f = 4;
          public static int m() {
              return 5;
          }
      }
      --------------- A.java source end -----------------
      --------------- Test.java begin -----------------
      import static p.A.f;

      public class Test {

          public static void main(String argv[]) {

              System.exit(0);
          }
      }

      class f {
      }
      --------------- Test.java end -----------------
      --------------- Make.sh begin -----------------
      #!/bin/sh
      JDK=/export/ld25/java/dest/jdk1.5.0/solaris-sparc
      CLASSPATH=./:./p1:./p2
      uname -a
      echo 'Version:'
      $JDK/bin/java -version
      echo 'Compilation begin'
      $JDK/bin/javac -classpath $CLASSPATH -d . -source 1.5 A.java
      $JDK/bin/javac -classpath $CLASSPATH -d . -source 1.5 Test.java
      echo 'Compilation end'
      echo 'Running Test'
      $JDK/bin/java -classpath $CLASSPATH Test
      --------------- Make.sh end -----------------
      --------------- Make.sh output begin ----------------
      bash-2.03$ ./Make.sh
      SunOS novo148 5.8 Generic_108528-20 sun4u sparc SUNW,Ultra-80
      Version:
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b20)
      Java HotSpot(TM) Server VM (build 1.5.0-beta-b20, mixed mode)
      Compilation begin
      Compilation end
      Running Test
      --------------- Make.sh output end ----------------

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

        Attachments

          Activity

            People

            Assignee:
            gbrachasunw Gilad Bracha (Inactive)
            Reporter:
            garysunw Gary Gary (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: