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 #252: Potential failure to look up FsGenerator3 in OSGI-like contexts #253

Merged
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 @@ -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