Skip to content

Commit 1bf5e74

Browse files
tomballcopybara-github
authored andcommitted
Rewrite of j2objc_library.bzl to use an aspect to generate build actions for all java_library dependencies, like the native rule does.
PiperOrigin-RevId: 464184706
1 parent d011a13 commit 1bf5e74

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

examples/protobuf/AddressBook/j2objc_main.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ int j2objc_main(const char* className, int argc, const char *argv[]) {
7575
IOSClass *clazz = [IOSClass forName:[NSString stringWithUTF8String:className]];
7676
IOSObjectArray *mainArgs = JreEmulationMainArguments(argc, argv);
7777
SEL mainSelector = sel_registerName("mainWithNSStringArray:");
78+
#if __has_feature(objc_arc)
79+
// Avoid a -Warc-performSelector-leaks false-positive warning.
80+
IMP imp = [clazz.objcClass methodForSelector:mainSelector];
81+
void (*func)(id, SEL, id) = (void *)imp;
82+
func(nil, mainSelector, mainArgs);
83+
#else
7884
[clazz.objcClass performSelector:mainSelector withObject:mainArgs];
85+
#endif
7986
}
8087
@catch (JavaLangClassNotFoundException *e) {
8188
fprintf(stderr, "Error: could not find or load main class %s\n", className);

0 commit comments

Comments
 (0)