コード:
interface BaseIntr<T>{
void saveSwiftMsg(Collection<String> headers) throws Exception;
}
class Impl implements BaseIntr{
public void saveSwiftMsg(Collection<String> headers) throws Exception { }
}
コードの編集バージョン:
interface BaseIntr<T>{
T process(T t);
void saveSwiftMsg(Collection<String> headers) throws Exception;
}
class Impl implements BaseIntr{
public void saveSwiftMsg(Collection<String> headers) throws Exception { }
@Override
public Object process(Object t) { return t; }
}
作業環境:
Javaバージョン:1.7.0_04、ベンダー:Oracle Corporation
デフォルトのロケール:en_IN、プラットフォームエンコーディング:Cp1252
OS名:「windows7」、バージョン:「6.1」、アーチ:「amd64」、ファミリ:「windows」
Javaコンパイラは次の例外をスローします。しかし、BaseIntrから<T>を削除すると、正常に機能します。
javac gen\GenericsTest.java
gen\GenericsTest.java:18: error: Impl is not abstract and does not override abstract method saveSwiftMsg(Collection) in BaseIntr
class Impl implements BaseIntr{
^
gen\GenericsTest.java:20: error: name clash: saveSwiftMsg(Collection<String>) in Impl and saveSwiftMsg(Collection<String>) in BaseIntr have the same erasure, yet neither overrides the other
public void saveSwiftMsg(Collection<String> headers) throws Exception {
^
2 errors