Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 309788
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/UserLibrary.java (-1 / +7 lines)
Lines 110-116 Link Here
110
110
111
		for (int i = 0, length = entries.length; i < length; ++i) {
111
		for (int i = 0, length = entries.length; i < length; ++i) {
112
			ClasspathEntry cpEntry = (ClasspathEntry) entries[i];
112
			ClasspathEntry cpEntry = (ClasspathEntry) entries[i];
113
113
			if (cpEntry.getReferencingEntry() != null) {
114
				continue;
115
			}
114
			HashMap archive = new HashMap();
116
			HashMap archive = new HashMap();
115
			archive.put(TAG_PATH, cpEntry.getPath().toString());
117
			archive.put(TAG_PATH, cpEntry.getPath().toString());
116
			IPath sourceAttach= cpEntry.getSourceAttachmentPath();
118
			IPath sourceAttach= cpEntry.getSourceAttachmentPath();
Lines 186-191 Link Here
186
					attributeList = ClasspathEntry.getChildAttributes(ClasspathEntry.TAG_ACCESS_RULES, children, foundChildren);
188
					attributeList = ClasspathEntry.getChildAttributes(ClasspathEntry.TAG_ACCESS_RULES, children, foundChildren);
187
					IAccessRule[] accessRules = ClasspathEntry.decodeAccessRules(attributeList);
189
					IAccessRule[] accessRules = ClasspathEntry.decodeAccessRules(attributeList);
188
					IClasspathEntry entry = JavaCore.newLibraryEntry(new Path(path), sourceAttach, sourceAttachRoot, accessRules, extraAttributes, false/*not exported*/);
190
					IClasspathEntry entry = JavaCore.newLibraryEntry(new Path(path), sourceAttach, sourceAttachRoot, accessRules, extraAttributes, false/*not exported*/);
191
					IClasspathEntry[] referencedEntries = ((ClasspathEntry)entry).resolvedChainedLibraries();
192
					for (int index=0; index < referencedEntries.length; index++) {
193
						res.add(referencedEntries[index]);
194
					}
189
					res.add(entry);
195
					res.add(entry);
190
				}
196
				}
191
			}
197
			}
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+45 lines)
Lines 6747-6751 Link Here
6747
		ContainerInitializer.setInitializer(null);
6747
		ContainerInitializer.setInitializer(null);
6748
	}
6748
	}
6749
}
6749
}
6750
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=309788
6751
public void testBug309788() throws Exception {
6752
	
6753
	try {
6754
		IJavaProject p = this.createJavaProject("P", new String[] {}, "bin");
6755
		// Create new user library "SomeUserLibrary"
6756
		ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(JavaCore.USER_LIBRARY_CONTAINER_ID);
6757
		String libraryName = "SomeUserLibrary";
6758
		IPath containerPath = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID);
6759
		UserLibraryClasspathContainer containerSuggestion = new UserLibraryClasspathContainer(libraryName);
6760
		initializer.requestClasspathContainerUpdate(containerPath.append(libraryName), null, containerSuggestion);
6761
6762
		addExternalLibrary(p, getExternalResourcePath("lib1.jar"), new String[0], 
6763
				new String[] {
6764
					"META-INF/MANIFEST.MF",
6765
					"Manifest-Version: 1.0\n" +
6766
					"Class-Path: lib2.jar\n",
6767
				},
6768
				JavaCore.VERSION_1_4);
6769
		
6770
		// Modify user library
6771
		IEclipsePreferences preferences = new InstanceScope().getNode(JavaCore.PLUGIN_ID);
6772
		String propertyName = JavaModelManager.CP_USERLIBRARY_PREFERENCES_PREFIX+"SomeUserLibrary";
6773
		StringBuffer propertyValue = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<userlibrary systemlibrary=\"false\" version=\"1\">\r\n<archive");
6774
		propertyValue.append(" path=\"" + getExternalResourcePath("lib1.jar"));
6775
		propertyValue.append("\"/>\r\n</userlibrary>\r\n");
6776
		preferences.put(propertyName, propertyValue.toString());
6777
		preferences.flush();
6778
6779
		createExternalFile("lib2.jar", "");
6780
		initializer.requestClasspathContainerUpdate(containerPath.append(libraryName), null, containerSuggestion);
6781
		
6782
		IClasspathEntry[] entries = new IClasspathEntry[1];
6783
		entries[0] = JavaCore.newContainerEntry(containerSuggestion.getPath());
6784
		p.setRawClasspath(entries, null);
6785
		IClasspathEntry[] resolvedClasspath = p.getResolvedClasspath(true);
6786
		assertClasspathEquals(resolvedClasspath, 
6787
				""+ getExternalPath() + "lib2.jar[CPE_LIBRARY][K_BINARY][isExported:false]\n" + 
6788
				""+ getExternalPath() + "lib1.jar[CPE_LIBRARY][K_BINARY][isExported:false]");
6789
6790
	} finally {
6791
		deleteProject("P");
6792
		ContainerInitializer.setInitializer(null);
6793
	}
6794
}
6750
6795
6751
}
6796
}

Return to bug 309788