# HG changeset patch # User Doug Simon # Date 1502179539 -7200 # Node ID 7d8e0c328b640a0f1c60ea6f59cbf72b04f721e5 # Parent 0137da2b56d9db3f215d88eb38805e3442f2d8b8 fix NPE possibility in HotSpotSpeculationLog.speculate (JDK-8185950) diff -r 0137da2b56d9 -r 7d8e0c328b64 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java Thu Aug 03 11:53:11 2017 -0700 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java Tue Aug 08 10:05:39 2017 +0200 @@ -39,7 +39,7 @@ private Set failedSpeculations; /** Strong references to all reasons embedded in the current nmethod. */ - private volatile Collection speculations; + private Collection speculations; @Override public synchronized void collectFailedSpeculations() { @@ -70,14 +70,12 @@ * reason objects that are embedded in nmethods, so we add them to the speculations * collection. */ - if (speculations == null) { - synchronized (this) { - if (speculations == null) { - speculations = new ConcurrentLinkedQueue<>(); - } + synchronized (this) { + if (speculations == null) { + speculations = new ConcurrentLinkedQueue<>(); } + speculations.add(reason); } - speculations.add(reason); return HotSpotObjectConstantImpl.forObject(reason); }