JDK-8178832 : (ref) jdk.lang.ref.disableClearBeforeEnqueue property is ignored
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2017-04-14
  • Updated: 2022-08-22
  • Resolved: 2017-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8 JDK 9 Other
10Fixed 8u351Fixed 9 b167Fixed openjdk8u352Fixed
Related Reports
CSR :  
Relates :  
Relates :  
Description
JDK-8175797 changed Reference.enqueue to clear the reference object before adding it to its associated queue.  For backward compatibility, the property jdk.lang.ref.disableClearBeforeEnqueue was introduced to allow reverting to the old behavior.

Unfortunately, due to bootstrapping problems, the value of that property is always ignored.  The Reference class's initializer attempts to get the property value, but at that point the property mechanism is not yet ready for use.  That failure is silently ignored because it occurs in Boolean.getBoolean, which silently swallows the NullPointerExcepion resulting from the too early access.  As a result, it is not possible to revert to the old behavior.

Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk8u-dev/pull/99 Date: 2022-08-11 19:12:23 +0000
11-08-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk8u-ri/pull/5 Date: 2022-04-20 00:15:58 +0000
20-04-2022

URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/63a174bf063a User: lana Date: 2017-04-26 19:55:46 +0000
26-04-2017

URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/63a174bf063a User: kbarrett Date: 2017-04-19 04:35:50 +0000
19-04-2017

Approved for JDK 9 as otherwise we have no way to restore previous behavior for applications that might depend on it.
18-04-2017

Fix Request Without this fix, there is no way to obtain the old (non-clearing) behavior of Reference.enqueue if an application has problems with the new behavior. The proposed change also includes fixing the test that should have detected this problem, but failed to do so because of bugs in the test. The fix is low risk. It defers reading the property until first use, rather than reading it so early that it runs afoul of bootstrapping issues. Since Reference.enqueue is not used at all (outside of tests) by the jdk, there isn't a risk of some other bootstrapping problem. Webrev of the fix is here: http://cr.openjdk.java.net/~kbarrett/8178832/jdk00/
18-04-2017

A proposed patch: diff --git a/src/java.base/share/classes/java/lang/ref/Reference.java b/src/java.base/share/classes/java/lang/ref/Reference.java --- a/src/java.base/share/classes/java/lang/ref/Reference.java +++ b/src/java.base/share/classes/java/lang/ref/Reference.java @@ -143,8 +143,10 @@ /* * system property to disable clearing before enqueuing. */ - private static final boolean disableClearBeforeEnqueue + static class ClearBeforeEnqueue { + static final boolean DISABLE = Boolean.getBoolean("jdk.lang.ref.disableClearBeforeEnqueue"); + } /* * Atomically get and clear (set to null) the VM's pending list. @@ -297,7 +299,7 @@ * it was not registered with a queue when it was created */ public boolean enqueue() { - if (!disableClearBeforeEnqueue) + if (!ClearBeforeEnqueue.DISABLE) this.referent = null; return this.queue.enqueue(this); }
17-04-2017