|
34 | 34 | import org.eclipse.jdt.core.IClasspathAttribute; |
35 | 35 | import org.eclipse.jdt.core.IClasspathEntry; |
36 | 36 | import org.eclipse.jdt.core.IJavaModelStatus; |
| 37 | +import org.eclipse.jdt.core.IJavaModelStatusConstants; |
37 | 38 | import org.eclipse.jdt.core.IJavaProject; |
38 | 39 | import org.eclipse.jdt.core.IPackageFragmentRoot; |
39 | 40 | import org.eclipse.jdt.core.JavaConventions; |
@@ -267,17 +268,23 @@ private static void addLibraryEntry(IPluginLibrary library, Map<String, IPath> s |
267 | 268 |
|
268 | 269 | IPackageFragmentRoot root = context.javaProject.getPackageFragmentRoot(jarFile); |
269 | 270 | 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; |
| 271 | + try { |
| 272 | + IClasspathEntry oldEntry = root.getRawClasspathEntry(); |
| 273 | + // If we have the same binary root but new or different source, we |
| 274 | + // should recreate the entry. That is when the source attachment: |
| 275 | + // - is not defined: the default could be available now, or |
| 276 | + // - is overridden with a different value. |
| 277 | + if ((sourceAttachment == null && oldEntry.getSourceAttachmentPath() != null) |
| 278 | + || (sourceAttachment != null && sourceAttachment.equals(oldEntry.getSourceAttachmentPath()))) { |
| 279 | + context.reloaded.add(oldEntry); |
| 280 | + return; |
| 281 | + } |
| 282 | + isExported = oldEntry.isExported(); |
| 283 | + } catch (JavaModelException e) { |
| 284 | + if (e.getStatus().getCode() != IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH) { |
| 285 | + throw e; |
| 286 | + } |
279 | 287 | } |
280 | | - isExported = oldEntry.isExported(); |
281 | 288 | } |
282 | 289 | reloadClasspathEntry(jarFile, name, sourceAttachment, isExported, context); |
283 | 290 | } |
|
0 commit comments