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

8261404: Class.getReflectionFactory() is not thread-safe #6870

Closed
wants to merge 3 commits into from

Conversation

liach
Copy link
Member

@liach liach commented Dec 16, 2021

Simply changes this to only read the static field once to prevent null on second read.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8261404: Class.getReflectionFactory() is not thread-safe

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6870/head:pull/6870
$ git checkout pull/6870

Update a local copy of the PR:
$ git checkout pull/6870
$ git pull https://git.openjdk.java.net/jdk pull/6870/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6870

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6870.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 16, 2021

👋 Welcome back liach! 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 openjdk bot added the rfr Pull request is ready for review label Dec 16, 2021
@openjdk
Copy link

openjdk bot commented Dec 16, 2021

@liach 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 Dec 16, 2021
@mlbridge
Copy link

mlbridge bot commented Dec 16, 2021

Webrevs

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.

It would be easier to read and clearer if the local was not named the same as the static.

if (reflectionFactory == null) {
reflectionFactory =
return Class.reflectionFactory =
java.security.AccessController.doPrivileged
(new ReflectionFactory.GetReflectionFactoryAction());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

p.s. If using an early return, I'd have it return early in the case reflectionFactory was not-null.
then fall through to compute and assign the factory and return it.

        var factory = reflectionFactory;
        if (factory != null) {
            return factory;
        }
        return reflectionFactory =
            java.security.AccessController.doPrivileged
                (new ReflectionFactory.GetReflectionFactoryAction());

@openjdk
Copy link

openjdk bot commented Dec 16, 2021

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

8261404: Class.getReflectionFactory() is not thread-safe

Reviewed-by: rriggs, mchung

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

  • 022e4f0: 8275242: Remove redundant stream() call before forEach in jdk.compiler
  • 0bfc204: 8278956: Remove unimplemented PLAB::allocate_aligned
  • b17f8d5: 8278954: Using clang together with devkit on linux doesn't work for building
  • 769f14d: 8278384: Bytecodes::result_type() for arraylength returns T_VOID instead of T_INT
  • e45e0b0: 8278937: JCK test for java_awt/geom/Line2D.Float fails after 8277868
  • a68f28c: 8278909: Unproblemlist AdaptiveBlocking001
  • 3607a5c: 8277216: Examine InstanceKlass::_misc_flags for concurrency issues
  • abab173: 8278568: Consolidate filler objects
  • 6412d57: 8278560: X509KeyManagerImpl::getAliases might return a good key with others
  • 247ea71: 8278826: Print error if Shenandoah flags are empty (instead of crashing)
  • ... and 9 more: https://git.openjdk.java.net/jdk/compare/937126b1406ff0f6ac0828310e5e09003692dcd3...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@RogerRiggs, @mlchung) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 16, 2021
@liach
Copy link
Member Author

liach commented Dec 17, 2021

Should've been 24 hours for people in different time zones to review.

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Dec 17, 2021
@openjdk
Copy link

openjdk bot commented Dec 17, 2021

@liach
Your change (at version acc043e) is now ready to be sponsored by a Committer.

@mlchung
Copy link
Member

mlchung commented Dec 17, 2021

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 17, 2021

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

  • 022e4f0: 8275242: Remove redundant stream() call before forEach in jdk.compiler
  • 0bfc204: 8278956: Remove unimplemented PLAB::allocate_aligned
  • b17f8d5: 8278954: Using clang together with devkit on linux doesn't work for building
  • 769f14d: 8278384: Bytecodes::result_type() for arraylength returns T_VOID instead of T_INT
  • e45e0b0: 8278937: JCK test for java_awt/geom/Line2D.Float fails after 8277868
  • a68f28c: 8278909: Unproblemlist AdaptiveBlocking001
  • 3607a5c: 8277216: Examine InstanceKlass::_misc_flags for concurrency issues
  • abab173: 8278568: Consolidate filler objects
  • 6412d57: 8278560: X509KeyManagerImpl::getAliases might return a good key with others
  • 247ea71: 8278826: Print error if Shenandoah flags are empty (instead of crashing)
  • ... and 9 more: https://git.openjdk.java.net/jdk/compare/937126b1406ff0f6ac0828310e5e09003692dcd3...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 17, 2021
@openjdk openjdk bot closed this Dec 17, 2021
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Dec 17, 2021
@openjdk
Copy link

openjdk bot commented Dec 17, 2021

@mlchung @liach Pushed as commit 905b763.

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

@liach liach deleted the 8261404 branch May 7, 2023 00:55
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