• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ambigous call on boxing with varargs jdk 7 probable unfixed compiler bug ?

 
Greenhorn
Posts: 12
Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below code (Snippet 1) fails to compile in JDK 7.0_7 compiler (Error: reference to go is ambiguous, both method go(int...) in A and method go(java.lang.Integer...) in A match)

Snippet 1


Meanwhile this code (Snippet 2) compiles fine with JDK 7.0_7 and displays " primitive" on running. But the code doesn't compile on my other compiler Eclipse Compiler 0.A48 ( Error: The method go(int[]) is ambiguous for the type A. )


Snippet 2


So "snippet 2" seems to be an old compiler bug fixed in Java 7. What about "Snippet 1" ? Is this an unfixed bug with Java 7 compiler ? On the other hand , Is this compiler error a correct behaviour ? Can somebody kindly explain from the JLS .
 
Greenhorn
Posts: 7
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here both method are equally eligible for invoking . So it gives 'Reference is ambigous'.

As far as i understand , widening is not needed here as with primitive int and method (var)-argument int and Integer.
So, int i can become Integer through Autoboxing , and var-args+Wrapper(without widening) == var-args + primitive
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic