Update: this seems to be Eclipse-related, rather than Hudson-related so I updated the question accordingly.
I’m getting some compiler errors when running Maven on the command line, but all developers in our group has the code working fine in Eclipse (some Generic intricacies, see below for details). How could this differ and what to do about it?
The code that fails looks like this:
299 private <T extends ProductClassDTO> List<T> convertProductClass(List<? extends ProductClassDTO> fromList) {
300 List<T> toList = new ArrayList<T>();
301 for (ProductClassDTO from : fromList) {
302 T to = convert(from);
303 toList.add(to);
304 }
305 return toList;
306 }
this is the error on build server:
[ERROR] ...java:[302,26] type parameters of <T>T cannot be determined; no unique maximal instance exists for type variable T with upper bounds T,com.volvo.protom.util.dto.ProductClassDTO
(I know there are other questions+answers on this in SO, but they don’t seem to apply to this particular question, since changing to T to = <T>convert(from) doesn’t work, perhaps I should do something else?) I’m guessing the error refers to that there are several convert methods in this class, and more than one fit?
Thanks!
Update 2: these are the convert signatures:
private void convert(TestObjectDTO from, TestObjectDTO to);
private <T extends TestObjectDTO> T convert(TestObjectDTO from);
private void convert(ProductClassDTO from, ProductClassDTO to);
private <T extends ProductClassDTO> T convert(ProductClassDTO from);
private void convert(TestObjectTypeDTO from, TestObjectTypeDTO to);
private <T extends TestObjectTypeDTO> T convert(TestObjectTypeDTO from);
The Eclipse and JDK javac are slightly different, see @maximdim‘s comment. Always run from the command-line to ensure compatibility (though Eclipse’s javac seems more correct).