Index: src/runtime/class.m ================================================================== --- src/runtime/class.m +++ src/runtime/class.m @@ -333,11 +333,13 @@ * in the initialize method */ class->info |= OBJC_CLASS_INFO_INITIALIZED; class->isa->info |= OBJC_CLASS_INFO_INITIALIZED; - callMethod(class, "initialize"); + if (class_respondsToSelector(object_getClass(class), + @selector(initialize))) + [class initialize]; } void objc_initialize_class(Class class) { Index: src/runtime/lookup.m ================================================================== --- src/runtime/lookup.m +++ src/runtime/lookup.m @@ -22,19 +22,10 @@ #import "ObjFW_RT.h" #import "private.h" #import "macros.h" -@interface DummyObject -{ - Class isa; -} - -+ (bool)resolveClassMethod: (SEL)selector; -+ (bool)resolveInstanceMethod: (SEL)selector; -@end - static IMP forwardHandler = (IMP)0; static IMP stretForwardHandler = (IMP)0; static IMP commonMethodNotFound(id object, SEL selector, IMP (*lookup)(id, SEL), Index: src/runtime/private.h ================================================================== --- src/runtime/private.h +++ src/runtime/private.h @@ -276,5 +276,15 @@ fprintf(stderr, "\n"); \ fflush(stderr); \ abort(); \ OF_UNREACHABLE \ } + +@interface DummyObject +{ + Class _Nonnull isa; +} + ++ (void)initialize; ++ (bool)resolveClassMethod: (nonnull SEL)selector; ++ (bool)resolveInstanceMethod: (nonnull SEL)selector; +@end