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

8337840: Remove redundant null check in ObjectOutputStream.writeProxyDesc #20351

Conversation

turbanoff
Copy link
Member

@turbanoff turbanoff commented Jul 26, 2024

There is implicit null check in line before.

Class<?> cl = desc.forClass();
Class<?>[] ifaces = cl.getInterfaces();
bout.writeInt(ifaces.length);
for (int i = 0; i < ifaces.length; i++) {
bout.writeUTF(ifaces[i].getName());
}
bout.setBlockDataMode(true);
if (cl != null && isCustomSubclass()) {
ReflectUtil.checkPackageAccess(cl);
}

'cl' can't be null after that.


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-8337840: Remove redundant null check in ObjectOutputStream.writeProxyDesc (Enhancement - P5)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20351

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

Using diff file

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

Webrev

Link to Webrev Comment

There is implicit null check in line before this:

Class<?>[] ifaces = cl.getInterfaces();

'cl' can't be null after that.
@bridgekeeper
Copy link

bridgekeeper bot commented Jul 26, 2024

👋 Welcome back aturbanov! 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 Jul 26, 2024

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

8337840: Remove redundant null check in ObjectOutputStream.writeProxyDesc

Reviewed-by: rriggs

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

  • d19ba81: 8337603: Change in behavior with -Djava.locale.useOldISOCodes=true
  • 21f710e: 8310675: Fix -Wconversion warnings in ZGC code
  • 88a05a8: 8337975: [BACKOUT] Native memory leak when not recording any events
  • 41f784f: 8335925: Serial: Move allocation API from Generation to subclasses
  • 66286b2: 8337968: Problem list compiler/vectorapi/VectorRebracket128Test.java
  • 920751e: 8311990: Two JDI tests may interfere with each other
  • 6733b89: 8337667: sun/tools/jcmd/TestJcmdPIDSubstitution.java is failing on mac and windows
  • fc652d2: 8235404: [macos] JOptionPane blocks drawing string on another component
  • 22a3421: 8337786: Fix simple -Wzero-as-null-pointer-constant warnings in aarch64 code
  • ff634a9: 8337506: Disable "best-fit" mapping on Windows command line
  • ... and 102 more: https://git.openjdk.org/jdk/compare/5ff7c57f9ff5428ef3d2aedd7e860bb1e8ff29ea...master

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
Copy link

openjdk bot commented Jul 26, 2024

@turbanoff 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 Jul 26, 2024
@turbanoff turbanoff changed the title [PATCH] Remove redundant null check in ObjectOutputStream.writeProxyDesc 8337840: Remove redundant null check in ObjectOutputStream.writeProxyDesc Aug 5, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 5, 2024
@mlbridge
Copy link

mlbridge bot commented Aug 5, 2024

Webrevs

@jaikiran
Copy link
Member

jaikiran commented Aug 6, 2024

That null check appears to have been added as part of https://mail.openjdk.org/pipermail/core-libs-dev/2014-April/026379.html. The change in that previous commit introduced 2 null checks - one in writeProxyDesc() and one in writeNonProxyDesc(). The null check added in writeProxyDesc() appears to be a copy/paste issue and as you note that null check essentially is a no-op because the cl has already been dereferenced a few lines above. Removing this redundant null check seems OK to me.

Having said that, I think we might have to consider if that null check needs to be moved just after the call to desc.forClass(). Apparently that call is allowed to return null (which is what prompted the original commit).

I would wait for Roger or someone more familiar with this area to recommend what needs to be done here.

Copy link
Contributor

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

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

lgtm
Hotspot would have elided this check anyway based on the previous implicit check.
The review overhead is higher than the value add to the source.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 7, 2024
@turbanoff
Copy link
Member Author

Thank you for review!

/integrate

@openjdk
Copy link

openjdk bot commented Aug 9, 2024

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

  • c01f53a: 8337876: [IR Framework] Add support for IR tests with @stable
  • 00aac40: 8338058: map_or_reserve_memory_aligned Windows enhance remap assertion
  • 9ab8c6b: 8335130: The test "javax/swing/plaf/synth/ComponentsOrientationSupport/5033822/bug5033822.java" fails because the background color of the tabs is displayed incorrectly.
  • 0c1e911: 8338019: Fix simple -Wzero-as-null-pointer-constant warnings in riscv code
  • 55c5097: 8337331: crash: pinned virtual thread will lead to jvm crash when running with the javaagent option
  • 9f08a01: 8338010: WB_IsFrameDeoptimized miss ResourceMark
  • e7a0b5b: 8334780: Crash: assert(h_array_list.not_null()) failed: invariant
  • bfb75b9: 8336926: jdk/internal/util/ReferencedKeyTest.java can fail with ConcurrentModificationException
  • 53c9f03: 8336849: Remove .llvm_addrsig section from JDK/VM static libraries (.a files)
  • 9695f09: 8337683: Fix -Wconversion problem with arrayOop.hpp
  • ... and 127 more: https://git.openjdk.org/jdk/compare/5ff7c57f9ff5428ef3d2aedd7e860bb1e8ff29ea...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 9, 2024

@turbanoff Pushed as commit 82d5768.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants