Java Mailing List Archive

http://www.java2.5341.com/

Home » java-user.lucene »

Re: ClassCastException when writing to index writer

Chris Hostetter

2008-10-04

Replies: Find Java Web Hosting

Author LoginPost Reply

:     SegmentInfos sis = (SegmentInfos) super.clone();

: We see that it is trying to cast a Vector into SegmentInfos which explains
: the ClassCastException. This is definitely a bug.

That is in the correct and specified use of clone() ... note the
javadocs for Object.clone() and the Cloneable interface...

> By convention, the returned object should be obtained by calling
> super.clone. If a class and all of its superclasses (except Object) obey
> this convention, it will be the case that x.clone().getClass() ==
> x.getClass()
 ...
> The method clone for class Object performs a specific cloning operation.
> First, if the class of this object does not implement the interface
> Cloneable, then a CloneNotSupportedException is thrown. Note that all
> arrays are considered to implement the interface Cloneable. Otherwise,
> this method creates a new instance of the class of this object and
> initializes all its fields with exactly the contents of the ...

I'm really not sure how you could be getting that ClassCastException
unless there's a really horrific bug in the JRE you are using.

You'll see this in just about every (non-trivial) use of super.clone() ...

http://www.google.com/codesearch?q=super.clone%28%29+lang%3Ajava



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@(protected)
For additional commands, e-mail: java-user-help@(protected)

©2008 java2.5341.com - Jax Systems, LLC, U.S.A.