# HG changeset patch # User Stefan Anzinger # Date 1430774142 -7200 # Node ID e11eb6ec180e7b68c657b6ba68f8157e38ec75a0 # Parent bfb6e742ad0aef19fc1da28283cb316d275a0dd2 Use double-checked locking in HotSpotConstantPool.lookupType. diff -r bfb6e742ad0a -r e11eb6ec180e graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java Mon May 04 19:34:51 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java Mon May 04 23:15:42 2015 +0200 @@ -489,16 +489,20 @@ @Override public JavaType lookupType(int cpi, int opcode) { - synchronized (this) { - if (cpi == this.lastTypeCpi) { - return this.lastType; + if (cpi == this.lastTypeCpi) { + synchronized (this) { + if (cpi == this.lastTypeCpi) { + return this.lastType; + } } } final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, cpi); JavaType result = getJavaType(metaspacePointer); if (result instanceof ResolvedJavaType) { - this.lastType = (ResolvedJavaType) result; - this.lastTypeCpi = cpi; + synchronized (this) { + this.lastType = (ResolvedJavaType) result; + this.lastTypeCpi = cpi; + } } return result; }