You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2022/10/12 07:56:48 UTC
[uima-uimaj] 01/01: Issue #252: Potential failure to look up FsGenerator3 in OSGI-like contexts
This is an automated email from the ASF dual-hosted git repository.
rec pushed a commit to branch bugfix/252-Potential-failure-to-look-up-FsGenerator3-in-OSGI-like-contexts
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git
commit 2be73010c2f0cb99019549da2af53219f21e3a0e
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Wed Oct 12 09:56:39 2022 +0200
Issue #252: Potential failure to look up FsGenerator3 in OSGI-like contexts
- If the class to be looked up is in the FsGenerator3 package, use the classloader of FsGenerator3
---
.../org/apache/uima/internal/util/UIMAClassLoader.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/uimaj-core/src/main/java/org/apache/uima/internal/util/UIMAClassLoader.java b/uimaj-core/src/main/java/org/apache/uima/internal/util/UIMAClassLoader.java
index f3c4f99af..026351463 100644
--- a/uimaj-core/src/main/java/org/apache/uima/internal/util/UIMAClassLoader.java
+++ b/uimaj-core/src/main/java/org/apache/uima/internal/util/UIMAClassLoader.java
@@ -29,6 +29,7 @@ import java.util.List;
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;
/**
@@ -235,15 +236,23 @@ public class UIMAClassLoader extends URLClassLoader {
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;
}
}