Skip to content

Commit a3feb92

Browse files
Jörg Kubitzjukzi
authored andcommitted
fix ClasspathComputer: ignore if oldEntry not found #820
fixes random failing ClasspathUpdaterTest When IJavaProject.setRawClasspath() is explicitly called with ClasspathEntries distinct from PDE (like in the Test), and then later PDEs UpdateClasspathJob is executed it can't compute the "oldEntry" and fails with "... is not on its projects build path". The Message is correct - it was manually removed from the projects build path. That state should just be ignored so that PDE continues to set the IClasspathEntries computed by PDE. #820
1 parent 5c22fae commit a3feb92

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ protected static IBuild getBuild(IProject project) throws CoreException {
255255
}
256256

257257
private static void addLibraryEntry(IPluginLibrary library, Map<String, IPath> sourceLibraryMap,
258-
ClasspathConfiguration context) throws JavaModelException {
258+
ClasspathConfiguration context) {
259259
String name = ClasspathUtilCore.expandLibraryName(library.getName());
260260
IResource jarFile = context.javaProject.getProject().findMember(name);
261261
if (jarFile == null) {
@@ -266,18 +266,26 @@ private static void addLibraryEntry(IPluginLibrary library, Map<String, IPath> s
266266
boolean isExported = library.isExported();
267267

268268
IPackageFragmentRoot root = context.javaProject.getPackageFragmentRoot(jarFile);
269-
if (root.exists() && root.getKind() == IPackageFragmentRoot.K_BINARY) {
270-
IClasspathEntry oldEntry = root.getRawClasspathEntry();
271-
// If we have the same binary root but new or different source, we
272-
// should recreate the entry. That is when the source attachment:
273-
// - is not defined: the default could be available now, or
274-
// - is overridden with a different value.
275-
if ((sourceAttachment == null && oldEntry.getSourceAttachmentPath() != null)
276-
|| (sourceAttachment != null && sourceAttachment.equals(oldEntry.getSourceAttachmentPath()))) {
277-
context.reloaded.add(oldEntry);
278-
return;
269+
try {
270+
if (root.exists() && root.getKind() == IPackageFragmentRoot.K_BINARY) {
271+
IClasspathEntry oldEntry = root.getRawClasspathEntry();
272+
// If we have the same binary root but new or different source,
273+
// we
274+
// should recreate the entry. That is when the source
275+
// attachment:
276+
// - is not defined: the default could be available now, or
277+
// - is overridden with a different value.
278+
if ((sourceAttachment == null && oldEntry.getSourceAttachmentPath() != null)
279+
|| (sourceAttachment != null && sourceAttachment.equals(oldEntry.getSourceAttachmentPath()))) {
280+
context.reloaded.add(oldEntry);
281+
return;
282+
}
283+
isExported = oldEntry.isExported();
279284
}
280-
isExported = oldEntry.isExported();
285+
} catch (JavaModelException ignored) {
286+
// For example ELEMENT_NOT_ON_CLASSPATH is expected when
287+
// rawclasspath was changed manually.
288+
// In any case PDE can not solve any issue beside ignoring it.
281289
}
282290
reloadClasspathEntry(jarFile, name, sourceAttachment, isExported, context);
283291
}

0 commit comments

Comments
 (0)