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

Incorrect error message for ambiguous single static import

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 5.0
    • tools
    • b37
    • generic
    • generic
    • Verified

      Name: izR10247 Date: 01/20/2004



      1.5.0-beta b33 compiler generates incorrect
      error message while it tries to compile source
      which contains ambiguous static import of the different
      static fields with the same names. This message states
      that static member is already defined in a single-type import
      declaration whereas there are no such declarations in the
      source. This bug is revealed by the following
      JCK 1.5 lang test:

      lang/PKGS/pkgs057/pkgs05702.html

      To reproduce this bug please run following test using
      script below, note that b32a compiler also contains
      this bug:


      ================= MyTest.sh begin =====================
      #!/usr/bin/bash
      set -x
      uname -a

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

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

      public class MyTest {

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

      public class A1 {
          static public int f = 6;
      }
      ================= A1.java end =========================
      ================= A2.java begin =======================
      package p2;

      public class A2 {
          static public int f = 6;
      }
      ================= A2.java end =========================
      ================= MyTest output begin =================
      + uname -a
      SunOS novo148 5.8 Generic_108528-20 sun4u sparc SUNW,Ultra-80
      + JAVAC=/export/ld25/java/dest/jdk1.5.0-b33/solaris-sparc/bin/javac
      + /export/ld25/java/dest/jdk1.5.0-b33/solaris-sparc/bin/javac -version -source 1.5 -d . p1/A1.java
      javac 1.5.0-beta2
      + /export/ld25/java/dest/jdk1.5.0-b33/solaris-sparc/bin/javac -version -source 1.5 -d . p2/A2.java
      javac 1.5.0-beta2
      + /export/ld25/java/dest/jdk1.5.0-b33/solaris-sparc/bin/javac -version -source 1.5 -d . MyTest.java
      javac 1.5.0-beta2
      __input:3: f is already defined in a single-type import
      (source unavailable)
      1 error
      ================= MyTest output end ===================
      ======================================================================
      ###@###.### 10/25/04 22:53 GMT

            jjg Jonathan Gibbons
            garysunw Gary Gary (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: