JDK-6394462 : Hotspot prints "*** Unlock prevents locking optimization"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-03-06
  • Updated: 2010-04-02
  • Resolved: 2006-11-14
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 6 JDK 7 Other
6u4Fixed 7Fixed hs10Fixed
Description
FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta2-b74)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b74, mixed mode, sharing)


FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]


A DESCRIPTION OF THE PROBLEM :
When sample program is run with "-server -XX:+DoEscapeAnalysis" Hotspot prints "*** Unlock prevents locking optimization" messages.

THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class UnlockPrevents
{
    public static void main(String args[])
    {
	for (int n = 0; n < 5; n++)
	    doit();
    }

    public static void doit()
    {
        for (int n = 0; n < 10000; n++) {
	    Histogram h = new Histogram();

	    assertTrue(h.foo() == 1);
	    h.add(3);
	    assertTrue(h.bar() == 0);
	}
    }

    static void assertTrue(boolean x)
    {
    }
}

class Histogram
{
    private int count;
    private double min;

    public synchronized void add(double value)
    {
        if (count++ == 0) {
            min = value;
        } else {
            if (min > value)
                min = value;
        }
    }

    public int foo()
    {
        return 1;
    }

    public synchronized int bar()
    {
        return 0;
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Don't use -XX:+DoEscapeAnalysis.

Comments
EVALUATION extraneous print statement that should have been removed, and was accidentally left in.
14-11-2006