Avoid real work (here initializiing/setting classpath containers) during static initializers.
I saw deadlocks with involvment of the following stack-fragment:
at org.eclipse.jdt.core.JavaCore.setClasspathVariable(JavaCore.java:4923)
at org.eclipse.objectteams.otdt.core.ext.OTVariableInitializer.initialize(OTVariableInitializer.java:62)
at org.eclipse.jdt.core.JavaCore.getClasspathVariable(JavaCore.java:2858)
at org.eclipse.jdt.internal.core.JavaModelManager.getResolvedVariablePath(JavaModelManager.java:2411)
at org.eclipse.jdt.core.JavaCore.getResolvedVariablePath(JavaCore.java:3400)
at org.eclipse.objectteams.otdt.core.ext.OTDTPlugin.getResolvedVariablePath(OTDTPlugin.java:166)
at org.eclipse.objectteams.otdt.core.ext.OTREContainer.<clinit>(OTREContainer.java:73)
at org.eclipse.objectteams.otdt.core.ext.OTDTPlugin.start(OTDTPlugin.java:120)
(initializing BCEL_PATH early is OK, we need the BundleContext and don't perform further computations)
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java
index 718e197..ac093d4 100644
--- a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java
@@ -21,6 +21,7 @@
import java.util.List;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -83,12 +84,13 @@
boolean hasBCEL = false;
boolean hasOTRE_min = false;
+ IPath otreMinJarPath = OTREContainer.getOtreMinJarPath();
for (int i = 0; i < origEntries.length; i++)
{
- IRuntimeClasspathEntry entry = origEntries[i];
- if (OTREContainer.BCEL_PATH.equals(entry.getPath()))
+ IPath entryPath = origEntries[i].getPath();
+ if (OTREContainer.BCEL_PATH.equals(entryPath))
hasBCEL = true;
- else if (OTREContainer.OTRE_MIN_JAR_PATH.equals(entry.getPath().toString()))
+ else if (otreMinJarPath.equals(entryPath))
hasOTRE_min = true;
}
@@ -101,7 +103,7 @@
}
if (!hasOTRE_min) {
- entry = JavaRuntime.newArchiveRuntimeClasspathEntry(OTREContainer.OTRE_MIN_JAR_PATH);
+ entry = JavaRuntime.newArchiveRuntimeClasspathEntry(otreMinJarPath);
entry.setClasspathProperty(IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);
result.add(entry);
}