-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8308780: Fix the Java Integer types on Windows #14125
Conversation
👋 Welcome back jwaters! A progress list of the required criteria for merging this PR into |
@TheShermanTanker The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
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.
I think the JNI type definition change is okay.
However many of the other changes appear to me to not involve Java variables and so don't need to be Java types i.e they should be int
rather than jint
- though as these are native Windows types there may not actually be any reason to change them from long
. This is for the client-libs folk to decide.
@@ -322,7 +322,7 @@ Java_sun_java2d_windows_GDIRenderer_doDrawArc | |||
return; | |||
} | |||
|
|||
long sx, sy, ex, ey; | |||
jint sx, sy, ex, ey; |
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.
These are not Java variables. They get passed to the win32 GDI Arc function below which expects int
.
src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp
Outdated
Show resolved
Hide resolved
All the changes from long were done since there was conversion from or to a jint somewhere down the line, and the compilation would fail if not done otherwise. I also changed them to jint rather than int so there wouldn't be a need to keep the variables in sync with the jni.h declarations, but I guess I'll wait for more reviews to see what to do here |
Going to page for @aivanov-jdk for |
Okay I see that now. It is a messy situation - at some point the incoming jint's need to be "converted" to a native type. |
I'll see what I can do, I'll check the parameter type for the methods that are called in relevant code, though if they take an int as an argument I'm not really sure what to change |
For reference as to what types the calls in affected code accepts as parameters, so any future reviews don't need to dig through the code
Only outlier is jaccesswalker, which I think I may have edited wrongly |
Bumping :( |
While looking through the code for this I've come to realize that a staggering amount of code in the accessibility binaries specify longs where unsigned longs would be much more appropriate (see the one example in this PR for instance), wonder if this should also be fixed in the long term too |
I'm not sure I understand the logic here. Also "compilation" isn't nearly good enough. How is this being tested ? |
I can change the jints in this PR to regular ints if required. As listed above, the native Windows API routines that the java.desktop code calls are actually expecting ints, so our existing declarations of passing longs to them are also wrong regardless, even without the Java typedefs Actually, now that I revisit this issue (shown in the list above), the only actual calls in this change that don't take Java typedefs are the calls to ::Arc and ::Pie, so this is less of a problem than initially expected
|
Bumping |
Anyone? |
I'll take a look… hopefully next week. |
Bumping |
Bumping |
Mailing list message from Patrick Chen on client-libs-dev: No rejected Le mer. 21 juin 2023, 08:47, Julian Waters <jwaters at openjdk.org> a ?crit : -------------- next part -------------- |
... |
src/jdk.accessibility/windows/native/jaccesswalker/jaccesswalker.cpp
Outdated
Show resolved
Hide resolved
Will do, thanks Daniel |
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.
Looks fine to me, except for a few comments.
The size of the types for jint
and jlong
remains the same after amending the typedef jni_md.h
. Yet I'm still cautious about it. You should have an approval from hotspot.
Please also update the copyright year in the modified files.
src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp
Outdated
Show resolved
Hide resolved
src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp
Outdated
Show resolved
Hide resolved
src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp
Outdated
Show resolved
Hide resolved
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.
Hotspot changes still approved.
Other changes seem okay to me.
Thanks
Alright, I'll integrate once Alexsey approve, anyone else has further objections? |
@@ -73,7 +73,7 @@ class AwtMenu : public AwtMenuItem { | |||
|
|||
/*for multifont menu */ | |||
BOOL IsTopMenu(); | |||
virtual AwtMenuItem* GetItem(jobject target, long index); | |||
virtual AwtMenuItem* GetItem(jobject target, int index); |
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.
Hi @aivanov-jdk are you OK leaving this inconsistent with the definition?
AwtMenuItem* AwtMenu::GetItem(jobject target, jint index) |
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.
The declaration and implementation have to match.
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.
To minimise the number of changes, we can go for using jint
in AwtMenu::GetItem
.
What do you thing, @djelinski and @TheShermanTanker?
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.
Hmm, I lean towards jint as I feel it conveys the fact that it is a Java parameter clearer, intuitively to me it makes sense that a Java integer type would still work in a C++ for loop in native code
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.
You're right… it gives a hint it'll be an upcall into Java. Let's go for jint
then.
I don't think there's a need to change the type of the for-loop variable to jint
.
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.
Oh no, I didn't mean to change the loop variable, rather that leaving the jint as is should be fine in the for loop
Wait a minute, I was right, it was a jint the whole time! Oh well, I'll wait for what @aivanov-jdk has to say, but I don't like the idea of leaving both inconsistent |
Alright, waiting for you to do the honours :) |
src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Alexey Ivanov <alexey.ivanov@oracle.com>
Alright, done |
@aivanov-jdk Is the final change ok with you? |
Looks good now. Thanks! I've run client tests, all is green. |
Haha, thanks Alexsey! |
/integrate |
Going to push as commit c92b049.
Your commit was automatically rebased without conflicts. |
@TheShermanTanker Pushed as commit c92b049. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
On Windows, the basic Java Integer types are defined as long and __int64 respectively. In particular, the former is rather problematic since it breaks compilation as the Visual C++ becomes stricter and more compliant with every release, which means the way Windows code treats long as a typedef for int is no longer correct, especially with -permissive- enabled. Instead of changing every piece of broken code to match the jint = long typedef, which is far too time consuming, we can instead change jint to an int (which is still the same 32 bit number type as long), as there are far fewer problems caused by this definition. It's better to get this over and done with sooner than later when a future version of Visual C++ finally starts to break on existing code
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14125/head:pull/14125
$ git checkout pull/14125
Update a local copy of the PR:
$ git checkout pull/14125
$ git pull https://git.openjdk.org/jdk.git pull/14125/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14125
View PR using the GUI difftool:
$ git pr show -t 14125
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14125.diff
Webrev
Link to Webrev Comment