Add check to prevent loading more than one Kotlin framework

This commit is contained in:
Svyatoslav Scherbina
2018-03-07 17:17:25 +03:00
committed by SvyatoslavScherbina
parent 0570e281a9
commit 79b0dc5652
+11
View File
@@ -897,4 +897,15 @@ extern "C" void Kotlin_ObjCExport_AbstractMethodCalled(id self, SEL 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