New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8272602: [macos] not all KEY_PRESSED events sent when control modifier is used #5177
Conversation
👋 Welcome back prr! A progress list of the required criteria for merging this PR into |
NSRange crange = NSMakeRange(0, len); | ||
[str getCharacters:buffer range:crange]; | ||
jstring jStr = (*env)->NewString(env, buffer, len); | ||
free(buffer); | ||
CHECK_EXCEPTION(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be better to call CHECK_EXCEPTION_NULL_RETURN() here to return null in case NewString throw exception in which case, I guess jStr will have garbage.
Also, it seems https://developer.apple.com/documentation/foundation/nsstring/1408720-getcharacters says the buffer must be large enough...aRange.length*sizeof(unichar) so shouldn't the NSRange be created for
(0, len * sizeof(unichar))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be better to call CHECK_EXCEPTION_NULL_RETURN()
If the jstring were garbage in such a case we would NOT want to check it against null, since
that would be a definite problem.
As it is NewString is specified to return NULL if there is a problem so the existing code is fine although the alternative pattern of CHECK_EXCEPTION_NULL_RETURN(jstr, NULL) would also work.
SInce I'm not changing this I think it fine to stick with the existing code.
the buffer must be large enough...aRange.length*sizeof(unichar) so shouldn't the NSRange be created for
(0, len * sizeof(unichar))
The buffer is large enough
buffer = (unichar*) calloc(len, sizeof(unichar));
the NSRange is the number of elements to copy. It is not the buffer storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked - fix works and it does not break input handling including multibyte characters.
@prrace This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 44 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
On the other hand i now see that AFTER i did a multibyte character input every time i switch into application with - i get following output in the terminal: |
It is not related to this change, i rolled it back and the issue persists so has nothing to do with this fix. |
Yep, it is unrelated to what is being touched in this fix so should be handled separately. |
if (str == NULL) { | ||
return NULL; | ||
} | ||
jstring jStr = (*env)->NewStringUTF(env, [str UTF8String]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we should cleanup all usage of [nsstring UTF8String] in the code at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on what the source data is.
FWIW in the macOS code in java.desktop there are just 5 others and none of them were touched/added/changed by the JNF work. They are all pre-existing.
/integrate |
Going to push as commit ddcd851.
Your commit was automatically rebased without conflicts. |
When Ctrl+Space is pressed mac generates a string that contains the single unicode code point zero.
The fn that converts it from an NSString to a Java String is using NewStringUTF.
The input to that is a null terminated string which also has zero as the code point it contains, so
we actually end up with a zero length Java string instead of the intended one code point in length.
So the fix is to change the way we convert the string.
There's an existing test CtrlAscii.java which sort of tests some of this but it isn't asserting that you
get what you expect, its mostly testing you don't get something unexpected .. it will happily pass if
you don't get keyevents. I did not want to change the purpose of that test for this.
So I wrote a test specific to this Ctrl+Space to verify the fix but also ran all the standard automated tests too.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5177/head:pull/5177
$ git checkout pull/5177
Update a local copy of the PR:
$ git checkout pull/5177
$ git pull https://git.openjdk.java.net/jdk pull/5177/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5177
View PR using the GUI difftool:
$ git pr show -t 5177
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5177.diff