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

javac accepts static import of methods with the same names and sigs

    Details

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

      Description



      Name: izR10247 Date: 01/20/2004



      Current 1.5.0-beta b32a compiler compiles sources
      which contain static imports of different static methods
      with the same names and signatures. This behavior contradicts
      Public Review Draft of "Importing Static Members in the Java
      Programming Language":

      "If two or more single-static-import declarations in the same compilation
      unit attempt to import methods with the same simple name and signature,
      then a compile-time error occurs."

      This failure affects the following JCK 1.5 lang test:

      lang/PKGS/pkgs057/pkgs05701.html

      To reproduce this bug please run following test using
      script below, note that b33 compiler also contains
      this bug:
      ================= MyTest.sh begin =====================
      #!/usr/bin/bash
      set -x
      uname -a

      JAVAC=/export/ld25/java/dest/jdk1.5.0-b32a/solaris-sparc/bin/javac
      $JAVAC -version -source 1.5 -d . A1.java
      $JAVAC -version -source 1.5 -d . A2.java
      $JAVAC -version -source 1.5 -d . MyTest.java
      ================= MyTest.sh end =======================
      ================= MyTest.java begin ===================
      package p;

      import static p1.A1.m;
      import static p2.A2.m;

      public class MyTest {

          public static void main(String argv[]) {
          }
      }
      ================= MyTest.java end =====================
      ================= A1.java begin =======================
      package p1;

      public class A1 {
          public static int m() {
              return 1;
          }
      }
      ================= A1.java end =========================
      ================= A2.java begin =======================
      package p2;

      public class A2 {
          public static int m() {
              return 1;
          }
      }
      ================= A2.java end =========================
      ================= MyTest output begin =================
      + JAVAC=/export/ld25/java/dest/jdk1.5.0-b32a/solaris-sparc/bin/javac
      + /export/ld25/java/dest/jdk1.5.0-b32a/solaris-sparc/bin/javac -version -source 1.5 -d . A1.java
      javac 1.5.0-beta
      + /export/ld25/java/dest/jdk1.5.0-b32a/solaris-sparc/bin/javac -version -source 1.5 -d . A2.java
      javac 1.5.0-beta
      + /export/ld25/java/dest/jdk1.5.0-b32a/solaris-sparc/bin/javac -version -source 1.5 -d . MyTest.java
      javac 1.5.0-beta
      ================= MyTest output end ===================
      ======================================================================

        Attachments

          Issue Links

            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: