Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Method is ambiguous error
Method is ambiguous error [message #259068] Fri, 13 March 2009 12:37 Go to next message
Eclipse UserFriend
I imported a project from my 3.4.1 workspace into a new workspace for
I20090312-2000. JDT doesn't seem to like one of my unit tests anymore.
Here is a similar snippet that compiles in 3.4.1 but not 3.5

@Test
public void ambiguous() {
int i = 1;
assertEquals(i, getBoxed());
}

private Integer getBoxed() {
return Integer.valueOf(1);
}


"The method assertEquals(Object, Object) is ambiguous for the type
AmbiguousTests"

Is there a preference to control this particular error? Perhaps
something I had set in 3.4 that I don't have set in my new workspace..

Thanks
Ben
Re: Method is ambiguous error [message #259076 is a reply to message #259068] Fri, 13 March 2009 12:49 Go to previous message
Eclipse UserFriend
Originally posted by: mauro.molinari.cardinis.com

Ben Vitale ha scritto:
> I imported a project from my 3.4.1 workspace into a new workspace for
> I20090312-2000. JDT doesn't seem to like one of my unit tests anymore.
> Here is a similar snippet that compiles in 3.4.1 but not 3.5
>
> @Test
> public void ambiguous() {
> int i = 1;
> assertEquals(i, getBoxed());
> }
>
> private Integer getBoxed() {
> return Integer.valueOf(1);
> }
>
>
> "The method assertEquals(Object, Object) is ambiguous for the type
> AmbiguousTests"
>
> Is there a preference to control this particular error? Perhaps
> something I had set in 3.4 that I don't have set in my new workspace..
>
> Thanks
> Ben

It's JUnit 4.4 (or later) that introduces a new overload of assertEquals
that make a call like yours ambiguous.
To avoid the problem, make sure that you either call
assertEquals(Object, Object) (by passing two Integers) or
assertEquals(int, int) (by passing two ints).

Eclipse 3.4 embeds JUnit 4.3.1, while the new 3.5 embeds JUnit 4.5 (if I
remember well).

Mauro.
Previous Topic:Graphical Interaction in Refactoring Rename Participant
Next Topic:Unable to set a watchpoint on final variable
Goto Forum:
  


Current Time: Tue May 13 12:58:15 EDT 2025

Powered by FUDForum. Page generated in 0.04954 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top