Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #234: Using builtin annotation classes before creating a CAS can break type system management #243

Draft
wants to merge 1 commit into
base: release/3.3.x
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,20 @@ public static JCasClassInfo getOrCreateJCasClassInfo(TypeImpl ti, ClassLoader cl
jcci = maybeCreateJCasClassInfo(ti, cl, type2jcci, lookup);
}

// Due to initialization order, it could be that we created the JCCI before the static fields in
// the JCas class have been initialized. In particular, the jcasType typeIndexID might still
// have been uninitialized (0) when we crated the JCCI. To work fix that case, check if the
// typeIndexID has changed and if so update the JCCI
if (jcci != null && jcci.jcasType == 0) {
if (!Modifier.isAbstract(jcci.jcasClass.getModifiers())) { // skip next for abstract classes
int jcasType = Misc.getStaticIntFieldNoInherit(jcci.jcasClass, "typeIndexID");
if (jcasType != jcci.jcasType) {
jcci = new JCasClassInfo(jcci.jcasClass, jcci.generator, jcasType);
type2jcci.put(ti.getJCasClassName(), jcci);
}
}
}

// do this setup for new type systems using previously loaded jcci, as well as
// for new jccis
if (jcci != null && jcci.jcasType >= 0) {
Expand Down