Incidencia #531

インターフェースによる暗黙の abstract
Abrir Fecha: 2002-08-31 13:07 Última actualización: 2002-08-31 13:07

Informador:
Propietario:
(Ninguno)
Tipo:
Estado:
Open
Componente:
(Ninguno)
Hito:
(Ninguno)
Prioridad:
3
Gravedad:
5 - Medium
Resolución:
Ninguno
Fichero:
Ninguno

Details

public interface Interface {
public String hello();
}

public abstract class Super implements Interface {
public void sayHello() {
String msg = hello();
System.out.println(msg);
}
}

public class Test extends Super {
public String hello() {
return "hello, world";
}

public static void main(String[] args) {
new Test().sayHello();
}
}

というようなアプリケーションがあったとして、
ふつうに処理すると、Interface#hello() は参照されていな
いからという理由で削られてしまうが、
そうすると Super#sayHello() から呼ばれている hello()
(バイトコード上では invokevirtual test1/Super/hello()
になっている)は解決できなくなり、Super.class は不正な
クラスファイルになってしまう。

対処のし方は、Interface が結果の jar に含まれるものか、
そうでないものかによって変わってくる(はず)。

Ticket History (0/0 Histories)

Attachment File List

No attachments

Editar

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Entrar