JDK7泛型不编译

时间:2015-01-06 17:53:07

标签: java generics compiler-errors java-7

以下代码在jdk6中编译,但在jdk7中编译。请建议任何解决方法

public interface LocalCacheMap<K extends Comparable<? super K>, V>  
extends ClearableCache<K>, Iterable<V>{
    V get(K key);
}

public class Universe<K extends Comparable<? super K>, V, TSKEY extends Comparable<? super TSKEY>> extends MasterLocalCache<K>  
implements Iterable<V>, LocalCacheMap<K, V>, TsDaoInfo<TSKEY, K>, ValueConverter<K, Object, V>{
    public V get(K key) {
        return get(key, keyFunct);
    }
    abstract public TSKEY buildTsKey(K key, Date date);

    abstract public K getObjKey(TSKEY tsKey);

    abstract public Date getDateKey(TSKEY tsKey);

}

public class JdbcTimesSeriesCacheDef<K extends Comparable<? super K>, TSKEY extends Comparable<? super TSKEY>, LC extends Universe<K,?,TSKEY>&DataSourceProvider, T> extends AbstractRawTimeSeriesCacheDef<K, T, LC> {
    private final SqlDefs<T> defs;

}

使用jdk7编译时,我收到以下错误

Universe中的JdbcTimesSeriesCacheDef错误:get(K#1)无法在LocalCacheMap中实现get(K#2)

2 个答案:

答案 0 :(得分:0)

更改

LC extends Universe<K,?,TSKEY>&DataSourceProvider,

LC extends Universe<K,T,TSKEY>&DataSourceProvider,

答案 1 :(得分:0)

我通过使用特定的值类型'V'代替“?”

解决了这个问题

public class JdbcTimesSeriesCacheDef,V,TSKEY extends Comparable,LC extends Universe&amp; DataSourceProvider,T&gt;扩展AbstractRawTimeSeriesCacheDef {     私有最终SqlDefs defs;

}