Skip to content
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

8304717: Declaration aliasing between boolean and jboolean is wrong #13139

Closed
wants to merge 5 commits into from

Conversation

TheShermanTanker
Copy link
Contributor

@TheShermanTanker TheShermanTanker commented Mar 22, 2023

A couple of spots wrongly refer to boolean and jboolean as the same thing. While this does still compile thanks to a happy accident and implicit conversions, they are not the same at all, and should be fixed before a future compiler error happens if their declarations are touched


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8304717: Declaration aliasing between boolean and jboolean is wrong

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13139/head:pull/13139
$ git checkout pull/13139

Update a local copy of the PR:
$ git checkout pull/13139
$ git pull https://git.openjdk.org/jdk.git pull/13139/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13139

View PR using the GUI difftool:
$ git pr show -t 13139

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13139.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 22, 2023

👋 Welcome back jwaters! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Mar 22, 2023

@TheShermanTanker The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Mar 22, 2023
@TheShermanTanker TheShermanTanker changed the title WIP 8304717 Mar 22, 2023
@openjdk openjdk bot changed the title 8304717 8304717: Declaration aliasing between boolean and jboolean is wrong Mar 22, 2023
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 22, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 22, 2023

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

One change has an issue but the others seem fine. You really need reviewers from each component area though.

Thanks.

@@ -682,7 +682,7 @@ static void createTreeForPath(CFStringRef path, CFStringRef name,
CFDictionaryRef node;
CFStringRef topKey;
CFMutableDictionaryRef topValue;
Boolean beforeAdd = false;
Copy link
Member

Choose a reason for hiding this comment

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

The return value from CFDictionaryContainsKey is a Boolean and is assigned to this variable. So I think these changes are the wrong way round. Keep this as a Boolean but convert the return value to jboolean:

return beforeAdd ? JNI_TRUE : JNI_FALSE;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Argh, looks like Apple and Objective-C still use the ancient Boolean types from Carbon for the CoreFoundation APIs. Sigh...

@dholmes-ora
Copy link
Member

dholmes-ora commented Mar 24, 2023

/label add awt

Adding AWT folk.

@openjdk
Copy link

openjdk bot commented Mar 24, 2023

@dholmes-ora
The label awt is not a valid label.
These labels are valid:

  • serviceability
  • hotspot
  • hotspot-compiler
  • ide-support
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • hotspot-runtime
  • jmx
  • build
  • nio
  • client
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr

@TheShermanTanker
Copy link
Contributor Author

Correct label for awt is client to my knowledge

@TheShermanTanker
Copy link
Contributor Author

/label client

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Mar 24, 2023
@openjdk
Copy link

openjdk bot commented Mar 24, 2023

@TheShermanTanker
The client label was successfully added.

@dholmes-ora
Copy link
Member

Thanks for the correction I thought the mailing list was awt-dev similar to swing-dev.

@merykitty
Copy link
Member

Is this needed? A boolean-to-int conversion returns 1 if the input is true and 0 otherwise. The opposite returns true for non-zero value and false otherwise. Unless we have some tricky jboolean value that should not happen they should behave the same?

@TheShermanTanker
Copy link
Contributor Author

I'd argue it's more for correctness: Indeed it will still compile fine as of now, but the type of jboolean is not the only thing that can change; the other typedef'd boolean type can also be modified later on. Additionally, with compilers getting stricter as newer releases drop, it's a good idea to make sure the signatures match as best as possible, especially between declarations and definitions of the same method

@@ -695,9 +695,9 @@ static void createTreeForPath(CFStringRef path, CFStringRef name,
beforeAdd = CFDictionaryContainsKey(parent, child);
CFDictionaryAddValue(parent, child, node);
if (!beforeAdd)
beforeAdd = CFDictionaryContainsKey(parent, child);
beforeAdd = CFDictionaryContainsKey(parent, child) ? JNI_TRUE : JNI_FALSE;
Copy link
Member

Choose a reason for hiding this comment

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

If you do this here you need something similar on line 695. Still say it is simpler to use Boolean internally and convert to jboolean on return expression.

Copy link
Contributor

@prrace prrace left a comment

Choose a reason for hiding this comment

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

The single java.desktop change looks OK, so when anyone approves the rest that's implicitly approved.

@TheShermanTanker
Copy link
Contributor Author

Alright, thanks Phil

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Okay. Thanks.

@openjdk
Copy link

openjdk bot commented Apr 11, 2023

@TheShermanTanker 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:

8304717: Declaration aliasing between boolean and jboolean is wrong

Reviewed-by: dholmes

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 235 new commits pushed to the master branch:

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 11, 2023
@TheShermanTanker
Copy link
Contributor Author

Thanks David!

@TheShermanTanker
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Apr 11, 2023

Going to push as commit cd7d53c.
Since your change was applied there have been 237 commits pushed to the master branch:

  • 2586f36: 8304919: Implementation of Virtual Threads
  • 3939807: 8182621: JSSE should reject empty TLS plaintexts
  • 1375130: 8305728: RISC-V: Use bexti instruction to do single-bit testing
  • 4485737: 8304501: Remove orphaned demo netbeans projects
  • 0ff2ff6: 8305807: Spurious right brace in ConstantDescs field Javadocs
  • 2aeb0e5: 6241286: (cal) API: Calendar.DAY_OF_WEEK definition is wrong
  • 42965d3: 6218123: (cal) API: Spec for GregorianCalendar constructors and Calendar getInstance is inconsistent.
  • a43a17c: 8305808: Typo in javadoc of ConstantDescs::BSM_VARHANDLE_STATIC_FIELD
  • ba90dc7: 8304911: Use OperatingSystem enum in some modules
  • 76975da: 8305758: Update the JAR tool man page to indicate -i/--generate-file is deprecated
  • ... and 227 more: https://git.openjdk.org/jdk/compare/ddf1e34c1a0815e8677212f1a7860ca7cf9fc2c9...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 11, 2023
@openjdk openjdk bot closed this Apr 11, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 11, 2023
@openjdk
Copy link

openjdk bot commented Apr 11, 2023

@TheShermanTanker Pushed as commit cd7d53c.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@TheShermanTanker TheShermanTanker deleted the patch-2 branch April 11, 2023 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
4 participants