Hello, I see exception when I try to override protected(or package-private) method annotated with @Selector
Actually that method works nice. If I make it public there is no exception.
So, the Exception:
java.lang.NoSuchMethodException: handleTap []
at java.lang.Class.getMethod(Class.java:669)
at java.lang.Class.getMethod(Class.java:648)
at org.moe.natj.objc.ObjCSelectorsFinder.getMethodsWithSelectorsForClass(ObjCSelectorsFinder.java:72)
at org.moe.natj.objc.ObjCSelectorsFinder.prepareParentsSelectorsList(ObjCSelectorsFinder.java:42)
at org.moe.natj.objc.ObjCRuntime.registerClass(Native Method)
at org.moe.natj.objc.ObjCRuntime.doRegistration(ObjCRuntime.java:73)
at org.moe.natj.general.NatJ.register(NatJ.java:265)
at delightex.testhttp.MoeRecognizerEventHandler$MyMoeRecognizerEventHandler.<clinit>(MoeRecognizerEventHandler.java)
at delightex.testhttp.Main.applicationDidFinishLaunchingWithOptions(Main.java:60)
at ios.uikit.c.UIKit.UIApplicationMain(Native Method)
at delightex.testhttp.Main.main(Main.java:32)
Did not found method:handleTap For class:MyMoeRecognizerEventHandler
And my code:
package delightex.testhttp;
import ios.NSObject;
import ios.uikit.UITapGestureRecognizer;
import ios.uikit.UIView;
import ios.uikit.protocol.UIGestureRecognizerDelegate;
import org.moe.natj.general.Pointer;
import org.moe.natj.objc.SEL;
import org.moe.natj.objc.ann.Selector;
public class MoeRecognizerEventHandler extends NSObject implements UIGestureRecognizerDelegate {
public static final String HANDLE_TAP = "handleTap";
public final UITapGestureRecognizer singleTapRecognizer = UITapGestureRecognizer.alloc().init();
protected MoeRecognizerEventHandler(Pointer peer) {
super(peer);
}
@Selector("alloc")
public static native MoeRecognizerEventHandler alloc();
@Selector("init")
public native MoeRecognizerEventHandler init();
public void myInit(UIView view) {
singleTapRecognizer.setNumberOfTapsRequired(1);
singleTapRecognizer.addTargetAction(this, new SEL(HANDLE_TAP));
singleTapRecognizer.setDelegate(this);
view.addGestureRecognizer(singleTapRecognizer);
}
@Selector(value = HANDLE_TAP)
protected void handleTap() {
System.out.println("parent: handleTap");
}
public static class MyMoeRecognizerEventHandler extends MoeRecognizerEventHandler {
protected MyMoeRecognizerEventHandler(Pointer peer) {
super(peer);
}
@Selector("alloc")
public static native MyMoeRecognizerEventHandler alloc();
@Selector("init")
public native MyMoeRecognizerEventHandler init();
protected void handleTap() {
System.out.println("child: handleTap");
}
}
}
usage:
UiView view = getMyView();
MoeRecognizerEventHandler.MyMoeRecognizerEventHandler.alloc().init().myInit(view);