lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: Explicit setting of NIOFSDirectory not respected
Date Wed, 12 Dec 2012 14:29:37 GMT
Hi,

> Thanks for that, I had not realised that the open method was simply
> inherited from the FSDirectory, I should have read the docs.
> 
> However, it makes no sense to me that a call to NIOFSDirectory.open() can
> end up opening a MMapDirectory, and in general that a call to one subclass
> can end up opening any other of the subclasses. Perhaps the open() method
> which selects the subclass should only be in the FSDirectory class and the
> subclass open() methods should specifically open the class for which they are
> called.

This cannot be prevented. FSDirectory.open() is a static method and exists only in the class
FSDirectory not anywhere else. Your build environment (e.g. IDE) should warn you that you
are calling a static method in a non-static context or on a different class name. Java unfortunately
always makes static fields and variables visible to subclasses, but they are not virtual and
is a "bug" in Java. MMapDirectory has no static open method.

Uwe


---------------------------------------------------------------------
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