Skip to content

Commit 49d52e7

Browse files
authored
Merge pull request #396 from apache/bugfix/395-Potential-failure-to-look-up-UIMA-internal-classes-in-OSGI-like-contexts
Issue #395: Potential failure to look up UIMA-internal classes in OSGI-like contexts
2 parents 69ebb88 + 6d4567c commit 49d52e7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

uimaj-core/src/main/java/org/apache/uima/internal/util/UIMAClassLoader.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import java.util.List;
2929
import java.util.StringTokenizer;
3030

31+
import org.apache.uima.UIMAFramework;
3132
import org.apache.uima.cas.impl.FSClassRegistry;
32-
import org.apache.uima.cas.impl.FsGenerator3;
3333
import org.apache.uima.cas.impl.TypeSystemImpl;
3434

3535
/**
@@ -248,11 +248,11 @@ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundE
248248
c = findClass(name);
249249
}
250250
} catch (ClassNotFoundException e) {
251-
if (name.startsWith(FsGenerator3.class.getPackage().getName() + ".")) {
251+
if (isUimaInternalPackage(name)) {
252252
// There may be cases where the target class uses a classloader that has no access
253253
// to the UIMA internal classes - in particular to the FSGenerator3 - so we force using
254254
// the UIMA classloader in this case.
255-
c = FsGenerator3.class.getClassLoader().loadClass(name);
255+
c = UIMAFramework.class.getClassLoader().loadClass(name);
256256
} else {
257257
// delegate class loading for this class-name
258258
c = super.loadClass(name, false);
@@ -268,6 +268,11 @@ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundE
268268
}
269269
}
270270

271+
private boolean isUimaInternalPackage(String name) {
272+
return name.startsWith("org.apache.uima.cas.impl.")
273+
|| name.startsWith("org.apache.uima.jcas.cas.");
274+
}
275+
271276
/*
272277
* loads resource from this class loader first, if possible (non-Javadoc)
273278
*

0 commit comments

Comments
 (0)