private static void registerCallbackMethod(long cls, long selector, long newSelector, Method method) { long superMethod = ObjCRuntime.class_getInstanceMethod(cls, selector); long typeEncoding = ObjCRuntime.method_getTypeEncoding(superMethod); if (!ObjCRuntime.class_addMethod(cls, selector, VM.getCallbackMethodImpl(method), typeEncoding)) { throw new Error( "Failed to register callback method on the ObjectOwnershipHelper: class_addMethod(...) failed"); } // find the super class that is a native class and cache it long superClass = ObjCRuntime.class_getSuperclass(cls); long nativeSuper = 0; while (superClass != 0) { ObjCClass objCClass = ObjCClass.toObjCClass(superClass); if (!objCClass.isCustom()) { nativeSuper = superClass; break; } superClass = ObjCRuntime.class_getSuperclass(superClass); } if (nativeSuper == 0) { throw new Error("Couldn't find native super class for " + VM.newStringUTF(ObjCRuntime.class_getName(cls))); } synchronized (customClassToNativeSuper) { customClassToNativeSuper.put(cls, nativeSuper); } }
long methodPtr = isClassMethod ? ObjCRuntime.class_getClassMethod(superclass.getHandle(), selector.getHandle()) : ObjCRuntime.class_getInstanceMethod(superclass.getHandle(), selector.getHandle()); if (methodPtr != 0L) { long encodingPtr = ObjCRuntime.method_getTypeEncoding(methodPtr);
private static void registerCallbackMethod(long cls, long selector, long newSelector, Method method) { long superMethod = ObjCRuntime.class_getInstanceMethod(cls, selector); long typeEncoding = ObjCRuntime.method_getTypeEncoding(superMethod); if (!ObjCRuntime.class_addMethod(cls, selector, VM.getCallbackMethodImpl(method), typeEncoding)) { throw new Error( "Failed to register callback method on the ObjectOwnershipHelper: class_addMethod(...) failed"); } // find the super class that is a native class and cache it long superClass = ObjCRuntime.class_getSuperclass(cls); long nativeSuper = 0; while (superClass != 0) { ObjCClass objCClass = ObjCClass.toObjCClass(superClass); if (!objCClass.isCustom()) { nativeSuper = superClass; break; } superClass = ObjCRuntime.class_getSuperclass(superClass); } if (nativeSuper == 0) { throw new Error("Couldn't find native super class for " + VM.newStringUTF(ObjCRuntime.class_getName(cls))); } synchronized (customClassToNativeSuper) { customClassToNativeSuper.put(cls, nativeSuper); } }
long methodPtr = isClassMethod ? ObjCRuntime.class_getClassMethod(superclass.getHandle(), selector.getHandle()) : ObjCRuntime.class_getInstanceMethod(superclass.getHandle(), selector.getHandle()); if (methodPtr != 0L) { long encodingPtr = ObjCRuntime.method_getTypeEncoding(methodPtr);