File tree Expand file tree Collapse file tree
src/java.base/macosx/native/libjava Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -236,11 +236,16 @@ void setOSNameAndVersion(java_props_t *sprops) {
236236
237237 char * osVersionCStr = NULL ;
238238 // Mac OS 10.9 includes the [NSProcessInfo operatingSystemVersion] function,
239- // but it's not in the 10.9 SDK. So, call it via objc_msgSend_stret .
239+ // but it's not in the 10.9 SDK. So, call it via NSInvocation .
240240 if ([[NSProcessInfo processInfo ] respondsToSelector :@selector (operatingSystemVersion )]) {
241- OSVerStruct (* procInfoFn )(id rec , SEL sel ) = (OSVerStruct (* )(id , SEL ))objc_msgSend_stret ;
242- OSVerStruct osVer = procInfoFn ([NSProcessInfo processInfo ],
243- @selector (operatingSystemVersion ));
241+ OSVerStruct osVer ;
242+ NSMethodSignature * sig = [[NSProcessInfo processInfo ] methodSignatureForSelector :
243+ @selector (operatingSystemVersion )];
244+ NSInvocation * invoke = [NSInvocation invocationWithMethodSignature :sig ];
245+ invoke .selector = @selector (operatingSystemVersion );
246+ [invoke invokeWithTarget :[NSProcessInfo processInfo ]];
247+ [invoke getReturnValue :& osVer ];
248+
244249 NSString * nsVerStr ;
245250 if (osVer .patchVersion == 0 ) { // Omit trailing ".0"
246251 nsVerStr = [NSString stringWithFormat :@"%ld.%ld" ,
You can’t perform that action at this time.
0 commit comments