I currently have a compilation issue with Gradle using target 1.7 and source 1.7 vs Eclipse Juno using the built-in 1.7 jdk.
I have 5 classes :
Info.java –> Interface that has no methods (for example)
public interface Info { //... }
RealInfo.java –> Interface that extends the Info interface
public interface RealInfo extends Info { //... }
AbstractManager.java –> Abstract class that has the method “getInfo()“
public abstract class AbstractManager<I extends Info>
{
public I info;
public I getInfo()
{
return this.info;
}
}
Manager.java –> Interface that has the method “getInfo()“
public interface Manager
{
public <I extends Info> I getInfo();
}
DefaultManager.java –> Extends AbstractManager
public class DefaultManager extends AbstractManager<RealInfo> implements Manager
{
//...
}
If you copy/paste this code into eclipse, everything works fine. There’s no compilation error. However, if I build it with Gradle, using target jdk 1.7, the compiler will not like it :
DefaultManager.java:16: error: DefaultManager is not abstract and does not override abstract method <I>getInfo() in Manager
public class DefaultManager extends AbstractManager<RealInfo> implements Manager
^
where I is a type-variable:
I extends Info declared in method <I>getInfo()
Do you have any idea on what could happen there?
I’ve found what Javac doesn’t seem to like.
I modified my AbstractManager class to :
Gradle now accepts this code while compiling with Javac. It’s strange though that it cannot properly infer
Ito<I extends Info>. Eclipse’s compiler can handle the two syntaxes.