Skip to content

Commit

Permalink
Merge pull request #253 from apache/bugfix/252-Potential-failure-to-l…
Browse files Browse the repository at this point in the history
…ook-up-FsGenerator3-in-OSGI-like-contexts

Issue #252: Potential failure to look up FsGenerator3 in OSGI-like contexts
  • Loading branch information
reckart committed Oct 12, 2022
2 parents bd05de3 + 2be7301 commit c337dcb
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.StringTokenizer;

import org.apache.uima.cas.impl.FSClassRegistry;
import org.apache.uima.cas.impl.FsGenerator3;
import org.apache.uima.cas.impl.TypeSystemImpl;

/**
Expand Down Expand Up @@ -235,15 +236,23 @@ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundE
c = findClass(name);
}
} catch (ClassNotFoundException e) {
// delegate class loading for this class-name
c = super.loadClass(name, false);
if (name.startsWith(FsGenerator3.class.getPackage().getName() + ".")) {
// There may be cases where the target class uses a classloader that has no access
// to the UIMA internal classes - in particular to the FSGenerator3 - so we force using
// the UIMA classloader in this case.
c = FsGenerator3.class.getClassLoader().loadClass(name);
} else {
// delegate class loading for this class-name
c = super.loadClass(name, false);
}
}
}

if (resolve) {
resolveClass(c);
}
return c;

return c;
}
}

Expand Down

0 comments on commit c337dcb

Please sign in to comment.