Index: lucene/src/java/org/apache/lucene/util/Constants.java =================================================================== --- lucene/src/java/org/apache/lucene/util/Constants.java (revision 1201662) +++ lucene/src/java/org/apache/lucene/util/Constants.java (working copy) @@ -28,13 +28,20 @@ /** The value of System.getProperty("java.version"). **/ public static final String JAVA_VERSION = System.getProperty("java.version"); - /** True iff this is Java version 1.1. */ + + /** True iff this is Java version 1.1. + * @deprecated This constant is useless since Lucene is on Java 5 */ + @Deprecated public static final boolean JAVA_1_1 = JAVA_VERSION.startsWith("1.1."); - /** True iff this is Java version 1.2. */ + /** True iff this is Java version 1.2. + * @deprecated This constant is useless since Lucene is on Java 5 */ + @Deprecated public static final boolean JAVA_1_2 = JAVA_VERSION.startsWith("1.2."); - /** True iff this is Java version 1.3. */ + /** True iff this is Java version 1.3. + * @deprecated This constant is useless since Lucene is on Java 5 */ + @Deprecated public static final boolean JAVA_1_3 = JAVA_VERSION.startsWith("1.3."); - + /** The value of System.getProperty("os.name"). **/ public static final String OS_NAME = System.getProperty("os.name"); /** True iff running on Linux. */ @@ -66,6 +73,17 @@ } } + public static final boolean JRE_IS_MINIMUM_JAVA6; + static { + boolean v = true; + try { + String.class.getMethod("isEmpty"); + } catch (NoSuchMethodException me) { + v = false; + } + JRE_IS_MINIMUM_JAVA6 = v; + } + // this method prevents inlining the final version constant in compiled classes, // see: http://www.javaworld.com/community/node/3400 private static String ident(final String s) { Index: lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java =================================================================== --- lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java (revision 1201662) +++ lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java (working copy) @@ -19,7 +19,10 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; +import java.util.Collections; +import java.util.HashMap; import java.util.Map; +import org.apache.lucene.util.Constants; /** * Simple concurrent LRU cache, using a "double barrel" @@ -58,8 +61,13 @@ public DoubleBarrelLRUCache(int maxSize) { this.maxSize = maxSize; countdown = new AtomicInteger(maxSize); - cache1 = new ConcurrentHashMap(); - cache2 = new ConcurrentHashMap(); + if (Constants.JRE_IS_MINIMUM_JAVA6) { + cache1 = new ConcurrentHashMap(); + cache2 = new ConcurrentHashMap(); + } else { + cache1 = Collections.synchronizedMap(new HashMap()); + cache2 = Collections.synchronizedMap(new HashMap()); + } } @SuppressWarnings("unchecked")