mbassadorを使用していますが、インターフェイスへの公開が機能していないようです。以下は JUnit を使用したsscceです。このプログラムは を出力すると思いますhello world
が、そうではありません。ただし、この行を変更すると:
public void handleFoo(FooInterface f) {
これに:
public void handleFoo(FooImpl f) {
プログラムは完璧に動作します。これはバグですか、それとも何か間違っていますか? 注:public void handleFoo(Object o)
も機能します。
import net.engio.mbassy.bus.BusConfiguration;
import net.engio.mbassy.bus.MBassador;
import net.engio.mbassy.listener.Handler;
import org.junit.Test;
public class MBassadorTest {
@Test
public void testMBassador() {
MBassador<FooInterface> bus = new MBassador<>(BusConfiguration.Default());
bus.subscribe(this);
FooInterface myFoo = new FooImpl();
bus.publish(myFoo);
}
public static interface FooInterface {
String doSomething();
}
public static class FooImpl implements FooInterface {
public String doSomething() {
return "hello world";
}
}
@Handler(rejectSubtypes = false)
public void handleFoo(FooInterface f) {
System.out.println(f.doSomething());
}
}