lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: ClassCastException when writing to index writer
Date Sat, 04 Oct 2008 06:08:31 GMT

:        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@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message