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

  • Home
  • SEARCH
  • 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 6662045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:20:54+00:00 2026-05-26T02:20:54+00:00

We have a class LogManager in our Java project which looks like this: public

  • 0

We have a class LogManager in our Java project which looks like this:

public class LogManager {

    public void log(Level logLevel, Object... args) {
        // do something
    }

    public void log(Level logLevel, int value, Object... args) {
        // do something else
    }
}

When compiling the project with OpenJDK 6 under Debian everyting
works fine. When using OpenJDK 7 the build (done with ant)
produces the following errors and the build fails:

[javac] /…/LogManager.java:123: error: reference to log is ambiguous,
                      both method log(Level,Object...) in LogManager
                      and method log(Level,int,Object...) in LogManager match
[javac]       log(logLevel, 1, logMessage);
[javac]       ^
[javac] /…/SomeOtherClass.java:123: error: reference to log is ambiguous,
                      both method log(Level,Object...) in LogManager
                      and method log(Level,int,Object...) in LogManager match
[javac]       logger.log(logLevel, 1, logMessage);
[javac]             ^

As long as the 1 is not autoboxed, the method call should be
unambiguous as 1 is an int and cannot be upcast to Object. So why
doesn’t autoboxing overrule varargs here?

Eclipse (installed using the tar.gz from eclipse.org) compiles it no
matter if OpenJDK 6 is installed or not.

Thank’s a lot for your help!

Edit:

The compiler gets the option source="1.6" and target="1.6" in both cases. The Eclipse compiling note is just meant as a comment.

  • 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-26T02:20:54+00:00Added an answer on May 26, 2026 at 2:20 am

    I guess it’s related to bug #6886431, which seems to be fixed in OpenJDK 7 as well.

    The problem is that JLS 15.12.2.5 Choosing the Most Specific Method
    says that one method is more specific than another one when types of formal parameters of the former are subtypes of formal parameters of the latter.

    Since int is not a subtype of Object, neither of your methods is the most specific, thus your invocation is ambiguous.

    However, the following workaround is possible, because Integer is a subtype of Object:

    public void log(Level logLevel, Object... args) { ... }
    public void log(Level logLevel, Integer value, Object... args) { ... } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class Fred { public: void inspect() const {}; void modify(){}; }; int
We have a log class which uses Relection.MethodBase to send current class info to
I have a problem with a class, log cat return this error when a
I have a Java EE 6 application in which I'd like to use velocity
I have a singleton (from boost::serialization): class LogManager : public boost::serialization::singleton<LogManager> { ... };
So I have this code: public class LoggingManager { Logger root = Logger.getRootLogger(); public
I have class A: public class ClassA<T> Class B derives from A: public class
I have class A, which exposes an event. an object of class B subscribed
I have class A: public B { ...} vector<A*> v; I want to do
I have a class namespace LogToolsTest { public class Foo { private static readonly

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.