[515236] Fix OSGI class loading of implemented function
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java
index aade368..dc2a75c 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java
@@ -884,16 +884,30 @@
// e.printStackTrace();
// }
} else if (implementationClass != null) {
- ClassLoader classLoader = asFunction.getClass().getClassLoader();
+ ClassNotFoundException cnfe = null;
+ Class<?> functionClass = null;
+ for (@NonNull ClassLoader classLoader : metamodelManager.getImplementationManager().getClassLoaders()) {
+ try {
+ functionClass = classLoader.loadClass(implementationClass);
+ cnfe = null;
+ break;
+ } catch (ClassNotFoundException e) {
+ if (cnfe == null) {
+ cnfe = e;
+ }
+ }
+ }
+ if (cnfe != null) {
+ throw new IllegalStateException("Load class failure for " + implementationClass + " in QVTiAS2CGVisitor.visitFunction()", cnfe);
+ }
+ assert functionClass != null;
+ // ClassLoader classLoader = asFunction.getClass().getClassLoader();
Object implementationInstance;
try {
- Class<?> functionClass = classLoader.loadClass(implementationClass);
Field implementationField = functionClass.getField("INSTANCE");
implementationInstance = implementationField.get(null);
}
- catch (ClassNotFoundException e) {
- throw new IllegalStateException("Load class failure for " + implementationClass + " in QVTiAS2CGVisitor.visitFunction()", e);
- } catch (NoSuchFieldException e) {
+ catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new IllegalStateException(e);