Should Overload Resolution Select Private Methods?
Consider this code:

    class Foo {
        public void doIt(String... strs) {
            System.out.println("this is varargs");
        }

        private void doIt(String str) {
            System.out.println("this is single");
        }
    }

    class Bar {
        public static void main (String[] args) {
            new Foo().doIt("");
        }
    }

With javac version 1.6.0_29, it fails to compile, stating:

    VarArgsError.java:14: doIt(java.lang.String) has private access in Foo
      new Foo().doIt("");
               ^
    1 error

Yes, this is silly code and there are at least two obvious workarounds, but I'm curious. Based on [section 15.12.2 of the specification][1], this compilation error seems like a bug in javac, because the first step should remove the non-varargs doIt, as it is inaccessible according to [section 6.6.1][2]. Am I missing some other details in the lookup algorithm or is this as obviously wrong as I think it is?


  [1]: http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.12.2
  [2]: http://java.sun.com/docs/books/jls/third_edition/html/names.html#104285
Should Overload Resolution Select Private Methods?
===

Consider this code:

    class Foo {
        public void doIt(String... strs) {
            System.out.println("this is varargs");
        }

        private void doIt(String str) {
            System.out.println("this is single");
        }
    }

    class Bar {
        public static void main (String[] args) {
            new Foo().doIt("");
        }
    }

With javac version 1.6.0_29, it fails to compile, stating:

    VarArgsError.java:14: doIt(java.lang.String) has private access in Foo
      new Foo().doIt("");
               ^
    1 error

Yes, this is silly code and there are at least two obvious workarounds, but I'm curious. Based on [section 15.12.2 of the specification][1], this compilation error seems like a bug in javac, because the first step should remove the non-varargs doIt, as it is inaccessible according to [section 6.6.1][2]. Am I missing some other details in the lookup algorithm or is this as obviously wrong as I think it is?


  [1]: http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.12.2
  [2]: http://java.sun.com/docs/books/jls/third_edition/html/names.html#104285