[574706] Use class loading lock for synchronization
diff --git a/plugins/org.eclipse.m2m.qvt.oml.runtime.jdt/src/org/eclipse/m2m/internal/qvt/oml/jdt/runtime/blackbox/ProjectClassLoader.java b/plugins/org.eclipse.m2m.qvt.oml.runtime.jdt/src/org/eclipse/m2m/internal/qvt/oml/jdt/runtime/blackbox/ProjectClassLoader.java
index 4846ddd..75ea2d8 100644
--- a/plugins/org.eclipse.m2m.qvt.oml.runtime.jdt/src/org/eclipse/m2m/internal/qvt/oml/jdt/runtime/blackbox/ProjectClassLoader.java
+++ b/plugins/org.eclipse.m2m.qvt.oml.runtime.jdt/src/org/eclipse/m2m/internal/qvt/oml/jdt/runtime/blackbox/ProjectClassLoader.java
@@ -186,25 +186,27 @@
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- Class<?> result = findLoadedClass(name);
-
- if (result == null) {
- try {
- result = findClass(name);
+ synchronized (getClassLoadingLock(name)) {
+ Class<?> result = findLoadedClass(name);
+
+ if (result == null) {
+ try {
+ result = findClass(name);
+ }
+ catch(ClassNotFoundException e) {
+ result = getParent().loadClass(name);
+ }
+ catch(Throwable t) {
+ throw new ClassNotFoundException(name, t);
+ }
}
- catch(ClassNotFoundException e) {
- result = getParent().loadClass(name);
- }
- catch(Throwable t) {
- throw new ClassNotFoundException();
- }
+
+ if (resolve) {
+ resolveClass(result);
+ }
+
+ return result;
}
-
- if (resolve) {
- resolveClass(result);
- }
-
- return result;
}
private static class WorkspaceDependencyAnalyzer {
@@ -364,7 +366,7 @@
Class<?> result = loadedClasses.get(name);
if (result == null) {
- throw new ClassNotFoundException();
+ throw new ClassNotFoundException(name);
}
else {
return result;
@@ -398,7 +400,7 @@
}
loadedClasses.put(name, null);
- throw new ClassNotFoundException();
+ throw new ClassNotFoundException(name);
}
};
}