On 1/20/07, Marshall Schor <[EMAIL PROTECTED]> wrote:
There's a general "rule" in Java that you should not store a ref to a
partially-initialized instance in another object, because it allows
another thread to potentially access a Java Object that is not yet fully
initialized.

The use of JCasRegistry might be doing this.  It stores into an
externally-observable array (observable on other threads) a ref to the
class Foo, before Foo is fully initialized.
<snip/>

Hmmm.  This isn't actually a case of an Object (instance) being
referenced before it's finished initialized, but a Class being
referenced before its static initialization has finished.  The same
issues may apply to this case, but I am not sure.  I think for there
to be a problem, the code referencing the Class object would need to
use reflection to try to access a static field or method, perhaps
before some static field had been initialized.  I wonder if Java does
anything to guard against that happening before static initialization
has completed.


I don't think this is an actual issue in our case, because I think this
value is only used to obtain a ref to the class for the purpose of
getting the class "name" to use in an error message.   Other opinions?


Right, we don't try to invoke a method or access a field so I think we're good.

-Adam

Reply via email to