Skip to content

Commit cf528da

Browse files
author
Jörg Kubitz
committed
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 cf528da

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,23 @@ private static void addLibraryEntry(IPluginLibrary library, Map<String, IPath> s
267267

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

0 commit comments

Comments
 (0)