### Eclipse Workspace Patch 1.0 #P lucene-trunk Index: src/java/org/apache/lucene/index/TermInfosReader.java =================================================================== --- src/java/org/apache/lucene/index/TermInfosReader.java (revision 827821) +++ src/java/org/apache/lucene/index/TermInfosReader.java (working copy) @@ -289,7 +289,7 @@ /** Returns an enumeration of all the Terms and TermInfos in the set. */ public SegmentTermEnum terms() { - return (SegmentTermEnum)origEnum.clone(); + return origEnum.clone(); } /** Returns an enumeration of terms starting at or after the named term. */ @@ -297,6 +297,6 @@ // don't use the cache in this call because we want to reposition the // enumeration get(term, false); - return (SegmentTermEnum)getThreadResources().termEnum.clone(); + return getThreadResources().termEnum.clone(); } } Index: src/java/org/apache/lucene/search/spans/SpanNearQuery.java =================================================================== --- src/java/org/apache/lucene/search/spans/SpanNearQuery.java (revision 827821) +++ src/java/org/apache/lucene/search/spans/SpanNearQuery.java (working copy) @@ -127,7 +127,7 @@ SpanQuery query = (SpanQuery) c.rewrite(reader); if (query != c) { // clause rewrote: must clone if (clone == null) - clone = (SpanNearQuery) this.clone(); + clone = this.clone(); clone.clauses.set(i,query); } } @@ -138,7 +138,7 @@ } } - public Object clone() { + public SpanNearQuery clone() { int sz = clauses.size(); SpanQuery[] newClauses = new SpanQuery[sz]; Index: src/java/org/apache/lucene/store/BufferedIndexInput.java =================================================================== --- src/java/org/apache/lucene/store/BufferedIndexInput.java (revision 827821) +++ src/java/org/apache/lucene/store/BufferedIndexInput.java (working copy) @@ -188,7 +188,7 @@ */ protected abstract void seekInternal(long pos) throws IOException; - public Object clone() { + public BufferedIndexInput clone() { BufferedIndexInput clone = (BufferedIndexInput)super.clone(); clone.buffer = null; Index: src/java/org/apache/lucene/analysis/tokenattributes/TermAttributeImpl.java =================================================================== --- src/java/org/apache/lucene/analysis/tokenattributes/TermAttributeImpl.java (revision 827821) +++ src/java/org/apache/lucene/analysis/tokenattributes/TermAttributeImpl.java (working copy) @@ -175,7 +175,7 @@ termLength = 0; } - public Object clone() { + public TermAttributeImpl clone() { TermAttributeImpl t = (TermAttributeImpl)super.clone(); // Do a deep clone if (termBuffer != null) { Index: contrib/db/bdb/src/java/org/apache/lucene/store/db/DbIndexInput.java =================================================================== --- contrib/db/bdb/src/java/org/apache/lucene/store/db/DbIndexInput.java (revision 827821) +++ contrib/db/bdb/src/java/org/apache/lucene/store/db/DbIndexInput.java (working copy) @@ -47,7 +47,7 @@ block.get(directory); } - public Object clone() + public DbIndexInput clone() { try { DbIndexInput clone = (DbIndexInput) super.clone(); Index: src/java/org/apache/lucene/index/TermVectorsReader.java =================================================================== --- src/java/org/apache/lucene/index/TermVectorsReader.java (revision 827821) +++ src/java/org/apache/lucene/index/TermVectorsReader.java (working copy) @@ -520,16 +520,16 @@ } } - protected Object clone() throws CloneNotSupportedException { + protected TermVectorsReader clone() throws CloneNotSupportedException { final TermVectorsReader clone = (TermVectorsReader) super.clone(); // These are null when a TermVectorsReader was created // on a segment that did not have term vectors saved if (tvx != null && tvd != null && tvf != null) { - clone.tvx = (IndexInput) tvx.clone(); - clone.tvd = (IndexInput) tvd.clone(); - clone.tvf = (IndexInput) tvf.clone(); + clone.tvx = tvx.clone(); + clone.tvd = tvd.clone(); + clone.tvf = tvf.clone(); } return clone; Index: src/test/org/apache/lucene/search/QueryUtils.java =================================================================== --- src/test/org/apache/lucene/search/QueryUtils.java (revision 827821) +++ src/test/org/apache/lucene/search/QueryUtils.java (working copy) @@ -46,10 +46,10 @@ /** check very basic hashCode and equals */ public static void checkHashEquals(Query q) { - Query q2 = (Query)q.clone(); + Query q2 = q.clone(); checkEqual(q,q2); - Query q3 = (Query)q.clone(); + Query q3 = q.clone(); q3.setBoost(7.21792348f); checkUnequal(q,q3); @@ -119,7 +119,7 @@ checkExplanations(q1,s); checkSerialization(q1,s); - Query q2 = (Query)q1.clone(); + Query q2 = q1.clone(); checkEqual(s.rewrite(q1), s.rewrite(q2)); } Index: src/test/org/apache/lucene/index/TestIndexWriter.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexWriter.java (revision 827821) +++ src/test/org/apache/lucene/index/TestIndexWriter.java (working copy) @@ -4321,7 +4321,7 @@ writer2.close(); IndexReader r1 = IndexReader.open(dir2, true); - IndexReader r2 = (IndexReader) r1.clone(); + IndexReader r2 = r1.clone(); writer.addIndexes(new IndexReader[] {r1, r2}); writer.close(); Index: src/test/org/apache/lucene/index/TestMultiLevelSkipList.java =================================================================== --- src/test/org/apache/lucene/index/TestMultiLevelSkipList.java (revision 827821) +++ src/test/org/apache/lucene/index/TestMultiLevelSkipList.java (working copy) @@ -152,8 +152,8 @@ return this.input.length(); } - public Object clone() { - return new CountingStream((IndexInput) this.input.clone()); + public CountingStream clone() { + return new CountingStream(this.input.clone()); } } Index: src/java/org/apache/lucene/index/FieldInfo.java =================================================================== --- src/java/org/apache/lucene/index/FieldInfo.java (revision 827821) +++ src/java/org/apache/lucene/index/FieldInfo.java (working copy) @@ -55,7 +55,7 @@ } } - public Object clone() { + public FieldInfo clone() { return new FieldInfo(name, isIndexed, number, storeTermVector, storePositionWithTermVector, storeOffsetWithTermVector, omitNorms, storePayloads, omitTermFreqAndPositions); } Index: src/test/org/apache/lucene/index/TestFieldsReader.java =================================================================== --- src/test/org/apache/lucene/index/TestFieldsReader.java (revision 827821) +++ src/test/org/apache/lucene/index/TestFieldsReader.java (working copy) @@ -362,8 +362,8 @@ public void close() throws IOException { delegate.close(); } - public Object clone() { - return new FaultyIndexInput((IndexInput) delegate.clone()); + public FaultyIndexInput clone() { + return new FaultyIndexInput(delegate.clone()); } } Index: src/java/org/apache/lucene/util/AttributeSource.java =================================================================== --- src/java/org/apache/lucene/util/AttributeSource.java (revision 827821) +++ src/java/org/apache/lucene/util/AttributeSource.java (working copy) @@ -269,12 +269,12 @@ private AttributeImpl attribute; private State next; - public Object clone() { + public State clone() { State clone = new State(); - clone.attribute = (AttributeImpl) attribute.clone(); + clone.attribute = attribute.clone(); if (next != null) { - clone.next = (State) next.clone(); + clone.next = next.clone(); } return clone; @@ -322,7 +322,7 @@ if (currentState == null) { computeCurrentState(); } - return (State) this.currentState.clone(); + return this.currentState.clone(); } /** @@ -435,7 +435,7 @@ computeCurrentState(); } for (State state = currentState; state != null; state = state.next) { - clone.attributeImpls.put(state.attribute.getClass(), (AttributeImpl) state.attribute.clone()); + clone.attributeImpls.put(state.attribute.getClass(), state.attribute.clone()); } } Index: src/java/org/apache/lucene/index/CompoundFileReader.java =================================================================== --- src/java/org/apache/lucene/index/CompoundFileReader.java (revision 827821) +++ src/java/org/apache/lucene/index/CompoundFileReader.java (working copy) @@ -215,14 +215,14 @@ CSIndexInput(final IndexInput base, final long fileOffset, final long length, int readBufferSize) { super(readBufferSize); - this.base = (IndexInput)base.clone(); + this.base = base.clone(); this.fileOffset = fileOffset; this.length = length; } - public Object clone() { + public CSIndexInput clone() { CSIndexInput clone = (CSIndexInput)super.clone(); - clone.base = (IndexInput)base.clone(); + clone.base = base.clone(); clone.fileOffset = fileOffset; clone.length = length; return clone; Index: src/java/org/apache/lucene/index/IndexReader.java =================================================================== --- src/java/org/apache/lucene/index/IndexReader.java (revision 827821) +++ src/java/org/apache/lucene/index/IndexReader.java (working copy) @@ -395,7 +395,7 @@ * @throws CorruptIndexException if the index is corrupt * @throws IOException if there is a low-level IO error */ - public synchronized Object clone() { + public synchronized IndexReader clone() { throw new UnsupportedOperationException("This reader does not implement clone()"); } Index: src/java/org/apache/lucene/search/BooleanQuery.java =================================================================== --- src/java/org/apache/lucene/search/BooleanQuery.java (revision 827821) +++ src/java/org/apache/lucene/search/BooleanQuery.java (working copy) @@ -374,7 +374,7 @@ if (getBoost() != 1.0f) { // incorporate boost if (query == c.getQuery()) // if rewrite was no-op - query = (Query)query.clone(); // then clone before boost + query = query.clone(); // then clone before boost query.setBoost(getBoost() * query.getBoost()); } @@ -388,7 +388,7 @@ Query query = c.getQuery().rewrite(reader); if (query != c.getQuery()) { // clause rewrote: must clone if (clone == null) - clone = (BooleanQuery)this.clone(); + clone = this.clone(); clone.clauses.set(i, new BooleanClause(query, c.getOccur())); } } @@ -407,7 +407,7 @@ } @Override - public Object clone() { + public BooleanQuery clone() { BooleanQuery clone = (BooleanQuery)super.clone(); clone.clauses = (ArrayList)this.clauses.clone(); return clone; Index: src/java/org/apache/lucene/util/AttributeImpl.java =================================================================== --- src/java/org/apache/lucene/util/AttributeImpl.java (revision 827821) +++ src/java/org/apache/lucene/util/AttributeImpl.java (working copy) @@ -110,10 +110,10 @@ * Shallow clone. Subclasses must override this if they * need to clone any members deeply, */ - public Object clone() { - Object clone = null; + public AttributeImpl clone() { + AttributeImpl clone = null; try { - clone = super.clone(); + clone = (AttributeImpl) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); // shouldn't happen } Index: src/test/org/apache/lucene/util/TestOpenBitSet.java =================================================================== --- src/test/org/apache/lucene/util/TestOpenBitSet.java (revision 827821) +++ src/test/org/apache/lucene/util/TestOpenBitSet.java (working copy) @@ -118,21 +118,21 @@ fromIndex = rand.nextInt(sz+80); toIndex = fromIndex + rand.nextInt((sz>>1)+1); BitSet aa = (BitSet)a.clone(); aa.flip(fromIndex,toIndex); - OpenBitSet bb = (OpenBitSet)b.clone(); bb.flip(fromIndex,toIndex); + OpenBitSet bb = b.clone(); bb.flip(fromIndex,toIndex); doIterate(aa,bb, mode); // a problem here is from flip or doIterate fromIndex = rand.nextInt(sz+80); toIndex = fromIndex + rand.nextInt((sz>>1)+1); aa = (BitSet)a.clone(); aa.clear(fromIndex,toIndex); - bb = (OpenBitSet)b.clone(); bb.clear(fromIndex,toIndex); + bb = b.clone(); bb.clear(fromIndex,toIndex); doNextSetBit(aa,bb); // a problem here is from clear() or nextSetBit fromIndex = rand.nextInt(sz+80); toIndex = fromIndex + rand.nextInt((sz>>1)+1); aa = (BitSet)a.clone(); aa.set(fromIndex,toIndex); - bb = (OpenBitSet)b.clone(); bb.set(fromIndex,toIndex); + bb = b.clone(); bb.set(fromIndex,toIndex); doNextSetBit(aa,bb); // a problem here is from set() or nextSetBit @@ -147,10 +147,10 @@ BitSet a_xor = (BitSet)a.clone(); a_xor.xor(a0); BitSet a_andn = (BitSet)a.clone(); a_andn.andNot(a0); - OpenBitSet b_and = (OpenBitSet)b.clone(); assertEquals(b,b_and); b_and.and(b0); - OpenBitSet b_or = (OpenBitSet)b.clone(); b_or.or(b0); - OpenBitSet b_xor = (OpenBitSet)b.clone(); b_xor.xor(b0); - OpenBitSet b_andn = (OpenBitSet)b.clone(); b_andn.andNot(b0); + OpenBitSet b_and = b.clone(); assertEquals(b,b_and); b_and.and(b0); + OpenBitSet b_or = b.clone(); b_or.or(b0); + OpenBitSet b_xor = b.clone(); b_xor.xor(b0); + OpenBitSet b_andn = b.clone(); b_andn.andNot(b0); doIterate(a_and,b_and, mode); doIterate(a_or,b_or, mode); Index: src/java/org/apache/lucene/index/SegmentReader.java =================================================================== --- src/java/org/apache/lucene/index/SegmentReader.java (revision 827821) +++ src/java/org/apache/lucene/index/SegmentReader.java (working copy) @@ -294,7 +294,7 @@ */ private class FieldsReaderLocal extends CloseableThreadLocal { protected FieldsReader initialValue() { - return (FieldsReader) core.getFieldsReaderOrig().clone(); + return core.getFieldsReaderOrig().clone(); } } @@ -491,7 +491,7 @@ // Returns a copy of this Norm instance that shares // IndexInput & bytes with the original one - public synchronized Object clone() { + public synchronized Norm clone() { assert refCount > 0 && (origNorm == null || origNorm.refCount > 0); Norm clone; @@ -677,10 +677,10 @@ * @return New BitVector */ protected BitVector cloneDeletedDocs(BitVector bv) { - return (BitVector)bv.clone(); + return bv.clone(); } - public final synchronized Object clone() { + public final synchronized IndexReader clone() { try { return clone(readOnly); // Preserve current readOnly } catch (Exception ex) { @@ -772,7 +772,7 @@ final String curField = core.fieldInfos.fieldInfo(i).name; Norm norm = this.norms.get(curField); if (norm != null) - clone.norms.put(curField, (Norm) norm.clone()); + clone.norms.put(curField, norm.clone()); } } @@ -1156,7 +1156,7 @@ return null; } else { try { - tvReader = (TermVectorsReader) orig.clone(); + tvReader = orig.clone(); } catch (CloneNotSupportedException cnse) { return null; } Index: src/java/org/apache/lucene/search/function/CustomScoreQuery.java =================================================================== --- src/java/org/apache/lucene/search/function/CustomScoreQuery.java (revision 827821) +++ src/java/org/apache/lucene/search/function/CustomScoreQuery.java (working copy) @@ -107,9 +107,9 @@ } /*(non-Javadoc) @see org.apache.lucene.search.Query#clone() */ - public Object clone() { + public CustomScoreQuery clone() { CustomScoreQuery clone = (CustomScoreQuery)super.clone(); - clone.subQuery = (Query) subQuery.clone(); + clone.subQuery = subQuery.clone(); clone.valSrcQueries = new ValueSourceQuery[valSrcQueries.length]; for(int i = 0; i < valSrcQueries.length; i++) { clone.valSrcQueries[i] = (ValueSourceQuery) valSrcQueries[i].clone(); Index: src/java/org/apache/lucene/store/SimpleFSDirectory.java =================================================================== --- src/java/org/apache/lucene/store/SimpleFSDirectory.java (revision 827821) +++ src/java/org/apache/lucene/store/SimpleFSDirectory.java (working copy) @@ -147,7 +147,7 @@ return file.length; } - public Object clone() { + public SimpleFSIndexInput clone() { SimpleFSIndexInput clone = (SimpleFSIndexInput)super.clone(); clone.isClone = true; return clone; Index: src/java/org/apache/lucene/index/FieldInfos.java =================================================================== --- src/java/org/apache/lucene/index/FieldInfos.java (revision 827821) +++ src/java/org/apache/lucene/index/FieldInfos.java (working copy) @@ -98,11 +98,11 @@ /** * Returns a deep clone of this FieldInfos instance. */ - synchronized public Object clone() { + synchronized public FieldInfos clone() { FieldInfos fis = new FieldInfos(); final int numField = byNumber.size(); for(int i=0;i> 3); } - indexStream = (IndexInput) cloneableIndexStream.clone(); + indexStream = cloneableIndexStream.clone(); numTotalDocs = (int) (indexSize >> 3); success = true; } finally { @@ -419,7 +419,7 @@ private IndexInput getFieldStream() { IndexInput localFieldsStream = fieldsStreamTL.get(); if (localFieldsStream == null) { - localFieldsStream = (IndexInput) cloneableFieldsStream.clone(); + localFieldsStream = cloneableFieldsStream.clone(); fieldsStreamTL.set(localFieldsStream); } return localFieldsStream; Index: src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpls.java =================================================================== --- src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpls.java (revision 827821) +++ src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpls.java (working copy) @@ -119,7 +119,7 @@ } public static final AttributeImpl assertCloneIsEqual(AttributeImpl att) { - AttributeImpl clone = (AttributeImpl) att.clone(); + AttributeImpl clone = att.clone(); assertEquals("Clone must be equal", att, clone); assertEquals("Clone's hashcode must be equal", att.hashCode(), clone.hashCode()); return clone; Index: src/java/org/apache/lucene/search/Query.java =================================================================== --- src/java/org/apache/lucene/search/Query.java (revision 827821) +++ src/java/org/apache/lucene/search/Query.java (working copy) @@ -204,9 +204,9 @@ } /** Returns a clone of this query. */ - public Object clone() { + public Query clone() { try { - return super.clone(); + return (Query) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException("Clone not supported: " + e.getMessage()); } Index: src/java/org/apache/lucene/index/CheckIndex.java =================================================================== --- src/java/org/apache/lucene/index/CheckIndex.java (revision 827821) +++ src/java/org/apache/lucene/index/CheckIndex.java (working copy) @@ -412,7 +412,7 @@ } - result.newSegments = (SegmentInfos) sis.clone(); + result.newSegments = sis.clone(); result.newSegments.clear(); for(int i=0;i(userData); return sis; Index: src/java/org/apache/lucene/search/DisjunctionMaxQuery.java =================================================================== --- src/java/org/apache/lucene/search/DisjunctionMaxQuery.java (revision 827821) +++ src/java/org/apache/lucene/search/DisjunctionMaxQuery.java (working copy) @@ -194,7 +194,7 @@ Query singleton = disjuncts.get(0); Query result = singleton.rewrite(reader); if (getBoost() != 1.0f) { - if (result == singleton) result = (Query)result.clone(); + if (result == singleton) result = result.clone(); result.setBoost(getBoost() * result.getBoost()); } return result; @@ -204,7 +204,7 @@ Query clause = disjuncts.get(i); Query rewrite = clause.rewrite(reader); if (rewrite != clause) { - if (clone == null) clone = (DisjunctionMaxQuery)this.clone(); + if (clone == null) clone = this.clone(); clone.disjuncts.set(i, rewrite); } } @@ -215,7 +215,7 @@ /** Create a shallow copy of us -- used in rewriting if necessary * @return a copy of us (but reuse, don't copy, our subqueries) */ @Override - public Object clone() { + public DisjunctionMaxQuery clone() { DisjunctionMaxQuery clone = (DisjunctionMaxQuery)super.clone(); clone.disjuncts = (ArrayList)this.disjuncts.clone(); return clone; Index: src/java/org/apache/lucene/util/BitVector.java =================================================================== --- src/java/org/apache/lucene/util/BitVector.java (revision 827821) +++ src/java/org/apache/lucene/util/BitVector.java (working copy) @@ -49,7 +49,7 @@ this.size = size; } - public Object clone() { + public BitVector clone() { byte[] copyBits = new byte[bits.length]; System.arraycopy(bits, 0, copyBits, 0, bits.length); return new BitVector(copyBits, size); Index: src/test/org/apache/lucene/index/TestIndexReaderClone.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexReaderClone.java (revision 827821) +++ src/test/org/apache/lucene/index/TestIndexReaderClone.java (working copy) @@ -275,7 +275,7 @@ private void performDefaultTests(IndexReader r1) throws Exception { float norm1 = Similarity.decodeNorm(r1.norms("field1")[4]); - IndexReader pr1Clone = (IndexReader) r1.clone(); + IndexReader pr1Clone = r1.clone(); pr1Clone.deleteDocument(10); pr1Clone.setNorm(4, "field1", 0.5f); assertTrue(Similarity.decodeNorm(r1.norms("field1")[4]) == norm1); @@ -357,7 +357,7 @@ // the cloned segmentreader should have 2 references, 1 to itself, and 1 to // the original segmentreader - IndexReader clonedReader = (IndexReader) origReader.clone(); + IndexReader clonedReader = origReader.clone(); SegmentReader clonedSegmentReader = SegmentReader.getOnlySegmentReader(clonedReader); assertDelDocsRefCountEquals(2, origSegmentReader); // deleting a document creates a new deletedDocs bitvector, the refs goes to @@ -393,7 +393,7 @@ // test a reopened reader IndexReader reopenedReader = clonedReader.reopen(); - IndexReader cloneReader2 = (IndexReader) reopenedReader.clone(); + IndexReader cloneReader2 = reopenedReader.clone(); SegmentReader cloneSegmentReader2 = SegmentReader.getOnlySegmentReader(cloneReader2); assertDelDocsRefCountEquals(2, cloneSegmentReader2); clonedReader.close(); @@ -410,7 +410,7 @@ IndexReader origReader = IndexReader.open(dir1, false); origReader.deleteDocument(1); - IndexReader clonedReader = (IndexReader) origReader.clone(); + IndexReader clonedReader = origReader.clone(); origReader.close(); clonedReader.close(); @@ -431,7 +431,7 @@ // the cloned segmentreader should have 2 references, 1 to itself, and 1 to // the original segmentreader - IndexReader clonedReader = (IndexReader) orig.clone(); + IndexReader clonedReader = orig.clone(); orig.close(); clonedReader.close(); Index: src/java/org/apache/lucene/index/ParallelReader.java =================================================================== --- src/java/org/apache/lucene/index/ParallelReader.java (revision 827821) +++ src/java/org/apache/lucene/index/ParallelReader.java (working copy) @@ -121,7 +121,7 @@ decrefOnClose.add(Boolean.valueOf(incRefReaders)); } - public synchronized Object clone() { + public synchronized IndexReader clone() { try { return doReopen(true); } catch (Exception ex) { @@ -164,7 +164,7 @@ for (final IndexReader oldReader : readers) { IndexReader newReader = null; if (doClone) { - newReader = (IndexReader) oldReader.clone(); + newReader = oldReader.clone(); } else { newReader = oldReader.reopen(); } Index: src/java/org/apache/lucene/index/MultiReader.java =================================================================== --- src/java/org/apache/lucene/index/MultiReader.java (revision 827821) +++ src/java/org/apache/lucene/index/MultiReader.java (working copy) @@ -119,7 +119,7 @@ * readers is increased to ensure that the subreaders remain open * until the last referring reader is closed. */ - public synchronized Object clone() { + public synchronized IndexReader clone() { try { return doReopen(true); } catch (Exception ex) { @@ -145,7 +145,7 @@ try { for (int i = 0; i < subReaders.length; i++) { if (doClone) - newSubReaders[i] = (IndexReader) subReaders[i].clone(); + newSubReaders[i] = subReaders[i].clone(); else newSubReaders[i] = subReaders[i].reopen(); // if at least one of the subreaders was updated we remember that Index: src/test/org/apache/lucene/index/TestLazyProxSkipping.java =================================================================== --- src/test/org/apache/lucene/index/TestLazyProxSkipping.java (revision 827821) +++ src/test/org/apache/lucene/index/TestLazyProxSkipping.java (working copy) @@ -179,8 +179,8 @@ return this.input.length(); } - public Object clone() { - return new SeeksCountingStream((IndexInput) this.input.clone()); + public SeeksCountingStream clone() { + return new SeeksCountingStream(this.input.clone()); } } Index: src/java/org/apache/lucene/index/DirectoryReader.java =================================================================== --- src/java/org/apache/lucene/index/DirectoryReader.java (revision 827821) +++ src/java/org/apache/lucene/index/DirectoryReader.java (working copy) @@ -125,7 +125,7 @@ this.directory = writer.getDirectory(); this.readOnly = true; this.segmentInfos = infos; - segmentInfosStart = (SegmentInfos) infos.clone(); + segmentInfosStart = infos.clone(); this.termInfosIndexDivisor = termInfosIndexDivisor; if (!readOnly) { // We assume that this segments_N was previously @@ -311,7 +311,7 @@ starts[subReaders.length] = maxDoc; } - public final synchronized Object clone() { + public final synchronized IndexReader clone() { try { return clone(readOnly); // Preserve current readOnly } catch (Exception ex) { @@ -320,7 +320,7 @@ } public final synchronized IndexReader clone(boolean openReadOnly) throws CorruptIndexException, IOException { - DirectoryReader newReader = doReopen((SegmentInfos) segmentInfos.clone(), true, openReadOnly); + DirectoryReader newReader = doReopen(segmentInfos.clone(), true, openReadOnly); if (this != newReader) { newReader.deletionPolicy = deletionPolicy; @@ -742,7 +742,7 @@ void startCommit() { rollbackHasChanges = hasChanges; - rollbackSegmentInfos = (SegmentInfos) segmentInfos.clone(); + rollbackSegmentInfos = segmentInfos.clone(); for (int i = 0; i < subReaders.length; i++) { subReaders[i].startCommit(); } Index: src/test/org/apache/lucene/store/MockRAMInputStream.java =================================================================== --- src/test/org/apache/lucene/store/MockRAMInputStream.java (revision 827821) +++ src/test/org/apache/lucene/store/MockRAMInputStream.java (working copy) @@ -58,7 +58,7 @@ } } - public Object clone() { + public MockRAMInputStream clone() { MockRAMInputStream clone = (MockRAMInputStream) super.clone(); clone.isClone = true; // Pending resolution on LUCENE-686 we may want to Index: src/java/org/apache/lucene/index/SegmentTermEnum.java =================================================================== --- src/java/org/apache/lucene/index/SegmentTermEnum.java (revision 827821) +++ src/java/org/apache/lucene/index/SegmentTermEnum.java (working copy) @@ -92,17 +92,17 @@ } } - protected Object clone() { + protected SegmentTermEnum clone() { SegmentTermEnum clone = null; try { clone = (SegmentTermEnum) super.clone(); } catch (CloneNotSupportedException e) {} - clone.input = (IndexInput) input.clone(); + clone.input = input.clone(); clone.termInfo = new TermInfo(termInfo); - clone.termBuffer = (TermBuffer)termBuffer.clone(); - clone.prevBuffer = (TermBuffer)prevBuffer.clone(); + clone.termBuffer = termBuffer.clone(); + clone.prevBuffer = prevBuffer.clone(); clone.scanBuffer = new TermBuffer(); return clone; Index: src/java/org/apache/lucene/index/SegmentTermDocs.java =================================================================== --- src/java/org/apache/lucene/index/SegmentTermDocs.java (revision 827821) +++ src/java/org/apache/lucene/index/SegmentTermDocs.java (working copy) @@ -45,7 +45,7 @@ protected SegmentTermDocs(SegmentReader parent) { this.parent = parent; - this.freqStream = (IndexInput) parent.core.freqStream.clone(); + this.freqStream = parent.core.freqStream.clone(); synchronized (parent) { this.deletedDocs = parent.deletedDocs; } @@ -185,7 +185,7 @@ public boolean skipTo(int target) throws IOException { if (df >= skipInterval) { // optimized case if (skipListReader == null) - skipListReader = new DefaultSkipListReader((IndexInput) freqStream.clone(), maxSkipLevels, skipInterval); // lazily clone + skipListReader = new DefaultSkipListReader(freqStream.clone(), maxSkipLevels, skipInterval); // lazily clone if (!haveSkipped) { // lazily initialize skip stream skipListReader.init(skipPointer, freqBasePointer, proxBasePointer, df, currentFieldStoresPayloads); Index: src/test/org/apache/lucene/index/TestCompoundFile.java =================================================================== --- src/test/org/apache/lucene/index/TestCompoundFile.java (revision 827821) +++ src/test/org/apache/lucene/index/TestCompoundFile.java (working copy) @@ -380,7 +380,7 @@ IndexInput one = cr.openInput("f11"); assertTrue(isCSIndexInputOpen(one)); - IndexInput two = (IndexInput) one.clone(); + IndexInput two = one.clone(); assertTrue(isCSIndexInputOpen(two)); assertSameStreams("basic clone one", expected, one); @@ -510,8 +510,8 @@ IndexInput e1 = cr.openInput("f11"); IndexInput e2 = cr.openInput("f3"); - IndexInput a1 = (IndexInput) e1.clone(); - IndexInput a2 = (IndexInput) e2.clone(); + IndexInput a1 = e1.clone(); + IndexInput a2 = e2.clone(); // Seek the first pair e1.seek(100); Index: src/java/org/apache/lucene/index/Payload.java =================================================================== --- src/java/org/apache/lucene/index/Payload.java (revision 827821) +++ src/java/org/apache/lucene/index/Payload.java (working copy) @@ -156,7 +156,7 @@ * Clones this payload by creating a copy of the underlying * byte array. */ - public Object clone() { + public Payload clone() { try { // Start with a shallow copy of data Payload clone = (Payload) super.clone(); Index: src/java/org/apache/lucene/index/MultiLevelSkipListReader.java =================================================================== --- src/java/org/apache/lucene/index/MultiLevelSkipListReader.java (revision 827821) +++ src/java/org/apache/lucene/index/MultiLevelSkipListReader.java (working copy) @@ -203,7 +203,7 @@ toBuffer--; } else { // clone this stream, it is already at the start of the current level - skipStream[i] = (IndexInput) skipStream[0].clone(); + skipStream[i] = skipStream[0].clone(); if (inputIsBuffered && length < BufferedIndexInput.BUFFER_SIZE) { ((BufferedIndexInput) skipStream[i]).setBufferSize((int) length); } Index: contrib/db/bdb-je/src/java/org/apache/lucene/store/je/JEIndexInput.java =================================================================== --- contrib/db/bdb-je/src/java/org/apache/lucene/store/je/JEIndexInput.java (revision 827821) +++ contrib/db/bdb-je/src/java/org/apache/lucene/store/je/JEIndexInput.java (working copy) @@ -51,7 +51,7 @@ block.get(directory); } - public Object clone() { + public JEIndexInput clone() { try { JEIndexInput clone = (JEIndexInput) super.clone(); Index: src/test/org/apache/lucene/index/TestIndexReader.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexReader.java (revision 827821) +++ src/test/org/apache/lucene/index/TestIndexReader.java (working copy) @@ -1621,7 +1621,7 @@ assertEquals(17, ints[0]); // Clone reader - IndexReader r2 = (IndexReader) r.clone(); + IndexReader r2 = r.clone(); r.close(); assertTrue(r2 != r); final int[] ints2 = FieldCache.DEFAULT.getInts(r2, "number"); Index: src/java/org/apache/lucene/search/spans/SpanFirstQuery.java =================================================================== --- src/java/org/apache/lucene/search/spans/SpanFirstQuery.java (revision 827821) +++ src/java/org/apache/lucene/search/spans/SpanFirstQuery.java (working copy) @@ -59,7 +59,7 @@ return buffer.toString(); } - public Object clone() { + public SpanFirstQuery clone() { SpanFirstQuery spanFirstQuery = new SpanFirstQuery((SpanQuery) match.clone(), end); spanFirstQuery.setBoost(getBoost()); return spanFirstQuery; @@ -119,7 +119,7 @@ SpanQuery rewritten = (SpanQuery) match.rewrite(reader); if (rewritten != match) { - clone = (SpanFirstQuery) this.clone(); + clone = this.clone(); clone.match = rewritten; } Index: src/java/org/apache/lucene/store/IndexInput.java =================================================================== --- src/java/org/apache/lucene/store/IndexInput.java (revision 827821) +++ src/java/org/apache/lucene/store/IndexInput.java (working copy) @@ -217,7 +217,7 @@ * different points in the input from each other and from the stream they * were cloned from. */ - public Object clone() { + public IndexInput clone() { IndexInput clone = null; try { clone = (IndexInput)super.clone(); Index: src/java/org/apache/lucene/index/TermBuffer.java =================================================================== --- src/java/org/apache/lucene/index/TermBuffer.java (revision 827821) +++ src/java/org/apache/lucene/index/TermBuffer.java (working copy) @@ -124,7 +124,7 @@ return term; } - protected Object clone() { + protected TermBuffer clone() { TermBuffer clone = null; try { clone = (TermBuffer)super.clone(); Index: src/java/org/apache/lucene/index/IndexWriter.java =================================================================== --- src/java/org/apache/lucene/index/IndexWriter.java (revision 827821) +++ src/java/org/apache/lucene/index/IndexWriter.java (working copy) @@ -1119,7 +1119,7 @@ } private synchronized void setRollbackSegmentInfos(SegmentInfos infos) { - rollbackSegmentInfos = (SegmentInfos) infos.clone(); + rollbackSegmentInfos = infos.clone(); assert !rollbackSegmentInfos.hasExternalSegments(directory); rollbackSegments = new HashMap(); final int size = rollbackSegmentInfos.size(); @@ -2582,7 +2582,7 @@ success = false; try { - localRollbackSegmentInfos = (SegmentInfos) segmentInfos.clone(); + localRollbackSegmentInfos = segmentInfos.clone(); assert !hasExternalSegments(); @@ -4393,7 +4393,7 @@ // Apply buffered deletes to all segments. private final synchronized boolean applyDeletes() throws CorruptIndexException, IOException { assert testPoint("startApplyDeletes"); - SegmentInfos rollback = (SegmentInfos) segmentInfos.clone(); + SegmentInfos rollback = segmentInfos.clone(); boolean success = false; boolean changed; try { @@ -4588,7 +4588,7 @@ readerPool.commit(); - toSync = (SegmentInfos) segmentInfos.clone(); + toSync = segmentInfos.clone(); if (commitUserData != null) toSync.setUserData(commitUserData);