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

8052260: Reference.isEnqueued() spec does not match the long-standing behavior returning true iff it's in the ref queue #1684

Closed
wants to merge 5 commits into from

Conversation

mlchung
Copy link
Member

@mlchung mlchung commented Dec 8, 2020

Reference::isEnqueued method was never implemented as it was initially specified since 1.2. The specification says that it tests if this reference object has been enqueued, but the long-standing behavior is to test if this reference object is in its associated queue, only reflecting the state at the time when this method is executed. The implementation doesn't do what the specification promised, which might cause serious bugs if unnoticed. For example, an application that relies on this method to release critical resources could cause serious performance issues, in particular when this method is misused on Reference objects without an associated queue. Reference::refersTo(null) is the better recommended way to test if a Reference object has been cleared.

This proposes to deprecate Reference::isEnqueued. Also the spec is updated to match the long-standing behavior.

CSR: https://bugs.openjdk.java.net/browse/JDK-8189386


Progress

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

Issue

  • JDK-8052260: Reference.isEnqueued() spec does not match the long-standing behavior returning true iff it's in the ref queue

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/1684/head:pull/1684
$ git checkout pull/1684

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 8, 2020

👋 Welcome back mchung! 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 8, 2020
@mlchung
Copy link
Member Author

mlchung commented Dec 8, 2020

/csr

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Dec 8, 2020
@openjdk
Copy link

openjdk bot commented Dec 8, 2020

@mlchung this pull request will not be integrated until the CSR request JDK-8189386 for issue JDK-8052260 has been approved.

@openjdk
Copy link

openjdk bot commented Dec 8, 2020

@mlchung 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 8, 2020
@mlbridge
Copy link

mlbridge bot commented Dec 8, 2020

Webrevs

Copy link

@kimbarrett kimbarrett left a comment

This change looks good. There are a couple of tests that are using isEnqueued.
vmTestbase/gc/gctests/ReferencesGC/ReferencesGC.java
jdk/java/lang/ref/ReferenceEnqueue.java
https://bugs.openjdk.java.net/browse/JDK-8257876
(I'm working on this.)

@mlchung
Copy link
Member Author

mlchung commented Dec 8, 2020

Thanks, Kim. It's good to update the tests (thanks for working on it).

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Dec 8, 2020
@openjdk
Copy link

openjdk bot commented Dec 8, 2020

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

8052260: Reference.isEnqueued() spec does not match the long-standing behavior returning true iff it's in the ref queue

Reviewed-by: kbarrett, alanb

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

  • 0201a33: 8255959: Timeouts in VectorConversion tests
  • d3dddb6: 8256657: Add cross-compiled build for Windows+Arm64 to submit workflow
  • 616b1f1: 8257516: define test group for manual tests
  • 5bdce9b: 8257639: Update usage of "type" terminology in java.lang.Enum & java.lang.Record
  • b4615c6: 8256580: Fault in new grid display
  • df55ecd: 8257794: Zero: assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1) failed: wrong on Linux/x86_32
  • fae7961: 8257884: Re-enable sun/security/ssl/SSLSocketImpl/SSLSocketLeak.java as automatic test
  • 79f1dfb: 8255987: JDI tests fail with com.sun.jdi.ObjectCollectedException
  • 9ce3d80: 8257887: java/foreign/TestSegments.java test fails on 32-bit after JDK-8257186
  • 10da767: 8257847: Tiered should publish MDO data pointer for interpreter after profile start
  • ... and 6 more: https://git.openjdk.java.net/jdk/compare/f48d5d1b7ee01cff172f8049c7fa1e878f04631d...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 openjdk bot added the ready Pull request is ready to be integrated label Dec 8, 2020
* @deprecated
* This method was never implemented to test if a reference object has
* been cleared and enqueued as it was previously specified since 1.2.
* This method could be misused due to the inherent race condition
Copy link
Contributor

@AlanBateman AlanBateman Dec 8, 2020

Choose a reason for hiding this comment

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

A small suggestion is to restructure the first sentence of the deprecated message to say "This method was originally specified to test .. but was never implemented to do this test", otherwise looks okay.

Copy link
Member Author

@mlchung mlchung Dec 8, 2020

Choose a reason for hiding this comment

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

Yes, it reads better and we can also drop "as it was previously specified since 1.2".

     * This method was originally specified to test if a reference object has
     * been cleared and enqueued but was never implemented to do this test.

@mlchung
Copy link
Member Author

mlchung commented Dec 9, 2020

/integrate

@openjdk openjdk bot closed this Dec 9, 2020
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 9, 2020
@openjdk
Copy link

openjdk bot commented Dec 9, 2020

@mlchung Since your change was applied there have been 22 commits pushed to the master branch:

  • 6dd06ad: 8254996: make jdk.net.UnixDomainPrincipal a record class
  • bd22aa5: 8229862: NPE in jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0(Code.java:570)
  • cf62b0a: 8257518: LogCompilation: java.lang.InternalError with JFR turned on
  • 6c69eca: 8257973: UTIL_LOOKUP_PROGS should only find executable files
  • 6eff931: 8256950: Add record attribute support to symbol generator CreateSymbols
  • f148915: 8245107: Use Unified Logging in trace_method_handle_stub()
  • 0201a33: 8255959: Timeouts in VectorConversion tests
  • d3dddb6: 8256657: Add cross-compiled build for Windows+Arm64 to submit workflow
  • 616b1f1: 8257516: define test group for manual tests
  • 5bdce9b: 8257639: Update usage of "type" terminology in java.lang.Enum & java.lang.Record
  • ... and 12 more: https://git.openjdk.java.net/jdk/compare/f48d5d1b7ee01cff172f8049c7fa1e878f04631d...master

Your commit was automatically rebased without conflicts.

Pushed as commit 5f03341.

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

@mlchung mlchung deleted the isEnqueued branch Mar 25, 2021
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
3 participants