Add check to prevent loading more than one Kotlin framework
This commit is contained in:
committed by
SvyatoslavScherbina
parent
0570e281a9
commit
79b0dc5652
@@ -897,4 +897,15 @@ extern "C" void Kotlin_ObjCExport_AbstractMethodCalled(id self, SEL selector) {
|
|||||||
class_getName(object_getClass(self)), sel_getName(selector)];
|
class_getName(object_getClass(self)), sel_getName(selector)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((constructor))
|
||||||
|
static void checkLoadedOnce() {
|
||||||
|
Class marker = objc_allocateClassPair([NSObject class], "KotlinFrameworkLoadedOnceMarker", 0);
|
||||||
|
if (marker == nullptr) {
|
||||||
|
[NSException raise:NSGenericException
|
||||||
|
format:@"Only one Kotlin framework can be loaded currently"];
|
||||||
|
} else {
|
||||||
|
objc_registerClassPair(marker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // KONAN_OBJC_INTEROP
|
#endif // KONAN_OBJC_INTEROP
|
||||||
|
|||||||
Reference in New Issue
Block a user