I'm not sure of your use case in detail, but if the JCas classes have been
loaded, they can't be "reloaded" - the calls to Class.forName, or
classLoader.loadClass would find the named object already loaded, and just
return that. (This assumes you're using the same class loader, of course).
This whole area is somewhat cleaned up in the experimental UIMA v3. There, when
you commit a type system, it's compared to existing type systems previously
committed, and if one of those is "equal", it's used instead.
This was a bit involved to do; the saving is done using weak references, so
things would eventually get cleaned up, and there were issues with test cases
which built type systems programmatically, and kept java references to types and
features before the commit, which became invalid after the commit (fix was to
re-compute these handles after the commit).
If you know the type system is identical, you could cobble something up to avoid
reinitializing it, I think.
-Marshall
On 3/15/2016 1:21 PM, Peter Klügl wrote:
> Hi,
>
> I wonder if it is necessary to load all JCas cover classes anew if the
> jcas is deserialized with deserializeCASComplete.
>
> In JCasImpl line 645, the map is null because the type system instance
> changed in the serialization (no equals()).
??? line 645 in trunk:
private void expandTypeArrayIfNeeded() {
if (typeArray.length < JCasRegistry.getNumberOfRegisteredClasses()) {
TOP_Type[] newTypeArray = new
TOP_Type[JCasRegistry.getNumberOfRegisteredClasses()];
System.arraycopy(typeArray, 0, newTypeArray, 0, typeArray.length);
typeArray = newTypeArray; // <<<<<<<<<<<<<<< Line 645
}
}
>
> There there a way to avoid that?
>
> Best,
>
> Peter
>