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

7.5.3: Allow "duplicate" single-type-import and single-static-import

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 10
    • 8u51, 9
    • specification
    • x86_64
    • windows_7

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      According to the spec (7.5.3): "If a compilation unit contains both a single-static-import declaration that imports a type whose simple name is n, and a single-type-import declaration that imports a type whose simple name is n, a compile-time error occurs.", and vice versa for the single type import declaration.

      This is not enforced by the compiler if they import the same type though. Either the spec should be changed to say "a different top level type whose simple name is n" or the compiler should be changed to enforce the spec.

      Note that in the spec for single type import, a clash with another single type import is qualified with "unless the two types are the same type".

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect error "error: a type with the same simple name is already defined by the static single-type-import of Subset".

      Note that this is the wrong error message. The messages for static first and static last are switched. I will file a separate bug report for that.
      ACTUAL -
      compilation succeeds

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.lang.Character.Subset;
      import static java.lang.Character.Subset;

      public class Test {
      }

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

      Attachments

        Activity

          People

            abuckley Alex Buckley
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: