Bug 534673 - NPE in DSAnnotationClasspathContributor.getInitialEntries
breaks UI
lib1_2 directory was never added to the build path, so never shipped
with org.eclipse.pde.ds.annotations.
Added directory and extra errors pointing to possible configuration
problems.
Change-Id: Id5b0770af27176829d670b2e52335f1599d9fe6b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
diff --git a/ds/org.eclipse.pde.ds.annotations/build.properties b/ds/org.eclipse.pde.ds.annotations/build.properties
index e5ba8a7..49a1381 100644
--- a/ds/org.eclipse.pde.ds.annotations/build.properties
+++ b/ds/org.eclipse.pde.ds.annotations/build.properties
@@ -16,5 +16,6 @@
OSGI-INF/,\
.options,\
about.html,\
- lib/
+ lib/,\
+ lib1_2/
src.includes = about.html
diff --git a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationClasspathContributor.java b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationClasspathContributor.java
index 5a52553..9ae3587 100644
--- a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationClasspathContributor.java
+++ b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationClasspathContributor.java
@@ -76,10 +76,15 @@
}
try {
- URL fileURL = FileLocator.toFileURL(bundle.getEntry(jarDir + "/annotations.jar")); //$NON-NLS-1$
+ URL entryUrl = bundle.getEntry(jarDir + "/annotations.jar");
+ if (entryUrl == null) {
+ Activator.log(new IllegalStateException(
+ "Missing " + bundle.getSymbolicName() + "/" + jarDir + "/annotations.jar")); //$NON-NLS-1$
+ return Collections.emptyList();
+ }
+ URL fileURL = FileLocator.toFileURL(entryUrl); // $NON-NLS-1$
if ("file".equals(fileURL.getProtocol())) { //$NON-NLS-1$
- URL srcFileURL = FileLocator.toFileURL(bundle.getEntry(jarDir + "/annotationssrc.zip")); //$NON-NLS-1$
- IPath srcPath = "file".equals(srcFileURL.getProtocol()) ? new Path(srcFileURL.getPath()) : null; //$NON-NLS-1$
+ IPath srcPath = getSrcPath(bundle, jarDir);
IClasspathEntry entry = JavaCore.newLibraryEntry(new Path(fileURL.getPath()), srcPath, Path.ROOT, ANNOTATION_ACCESS_RULES, DS_ATTRS, false);
return Collections.singletonList(entry);
}
@@ -95,6 +100,18 @@
return Collections.emptyList();
}
+ private IPath getSrcPath(Bundle bundle, String jarDir) throws IOException {
+ URL srcEntry = bundle.getEntry(jarDir + "/annotationssrc.zip");
+ if (srcEntry == null) {
+ Activator.log(new IllegalStateException(
+ "Missing " + bundle.getSymbolicName() + "/" + jarDir + "/annotationssrc.zip")); //$NON-NLS-1$
+ return null;
+ }
+ URL srcFileURL = FileLocator.toFileURL(srcEntry); // $NON-NLS-1$
+ IPath srcPath = "file".equals(srcFileURL.getProtocol()) ? new Path(srcFileURL.getPath()) : null; //$NON-NLS-1$
+ return srcPath;
+ }
+
@Override
public List<IClasspathEntry> getEntriesForDependency(BundleDescription project, BundleDescription addedDependency) {
return Collections.emptyList();