Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7531467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:10:46+00:00 2026-05-30T05:10:46+00:00

Consider this code: class Foo { public void doIt(String… strs) { System.out.println(this is varargs);

  • 0

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, 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. Am I missing some other details in the lookup algorithm or is this as obviously wrong as I think it is?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:10:48+00:00Added an answer on May 30, 2026 at 5:10 am

    You’re not missing anything.
    This is a known bug.

    As Qwe commented, here is a link to an appropriate bug filing:
    https://bugs.java.com/bugdatabase/view_bug?bug_id=6746184

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this code: public <T> List<T> meth(List<?> type) { System.out.println(type); // 1 return new
Consider this code class Foo { private: Bar bar; //note: no reference public: Foo(Bar&
Consider this: class Foo{ void func1(){ /*func1 code*/ } void func2(){ /*func2 code*/ }
Consider this class: public class Foo { // Fields private string _bar; // Properties
Consider this code: class DatabaseCommands { @Privilege(ADMIN) public void delete(Something thingToDelete, User currentUser) {
Consider this code. public class Class1 { public void ThisShouldNotCompileBecauseOrderWasVoilated() { Call2(); Call1(); }
Consider the following code (C# 4.0): public class Foo : LambdaExpression { } This
Consider such code (this is just example not real code): class Foo(url : String)
Consider the following code: class A { public: void foo() { auto functor =
Consider this code: class Foo[T : Manifest](val id: String = manifest[T].erasure.getName) I basically want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.