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

varargs: accessibility check missing from JLS 15.12.{2,4}

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 7
    • specification
    • None
    • rc
    • unknown
    • generic
    • Verified

      Quoting from 6313164:

      "As written, the specification supports the implemented behavior. It would seem
      reasonable to expect a compile-time error if the type of a var-arg formal parameter were
      inaccessible. One might debate if, in such a circumstance, the method should even be
      considered applicable.

      However, the only sane path is to consider the call equivalent to its translation,
      not only at run time (which it already is), but at compile time.

      This may lead to difficulties with generic methods. It is therefore necessary to
      specify he check explicitly. In JLS 15.12.4.3, one would add the check:

      If all of the following conditions hold

      a. The compile-time declaration of the method invocation is a variable arity method m.
      b. The inferred type of the final formal parameter of m for this invocation is T[].
      c. m is invoked with actual argument expressions (e1 ... en-1, en, ..., ek)
      d. m is being invoked with k != n actual argument expressions, or,
         m is being invoked with k = n actual argument expressions and the type of the
         kth argument expressions is not assignment compatible with T[]

      then it is a compile time error if the erasure of T is not accessible at the point of invocation."

            abuckley Alex Buckley
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: