United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6394462 Hotspot prints "*** Unlock prevents locking optimization"
JDK-6394462 : Hotspot prints "*** Unlock prevents locking optimization"

Details
Type:
Bug
Submit Date:
2006-03-06
Status:
Resolved
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2006-11-14
Component:
hotspot
OS:
windows_xp
Sub-Component:
compiler
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
hs10 (b03)

Related Reports
Backport:
Backport:

Sub Tasks

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.
                                     
2006-11-14



Hardware and Software, Engineered to Work Together