Apache Solr open-source search software
Some more cleanups and removal of deprecated SegmentReader GCJ settings
Uwe Schindler1ccd81ce81cd
diff --git a/src/java/org/apache/lucene/index/SegmentReader.java b/src/java/org/apache/lucene/index/SegmentReader.javaindex 027437f9f5d..a73ce26f937 100644--- a/src/java/org/apache/lucene/index/SegmentReader.java+++ b/src/java/org/apache/lucene/index/SegmentReader.java@@ -543,45 +543,6 @@ public class SegmentReader extends IndexReader implements Cloneable {Map<String,Norm> norms = new HashMap<String,Norm>();- /** The class which implements SegmentReader. */- // @deprecated (LUCENE-1677)- private static Class IMPL;- static {- try {- String name =- System.getProperty("org.apache.lucene.SegmentReader.class",- SegmentReader.class.getName());- IMPL = Class.forName(name);- } catch (ClassNotFoundException e) {- throw new RuntimeException("cannot load SegmentReader class: " + e, e);- } catch (SecurityException se) {- try {- IMPL = Class.forName(SegmentReader.class.getName());- } catch (ClassNotFoundException e) {- throw new RuntimeException("cannot load default SegmentReader class: " + e, e);- }- }- }-- // @deprecated (LUCENE-1677)- private static Class READONLY_IMPL;- static {- try {- String name =- System.getProperty("org.apache.lucene.ReadOnlySegmentReader.class",- ReadOnlySegmentReader.class.getName());- READONLY_IMPL = Class.forName(name);- } catch (ClassNotFoundException e) {- throw new RuntimeException("cannot load ReadOnlySegmentReader class: " + e, e);- } catch (SecurityException se) {- try {- READONLY_IMPL = Class.forName(ReadOnlySegmentReader.class.getName());- } catch (ClassNotFoundException e) {- throw new RuntimeException("cannot load default ReadOnlySegmentReader class: " + e, e);- }- }- }-/*** @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error@@ -601,15 +562,7 @@ public class SegmentReader extends IndexReader implements Cloneable {boolean doOpenStores,int termInfosIndexDivisor)throws CorruptIndexException, IOException {- SegmentReader instance;- try {- if (readOnly)- instance = (SegmentReader)READONLY_IMPL.newInstance();- else- instance = (SegmentReader)IMPL.newInstance();- } catch (Exception e) {- throw new RuntimeException("cannot load SegmentReader class: " + e, e);- }+ SegmentReader instance = readOnly ? new ReadOnlySegmentReader() : new SegmentReader();instance.readOnly = readOnly;instance.si = si;instance.readBufferSize = readBufferSize;@@ -717,15 +670,7 @@ public class SegmentReader extends IndexReader implements Cloneable {assert !doClone || (normsUpToDate && deletionsUpToDate);// clone reader- SegmentReader clone;- try {- if (openReadOnly)- clone = (SegmentReader) READONLY_IMPL.newInstance();- else- clone = (SegmentReader) IMPL.newInstance();- } catch (Exception e) {- throw new RuntimeException("cannot load SegmentReader class: " + e, e);- }+ SegmentReader clone = openReadOnly ? new ReadOnlySegmentReader() : new SegmentReader();boolean success = false;try {diff --git a/src/java/org/apache/lucene/store/LockStressTest.java b/src/java/org/apache/lucene/store/LockStressTest.javaindex e6b66b28544..13b7b92c908 100644--- a/src/java/org/apache/lucene/store/LockStressTest.java+++ b/src/java/org/apache/lucene/store/LockStressTest.java@@ -65,30 +65,23 @@ public class LockStressTest {final String lockDirName = args[4];final int sleepTimeMS = Integer.parseInt(args[5]);- Class c;- try {- c = Class.forName(lockFactoryClassName);- } catch (ClassNotFoundException e) {- throw new IOException("unable to find LockClass " + lockFactoryClassName);- }-LockFactory lockFactory;try {- lockFactory = (LockFactory) c.newInstance();+ lockFactory = Class.forName(lockFactoryClassName).asSubclass(LockFactory.class).newInstance();} catch (IllegalAccessException e) {throw new IOException("IllegalAccessException when instantiating LockClass " + lockFactoryClassName);} catch (InstantiationException e) {throw new IOException("InstantiationException when instantiating LockClass " + lockFactoryClassName);} catch (ClassCastException e) {throw new IOException("unable to cast LockClass " + lockFactoryClassName + " instance to a LockFactory");+ } catch (ClassNotFoundException e) {+ throw new IOException("unable to find LockClass " + lockFactoryClassName);}File lockDir = new File(lockDirName);- if (lockFactory instanceof NativeFSLockFactory) {- ((NativeFSLockFactory) lockFactory).setLockDir(lockDir);- } else if (lockFactory instanceof SimpleFSLockFactory) {- ((SimpleFSLockFactory) lockFactory).setLockDir(lockDir);+ if (lockFactory instanceof FSLockFactory) {+ ((FSLockFactory) lockFactory).setLockDir(lockDir);}lockFactory.setLockPrefix("test");diff --git a/src/java/org/apache/lucene/store/MMapDirectory.java b/src/java/org/apache/lucene/store/MMapDirectory.javaindex 87eb816d0e9..e447ccd8189 100644--- a/src/java/org/apache/lucene/store/MMapDirectory.java+++ b/src/java/org/apache/lucene/store/MMapDirectory.java@@ -91,9 +91,6 @@ public class MMapDirectory extends FSDirectory {super(path, null);}- static final Class[] NO_PARAM_TYPES = new Class[0];- static final Object[] NO_PARAMS = new Object[0];-private boolean useUnmapHack = false;private int maxBBuf = Constants.JRE_IS_64BIT ? Integer.MAX_VALUE : (256*1024*1024);@@ -106,7 +103,7 @@ public class MMapDirectory extends FSDirectory {try {Class.forName("sun.misc.Cleaner");Class.forName("java.nio.DirectByteBuffer")- .getMethod("cleaner", NO_PARAM_TYPES);+ .getMethod("cleaner");v = true;} catch (Exception e) {v = false;@@ -151,12 +148,12 @@ public class MMapDirectory extends FSDirectory {AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {public Object run() throws Exception {final Method getCleanerMethod = buffer.getClass()- .getMethod("cleaner", NO_PARAM_TYPES);+ .getMethod("cleaner");getCleanerMethod.setAccessible(true);- final Object cleaner = getCleanerMethod.invoke(buffer, NO_PARAMS);+ final Object cleaner = getCleanerMethod.invoke(buffer);if (cleaner != null) {- cleaner.getClass().getMethod("clean", NO_PARAM_TYPES)- .invoke(cleaner, NO_PARAMS);+ cleaner.getClass().getMethod("clean")+ .invoke(cleaner);}return null;}