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

static import on demand of members with the same simple name allowed

    XMLWordPrintable

Details

    • rc
    • generic
    • generic

    Description



      Name: izR10247 Date: 09/24/2003



      The Static import specification (JSR 201, draft of 08 Sep, 2003)
      Section "Full Proposal" reads:"
      Otherwise, if a type of that name is declared by more than one
      type-import-on-demand declaration of the compilation unit
      containing the Identifier, or a member of that name is declared by
      more than one static-import-on-demand declaration of that
      compilation unit, or a type of that name is declared by a
      type-import-on-demand declaration of that compilation unit
      and a member of that name is declared by a static-import-on-demand
      declaration of that compilation unit, then 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 p1;

      public class A {

          public static int f = 10;
          public static int m() {
              return 1;
          }
      }
      --------------- A.java source end -----------------
      --------------- B.java source begin -----------------
      package p2;

      public class B {

          public static int f = 10;
          public static long m() {
              return 2;
          }
      }
      --------------- B.java source end -----------------
      --------------- Test.java begin -----------------
      import static p1.A.*;
      import static p2.B.*;

      public class Test {

          public static void main(String argv[]) {

              System.out.println("m=" + m());
              System.exit(0);
          }
      }
      --------------- 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 B.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
      m=1
      --------------- Make.sh output end ----------------

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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: