Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Giving error when compiling with ant but not showing the error in eclips

 
ravin kacha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am getting across a very strange error. I have written a java file, it is getting compiled in Eclips without any error. Now I am compiling the whole package through an ANT script which is showing the below error for the code snippet while compiling

\com\holset\matrix\utils\QueryString.java - Classed method have been conflicted between two classes.

Error Prompted :-
com\holset\matrix\utils\QueryString.java:102: reference to putAll is ambiguous, both method putAll(java.util.Map<? extends K,? extends V>) in .AbstractMap<java.lang.String,capture#832 of ?> and method putAll(java.util.Map<? extends K,? extends V>) in java.util.HashMap<java.lang.String,capture#832 of ?> match
map.putAll((Map) requestMap.get("requestMap"));


can any buddy help me out to resolve this. Because this is a show stopper for me cause I am not able to create a jar because of this only.

Thanks in advance

Ravin Kacha
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ravin,

Chances are that your ANT build and your Eclipse are using different versions of the JDK. Can you check that?
 
ravin kacha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have checked the JDK versions, both are identical.

But the question which invokes my thought process again and again is, though I am giving HashMap<K,V> as data type and creating object of the same type how can compiler get confused in AbstractMap and HashMap???
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, what version of the JDK is this?
 
ravin kacha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JDK 1.6.0_03

is there any concern with the JDK version and ANT as such??
 
Vivekkk Singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey ,

A generic type declaration is compiled once and for all, and turned into a single class file, just like an ordinary class or interface declaration.

Google about Genrics..It will solve the problem.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eclipse has it's own Java compiler -- it doesn't compile using the JDK compiler.

I don't know offhand whether this is a bug in javac, or a bug in the Eclipse compiler. Here is a link to a similar-sounding bug in Sun's Java bug database which is still open for JDK 1.6, although it's apparently fixed in 1.7 and 1.5 .
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivekkkkk Singhhhhh wrote:
Google about Genrics..It will solve the problem.


Oh, indeed. Googling "generics" will make this compiler bug go away.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivekkkkk Singhhhhh,

Can you please change your screen name in accordance with our Naming Policy, thanks
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest Friedman-Hill wrote:Eclipse has it's own Java compiler -- it doesn't compile using the JDK compiler.

I don't know offhand whether this is a bug in javac, or a bug in the Eclipse compiler. Here is a link to a similar-sounding bug in Sun's Java bug database which is still open for JDK 1.6, although it's apparently fixed in 1.7 and 1.5 .


In addition to this, Ravin, can you try with the latest version of 1.6? (its 1.6.0_12)
 
Vivekkk Singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I changed the Name But I think the Javaranch should change it as the I am Not able to create account with my name.So I dont think its fair enof to change my second name...lols.. ...I dont Know what kind of validation they make from First Name.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivek Singh at Javaranch wrote:Well I changed the Name But I think the Javaranch should change it as the I am Not able to create account with my name.So I dont think its fair enof to change my second name...lols.. ...I dont Know what kind of validation they make from First Name.


PM sent.
 
Vivekkk Singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey here you are trying to mix a non Generic collection and generic collection..

reuestMap and map.This could be the problem because while compilation there is No error.But it may give a runtime...
 
Vivekkk Singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i can give you a small example on that.


So both are valid but

Only this is valid.

Similarly in your case requestMap is too general.Where as your map is very specific.
So you are trying to put a general map to something specific.

I hope it works now
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic