------- Additional Comments From [hidden email] 2005-05-25 01:08 -------
The area of code that is affected by this is in
Reader reader; // find or make Reader
if (field.readerValue() != null)
reader = field.readerValue();
else if (field.stringValue() != null)
reader = new StringReader(field.stringValue());
throw new IllegalArgumentException
("field must have either String or Reader value");
In my test scenario I do not use a reader, all my Fields are created as normal
String values, so the first if() to determine if the reader comes back null will
always result in an ClassCastException.
That's 1 ClassCastException for each Indexed & Tokenized field _per_ Document.
I'm not sure of whether String/Reader is more prevelant out there in the wild,
but I would have thought String would have been common. Sure for large
documents like PDF's etc it's more likely a Reader will be used.
Anyway, for the try/catch block, the JVM performs an implicit ClassCast check
anyway, that's how it determines whether it should throw an exception or not, so
there is no way to avoid some form of an instanceof.
Modern JVM's are quicker with instanceof. However this may not (probably not)
true for older (1.2 or earlier?) VM's, although I don't have access to that
anymore test that theory.