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 343509 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/JavaCore.java (-7 / +10 lines)
Lines 3486-3494 Link Here
3486
			// and recreate links for external folders if needed
3486
			// and recreate links for external folders if needed
3487
			if (monitor != null)
3487
			if (monitor != null)
3488
				monitor.subTask(Messages.javamodel_resetting_source_attachment_properties);
3488
				monitor.subTask(Messages.javamodel_resetting_source_attachment_properties);
3489
			ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager();
3490
			final IJavaProject[] projects = manager.getJavaModel().getJavaProjects();
3489
			final IJavaProject[] projects = manager.getJavaModel().getJavaProjects();
3491
			HashSet visitedPaths = new HashSet();
3490
			HashSet visitedPaths = new HashSet();
3491
			ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager();
3492
			for (int i = 0, length = projects.length; i < length; i++) {
3492
			for (int i = 0, length = projects.length; i < length; i++) {
3493
				JavaProject javaProject = (JavaProject) projects[i];
3493
				JavaProject javaProject = (JavaProject) projects[i];
3494
				IClasspathEntry[] classpath;
3494
				IClasspathEntry[] classpath;
Lines 3499-3505 Link Here
3499
					continue;
3499
					continue;
3500
				}
3500
				}
3501
				if (classpath != null) {
3501
				if (classpath != null) {
3502
					boolean needExternalFolderCreation = false;
3503
					for (int j = 0, length2 = classpath.length; j < length2; j++) {
3502
					for (int j = 0, length2 = classpath.length; j < length2; j++) {
3504
						IClasspathEntry entry = classpath[j];
3503
						IClasspathEntry entry = classpath[j];
3505
						if (entry.getSourceAttachmentPath() != null) {
3504
						if (entry.getSourceAttachmentPath() != null) {
Lines 3509-3526 Link Here
3509
							}
3508
							}
3510
						}
3509
						}
3511
						// else source might have been attached by IPackageFragmentRoot#attachSource(...), we keep it
3510
						// else source might have been attached by IPackageFragmentRoot#attachSource(...), we keep it
3512
						if (!needExternalFolderCreation && entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
3511
						if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
3513
							IPath entryPath = entry.getPath();
3512
							IPath entryPath = entry.getPath();
3514
							if (ExternalFoldersManager.isExternalFolderPath(entryPath) && externalFoldersManager.getFolder(entryPath) == null) {
3513
							if (ExternalFoldersManager.isExternalFolderPath(entryPath) && externalFoldersManager.getFolder(entryPath) == null) {
3515
								needExternalFolderCreation = true;
3514
								externalFoldersManager.addFolder(entryPath, true);
3516
							}
3515
							}
3517
						}
3516
						}
3518
					}
3517
					}
3519
					if (needExternalFolderCreation)
3520
						manager.deltaState.addExternalFolderChange(javaProject, null/*act as if all external folders were new*/);
3521
				}
3518
				}
3522
			}
3519
			}
3523
3520
			try {
3521
				externalFoldersManager.createPendingFolders(monitor);
3522
			}
3523
			catch(JavaModelException jme) {
3524
				// Creation of external folder project failed. Log it and continue;
3525
				Util.log(jme, "Error while processing external folders"); //$NON-NLS-1$
3526
			}
3524
			// initialize delta state
3527
			// initialize delta state
3525
			if (monitor != null)
3528
			if (monitor != null)
3526
				monitor.subTask(Messages.javamodel_initializing_delta_state);
3529
				monitor.subTask(Messages.javamodel_initializing_delta_state);
(-)model/org/eclipse/jdt/internal/core/ExternalFolderChange.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - inconsistent initialization of classpath container backed by external class folder, see https://bugs.eclipse.org/320618
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
12
package org.eclipse.jdt.internal.core;
12
13
Lines 42-48 Link Here
42
		Iterator iterator = newFolders.iterator();
43
		Iterator iterator = newFolders.iterator();
43
		while (iterator.hasNext()) {
44
		while (iterator.hasNext()) {
44
			Object folderPath = iterator.next();
45
			Object folderPath = iterator.next();
45
			if (oldFolders == null || !oldFolders.remove(folderPath)) {
46
			if (oldFolders == null || !oldFolders.remove(folderPath) || foldersManager.removePendingFolder(folderPath)) {
46
				try {
47
				try {
47
					foldersManager.createLinkFolder((IPath) folderPath, refreshIfExistAlready, monitor);
48
					foldersManager.createLinkFolder((IPath) folderPath, refreshIfExistAlready, monitor);
48
				} catch (CoreException e) {
49
				} catch (CoreException e) {
(-)model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java (-9 / +59 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - inconsistent initialization of classpath container backed by external class folder, see https://bugs.eclipse.org/320618
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
12
package org.eclipse.jdt.internal.core;
12
13
Lines 20-25 Link Here
20
import java.util.HashSet;
21
import java.util.HashSet;
21
import java.util.Iterator;
22
import java.util.Iterator;
22
import java.util.Map;
23
import java.util.Map;
24
import java.util.Set;
23
import java.util.Vector;
25
import java.util.Vector;
24
26
25
import org.eclipse.core.resources.IFolder;
27
import org.eclipse.core.resources.IFolder;
Lines 36-41 Link Here
36
import org.eclipse.core.runtime.jobs.Job;
38
import org.eclipse.core.runtime.jobs.Job;
37
import org.eclipse.jdt.core.IClasspathEntry;
39
import org.eclipse.jdt.core.IClasspathEntry;
38
import org.eclipse.jdt.core.JavaCore;
40
import org.eclipse.jdt.core.JavaCore;
41
import org.eclipse.jdt.core.JavaModelException;
39
import org.eclipse.jdt.internal.core.util.Messages;
42
import org.eclipse.jdt.internal.core.util.Messages;
40
import org.eclipse.jdt.internal.core.util.Util;
43
import org.eclipse.jdt.internal.core.util.Util;
41
44
Lines 43-48 Link Here
43
	private static final String EXTERNAL_PROJECT_NAME = ".org.eclipse.jdt.core.external.folders"; //$NON-NLS-1$
46
	private static final String EXTERNAL_PROJECT_NAME = ".org.eclipse.jdt.core.external.folders"; //$NON-NLS-1$
44
	private static final String LINKED_FOLDER_NAME = ".link"; //$NON-NLS-1$
47
	private static final String LINKED_FOLDER_NAME = ".link"; //$NON-NLS-1$
45
	private Map folders;
48
	private Map folders;
49
	private Set pendingFolders; // subset of keys of 'folders', for which linked folders haven't been created yet.
46
	private int counter = 0;
50
	private int counter = 0;
47
	/* Singleton instance */
51
	/* Singleton instance */
48
	private static ExternalFoldersManager MANAGER = new ExternalFoldersManager();
52
	private static ExternalFoldersManager MANAGER = new ExternalFoldersManager();
Lines 102-112 Link Here
102
		return EXTERNAL_PROJECT_NAME.equals(resourcePath.segment(0));
106
		return EXTERNAL_PROJECT_NAME.equals(resourcePath.segment(0));
103
	}
107
	}
104
108
105
	public IFolder addFolder(IPath externalFolderPath) {
109
	public IFolder addFolder(IPath externalFolderPath, boolean scheduleForCreation) {
106
		return addFolder(externalFolderPath, getExternalFoldersProject());
110
		return addFolder(externalFolderPath, getExternalFoldersProject(), scheduleForCreation);
107
	}
111
	}
108
112
109
	private IFolder addFolder(IPath externalFolderPath, IProject externalFoldersProject) {
113
	private IFolder addFolder(IPath externalFolderPath, IProject externalFoldersProject, boolean scheduleForCreation) {
110
		Map knownFolders = getFolders();
114
		Map knownFolders = getFolders();
111
		Object existing = knownFolders.get(externalFolderPath);
115
		Object existing = knownFolders.get(externalFolderPath);
112
		if (existing != null) {
116
		if (existing != null) {
Lines 116-128 Link Here
116
		do {
120
		do {
117
			result = externalFoldersProject.getFolder(LINKED_FOLDER_NAME + this.counter++);
121
			result = externalFoldersProject.getFolder(LINKED_FOLDER_NAME + this.counter++);
118
		} while (result.exists());
122
		} while (result.exists());
123
		if (scheduleForCreation) {
124
			if (this.pendingFolders == null)
125
				this.pendingFolders = new HashSet();
126
			this.pendingFolders.add(externalFolderPath);
127
		}
119
		knownFolders.put(externalFolderPath, result);
128
		knownFolders.put(externalFolderPath, result);
120
		return result;
129
		return result;
121
	}
130
	}
131
	
132
	/** 
133
	 * Try to remove the argument from the list of folders pending for creation.
134
	 * @param externalPath to link to
135
	 * @return true if the argument was found in the list of pending folders and could be removed from it.
136
	 */
137
	public boolean removePendingFolder(Object externalPath) {
138
		if (this.pendingFolders == null)
139
			return false;
140
		return this.pendingFolders.remove(externalPath);
141
	}
122
142
123
	public IFolder createLinkFolder(IPath externalFolderPath, boolean refreshIfExistAlready, IProgressMonitor monitor) throws CoreException {
143
	public IFolder createLinkFolder(IPath externalFolderPath, boolean refreshIfExistAlready, IProgressMonitor monitor) throws CoreException {
124
		IProject externalFoldersProject = createExternalFoldersProject(monitor); // run outside synchronized as this can create a resource
144
		IProject externalFoldersProject = createExternalFoldersProject(monitor); // run outside synchronized as this can create a resource
125
		IFolder result = addFolder(externalFolderPath, externalFoldersProject);
145
		return createLinkFolder(externalFolderPath, refreshIfExistAlready, externalFoldersProject, monitor);
146
	}
147
148
	private IFolder createLinkFolder(IPath externalFolderPath, boolean refreshIfExistAlready,
149
									IProject externalFoldersProject, IProgressMonitor monitor) throws CoreException {
150
		
151
		IFolder result = addFolder(externalFolderPath, externalFoldersProject, false);
126
		if (!result.exists())
152
		if (!result.exists())
127
			result.createLink(externalFolderPath, IResource.ALLOW_MISSING_LOCAL, monitor);
153
			result.createLink(externalFolderPath, IResource.ALLOW_MISSING_LOCAL, monitor);
128
		else if (refreshIfExistAlready)
154
		else if (refreshIfExistAlready)
Lines 130-142 Link Here
130
		return result;
156
		return result;
131
	}
157
	}
132
158
159
	public void createPendingFolders(IProgressMonitor monitor) throws JavaModelException{
160
		if (this.pendingFolders == null || this.pendingFolders.isEmpty()) return;
161
		
162
		IProject externalFoldersProject = null;
163
		try {
164
			externalFoldersProject = createExternalFoldersProject(monitor);
165
		}
166
		catch(CoreException e) {
167
			throw new JavaModelException(e);
168
		}
169
		Iterator iterator = this.pendingFolders.iterator();
170
		while (iterator.hasNext()) {
171
			Object folderPath = iterator.next();
172
			try {
173
				createLinkFolder((IPath) folderPath, false, externalFoldersProject, monitor);
174
			} catch (CoreException e) {
175
				Util.log(e, "Error while creating a link for external folder :" + folderPath); //$NON-NLS-1$
176
			}
177
		}
178
		this.pendingFolders.clear();
179
	}
180
	
133
	public void cleanUp(IProgressMonitor monitor) throws CoreException {
181
	public void cleanUp(IProgressMonitor monitor) throws CoreException {
134
		ArrayList toDelete = getFoldersToCleanUp(monitor);
182
		ArrayList toDelete = getFoldersToCleanUp(monitor);
135
		if (toDelete == null)
183
		if (toDelete == null)
136
			return;
184
			return;
137
		for (Iterator iterator = toDelete.iterator(); iterator.hasNext();) {
185
		for (Iterator iterator = toDelete.iterator(); iterator.hasNext();) {
138
			IFolder folder = (IFolder) iterator.next();
186
			Map.Entry entry = (Map.Entry) iterator.next();
187
			IFolder folder = (IFolder) entry.getValue();
139
			folder.delete(true, monitor);
188
			folder.delete(true, monitor);
189
			IPath key = (IPath) entry.getKey();
190
			this.folders.remove(key);
140
		}
191
		}
141
		IProject project = getExternalFoldersProject();
192
		IProject project = getExternalFoldersProject();
142
		if (project.isAccessible() && project.members().length == 1/*remaining member is .project*/)
193
		if (project.isAccessible() && project.members().length == 1/*remaining member is .project*/)
Lines 158-168 Link Here
158
				IPath path = (IPath) entry.getKey();
209
				IPath path = (IPath) entry.getKey();
159
				if ((roots != null && !roots.containsKey(path))
210
				if ((roots != null && !roots.containsKey(path))
160
						&& (sourceAttachments != null && !sourceAttachments.containsKey(path))) {
211
						&& (sourceAttachments != null && !sourceAttachments.containsKey(path))) {
161
					IFolder folder = (IFolder) entry.getValue();
212
					if (entry.getValue() != null) {
162
					if (folder != null) {
163
						if (result == null)
213
						if (result == null)
164
							result = new ArrayList();
214
							result = new ArrayList();
165
						result.add(folder);
215
						result.add(entry);
166
					}
216
					}
167
				}
217
				}
168
			}
218
			}
Lines 173-179 Link Here
173
	public IProject getExternalFoldersProject() {
223
	public IProject getExternalFoldersProject() {
174
		return ResourcesPlugin.getWorkspace().getRoot().getProject(EXTERNAL_PROJECT_NAME);
224
		return ResourcesPlugin.getWorkspace().getRoot().getProject(EXTERNAL_PROJECT_NAME);
175
	}
225
	}
176
	private IProject createExternalFoldersProject(IProgressMonitor monitor) throws CoreException {
226
	public IProject createExternalFoldersProject(IProgressMonitor monitor) throws CoreException {
177
		IProject project = getExternalFoldersProject();
227
		IProject project = getExternalFoldersProject();
178
		if (!project.isAccessible()) {
228
		if (!project.isAccessible()) {
179
			if (!project.exists()) {
229
			if (!project.exists()) {
(-)model/org/eclipse/jdt/internal/core/JavaProject.java (-1 / +2 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - inconsistent initialization of classpath container backed by external class folder, see https://bugs.eclipse.org/320618
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
12
package org.eclipse.jdt.internal.core;
12
13
Lines 2736-2742 Link Here
2736
			}
2737
			}
2737
		}
2738
		}
2738
		if (resolvedEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && ExternalFoldersManager.isExternalFolderPath(resolvedPath)) {
2739
		if (resolvedEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && ExternalFoldersManager.isExternalFolderPath(resolvedPath)) {
2739
			externalFoldersManager.addFolder(resolvedPath); // no-op if not an external folder or if already registered
2740
			externalFoldersManager.addFolder(resolvedPath, true/*scheduleForCreation*/); // no-op if not an external folder or if already registered
2740
		}
2741
		}
2741
	}
2742
	}
2742
2743
(-)plugin.xml (+6 lines)
Lines 47-52 Link Here
47
			class="org.eclipse.jdt.core.tests.model.ContainerInitializer"/>
47
			class="org.eclipse.jdt.core.tests.model.ContainerInitializer"/>
48
	</extension>
48
	</extension>
49
49
50
	<extension point = "org.eclipse.jdt.core.classpathContainerInitializer">
51
		<classpathContainerInitializer
52
			id="org.eclipse.jdt.core.tests.model.TEST_EXTERNAL_LIB_CONTAINER"
53
			class="org.eclipse.jdt.core.tests.extensions.TestExternalLibContainerInitializer"/>
54
	</extension>
55
50
	<!-- Extra Java-like file extensions -->
56
	<!-- Extra Java-like file extensions -->
51
	<extension point="org.eclipse.core.contenttype.contentTypes"> 
57
	<extension point="org.eclipse.core.contenttype.contentTypes"> 
52
	    <file-association 
58
	    <file-association 
(-)src/org/eclipse/jdt/core/tests/extensions/TestExternalLibContainerInitializer.java (+56 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Stephan Herrmann.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - inconsistent initialization of classpath container backed by external class folder, see https://bugs.eclipse.org/320618
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.extensions;
12
13
import org.eclipse.core.resources.ResourcesPlugin;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.jdt.core.ClasspathContainerInitializer;
17
import org.eclipse.jdt.core.IClasspathContainer;
18
import org.eclipse.jdt.core.IClasspathEntry;
19
import org.eclipse.jdt.core.IJavaProject;
20
import org.eclipse.jdt.core.JavaCore;
21
22
public class TestExternalLibContainerInitializer extends ClasspathContainerInitializer {
23
24
	IClasspathEntry[] entries;
25
	
26
	public void initialize(final IPath containerName, IJavaProject project)
27
			throws CoreException {
28
		IPath ws = ResourcesPlugin.getWorkspace().getRoot().getLocation();
29
		final IPath containerPath = ws.append("../TestContainer/");
30
		IClasspathContainer container = new IClasspathContainer() {
31
			
32
			public IPath getPath() {
33
				return containerName;
34
			}
35
			
36
			public int getKind() {
37
				return IClasspathContainer.K_APPLICATION;
38
			}
39
			
40
			public String getDescription() {
41
				return "Test Container";
42
			}
43
			
44
			public IClasspathEntry[] getClasspathEntries() {
45
				if (TestExternalLibContainerInitializer.this.entries == null) {
46
					TestExternalLibContainerInitializer.this.entries = new IClasspathEntry[] {
47
							JavaCore.newLibraryEntry(containerPath, null, null)	
48
						};
49
				}
50
				return TestExternalLibContainerInitializer.this.entries;
51
			}
52
		};
53
		JavaCore.setClasspathContainer(containerName, new IJavaProject[]{ project}, new IClasspathContainer[] { container }, null);
54
	}
55
56
}
(-)src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java (-1 / +70 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - inconsistent initialization of classpath container backed by external class folder, see https://bugs.eclipse.org/320618
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.model;
12
package org.eclipse.jdt.core.tests.model;
12
13
Lines 35-40 Link Here
35
public JavaProjectTests(String name) {
36
public JavaProjectTests(String name) {
36
	super(name);
37
	super(name);
37
}
38
}
39
static {
40
//	TESTS_NAMES = new String[] { "testAddExternalLibFolder6" };
41
}
38
public static Test suite() {
42
public static Test suite() {
39
	TestSuite suite = (TestSuite) buildModelTestSuite(JavaProjectTests.class);
43
	TestSuite suite = (TestSuite) buildModelTestSuite(JavaProjectTests.class);
40
44
Lines 170-175 Link Here
170
}
174
}
171
175
172
/*
176
/*
177
 * Ensures that a type from a classpath container pointing to an external folder can be resolved
178
 * Bug 320618 -  inconsistent initialization of classpath container backed by external class folder
179
 */
180
public void testAddExternalLibFolder6() throws CoreException, IOException {
181
	IWorkspace workspace = null;
182
	try {
183
		simulateExitRestart();
184
185
		// create a class folder outside the testing workspace:
186
		createExternalFolder("TestContainer/p");
187
		workspace = ResourcesPlugin.getWorkspace();
188
		File workspaceLocation = new File(workspace.getRoot().getLocation().toOSString());
189
		File classFileSrc = new File(workspaceLocation, "JavaProjectLibTests/lib/p/Y.class");
190
		File classFileDst = new File(workspaceLocation.getParentFile().getCanonicalFile(), "TestContainer/p/Y.class"); // canonicalize the external path as this is not done on case sensitive platforms when creating a new lib entry
191
		copy(classFileSrc, classFileDst);
192
193
		// setup a project depending on the classpath container:
194
		IJavaProject javaProject = setUpJavaProject("ExternalContainer");
195
		IProject p = javaProject.getProject();
196
		
197
		// build should find no errors:
198
		p.build(IncrementalProjectBuilder.FULL_BUILD, null);
199
		IMarker[] markers = p.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
200
		for (int i=0; i<markers.length; i++)
201
			System.out.println("unexpected marker: "+markers[i].getType()+": "+markers[i].getAttribute(IMarker.MESSAGE));
202
		assertEquals("Unexpected markers", markers.length, 0);
203
		
204
	} finally {
205
		deleteExternalResource("TestContainer");
206
		deleteProject("ExternalContainer");
207
	}
208
	workspace.save(true, null);
209
	// second go most be unaffected by previously used external links:
210
	// (tests ExternalFoldersManager.cleanUp())
211
	try {
212
		// *don't* reset: simulateExitRestart();
213
214
		// from hereon same as before:
215
216
		// create a class folder outside the testing workspace:
217
		createExternalFolder("TestContainer/p");
218
		workspace = ResourcesPlugin.getWorkspace();
219
		File workspaceLocation = new File(workspace.getRoot().getLocation().toOSString());
220
		File classFileSrc = new File(workspaceLocation, "JavaProjectLibTests/lib/p/Y.class");
221
		File classFileDst = new File(workspaceLocation.getParentFile().getCanonicalFile(), "TestContainer/p/Y.class"); // canonicalize the external path as this is not done on case sensitive platforms when creating a new lib entry
222
		copy(classFileSrc, classFileDst);
223
224
		// setup a project depending on the classpath container:
225
		IJavaProject javaProject = setUpJavaProject("ExternalContainer");
226
		IProject p = javaProject.getProject();
227
		
228
		// build should find no errors:
229
		p.build(IncrementalProjectBuilder.FULL_BUILD, null);
230
		IMarker[] markers = p.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
231
		for (int i=0; i<markers.length; i++)
232
			System.out.println("unexpected marker: "+markers[i].getType()+": "+markers[i].getAttribute(IMarker.MESSAGE));
233
		assertEquals("Unexpected markers", markers.length, 0);
234
		
235
	} finally {
236
		deleteExternalResource("TestContainer");
237
		deleteProject("ExternalContainer");
238
	}
239
}
240
241
/*
173
 * Ensures that adding a library entry for an existing empty external ZIP archive updates the model
242
 * Ensures that adding a library entry for an existing empty external ZIP archive updates the model
174
 */
243
 */
175
public void testAddZIPArchive1() throws Exception {
244
public void testAddZIPArchive1() throws Exception {
(-)workspace/ExternalContainer/.classpath (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.core.tests.model.TEST_EXTERNAL_LIB_CONTAINER"/>
5
	<classpathentry kind="var" path="JCL_LIB"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
(-)workspace/ExternalContainer/.project (+17 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>ExternalContainer</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.jdt.core.javanature</nature>
16
	</natures>
17
</projectDescription>
(-)workspace/ExternalContainer/src/p2/X.java (+5 lines)
Added Link Here
1
package p2;
2
import p.Y;
3
public class X {
4
    Y y;
5
}

Return to bug 343509