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

import and static-import of same name

XMLWordPrintable

    • x86
    • windows_xp, windows_7

      FULL PRODUCT VERSION :
      java version "1.6.0_12"
      Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
      Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Section 7.5.3 of the JLS Third Edition states: "if a compilation unit contains both a single-static-import (§7.5.3) declaration that imports a type whose simple name is n, and a single-type-import declaration (§7.5.1) that imports a type whose simple name is n, a compile-time error occurs. "

      The compiler accepts this though, if both n are the same type. Either the documentation need clarification or this is a compiler bug.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Possibly there should be a compiler error. If not, the JLS documentation should be clarified.
      ACTUAL -
      No compiler error.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import static java.util.Map.Entry;
      import java.util.Map.Entry;

      public class ImportBug {
      }

      ---------- END SOURCE ----------

            jlahoda Jan Lahoda
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: