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

incorrect warning on call of variable-arity method (b49)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • tools
    • None
    • generic
    • generic

      With b49, the following example:

      public class Foo {
          Class<?>[] get() { return null; }

          void set(Class... c) { }

          void test() {
      set(get());
          }
      }

      results in

      Foo.java:7: warning: fixed-arity call of variable-arity method with inexact match for last parameter;
      cast to java.lang.Class for a variable-arity call
      cast to java.lang.Class[] for a fixed-arity call
      set(get());
                     ^
      1 warning

      Suggesting a cast from Class<?>[] to Class makes no sense. The ambiguity in this call is not obvious to me.

            gafter Neal Gafter (Inactive)
            bscheiflsunw Bob Scheifler (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: