Skip to content

Commit

Permalink
8257620: Do not use objc_msgSend_stret to get macOS version
Browse files Browse the repository at this point in the history
Reviewed-by: ihse, rriggs
  • Loading branch information
AntonKozlov authored and Vladimir Kempik committed Dec 21, 2020
1 parent 8e42efa commit d4c7db5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/java.base/macosx/native/libjava/java_props_macosx.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,16 @@ void setOSNameAndVersion(java_props_t *sprops) {

char* osVersionCStr = NULL;
// Mac OS 10.9 includes the [NSProcessInfo operatingSystemVersion] function,
// but it's not in the 10.9 SDK. So, call it via objc_msgSend_stret.
// but it's not in the 10.9 SDK. So, call it via NSInvocation.
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
OSVerStruct (*procInfoFn)(id rec, SEL sel) = (OSVerStruct(*)(id, SEL))objc_msgSend_stret;
OSVerStruct osVer = procInfoFn([NSProcessInfo processInfo],
@selector(operatingSystemVersion));
OSVerStruct osVer;
NSMethodSignature *sig = [[NSProcessInfo processInfo] methodSignatureForSelector:
@selector(operatingSystemVersion)];
NSInvocation *invoke = [NSInvocation invocationWithMethodSignature:sig];
invoke.selector = @selector(operatingSystemVersion);
[invoke invokeWithTarget:[NSProcessInfo processInfo]];
[invoke getReturnValue:&osVer];

NSString *nsVerStr;
if (osVer.patchVersion == 0) { // Omit trailing ".0"
nsVerStr = [NSString stringWithFormat:@"%ld.%ld",
Expand Down

7 comments on commit d4c7db5

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VladimirKempik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk15u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d4c7db5 Jul 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VladimirKempik the backport was successfully created on the branch VladimirKempik-backport-d4c7db50 in my personal fork of openjdk/jdk15u-dev. To create a pull request with this backport targeting openjdk/jdk15u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit d4c7db50 from the openjdk/jdk repository.

The commit being backported was authored by Anton Kozlov on 21 Dec 2020 and was reviewed by Magnus Ihse Bursie and Roger Riggs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk15u-dev:

$ git fetch https://github.com/openjdk-bots/jdk15u-dev VladimirKempik-backport-d4c7db50:VladimirKempik-backport-d4c7db50
$ git checkout VladimirKempik-backport-d4c7db50
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk15u-dev VladimirKempik-backport-d4c7db50

@VladimirKempik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk13u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d4c7db5 Jul 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VladimirKempik the backport was successfully created on the branch VladimirKempik-backport-d4c7db50 in my personal fork of openjdk/jdk13u-dev. To create a pull request with this backport targeting openjdk/jdk13u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit d4c7db50 from the openjdk/jdk repository.

The commit being backported was authored by Anton Kozlov on 21 Dec 2020 and was reviewed by Magnus Ihse Bursie and Roger Riggs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk13u-dev:

$ git fetch https://github.com/openjdk-bots/jdk13u-dev VladimirKempik-backport-d4c7db50:VladimirKempik-backport-d4c7db50
$ git checkout VladimirKempik-backport-d4c7db50
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk13u-dev VladimirKempik-backport-d4c7db50

@VladimirKempik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d4c7db5 Jul 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VladimirKempik the backport was successfully created on the branch VladimirKempik-backport-d4c7db50 in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit d4c7db50 from the openjdk/jdk repository.

The commit being backported was authored by Anton Kozlov on 21 Dec 2020 and was reviewed by Magnus Ihse Bursie and Roger Riggs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev VladimirKempik-backport-d4c7db50:VladimirKempik-backport-d4c7db50
$ git checkout VladimirKempik-backport-d4c7db50
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev VladimirKempik-backport-d4c7db50

Please sign in to comment.