View | Details | Raw Unified | Return to bug 183413
Collapse All | Expand All

(-)model/org/eclipse/jdt/core/JavaCore.java (+21 lines)
Lines 3242-3247 Link Here
3242
					monitor.subTask(Messages.javamodel_configuring_classpath_containers);
3242
					monitor.subTask(Messages.javamodel_configuring_classpath_containers);
3243
					manager.batchContainerInitializationsProgress.set(new SubProgressMonitor(monitor, 50)); // 50% of the time is spent in initializing containers and variables
3243
					manager.batchContainerInitializationsProgress.set(new SubProgressMonitor(monitor, 50)); // 50% of the time is spent in initializing containers and variables
3244
				}
3244
				}
3245
				
3246
				// all classpaths in the workspace are going to be resolved, ensure that containers are initialized in one batch
3247
				manager.batchContainerInitializations = true; 
3248
				
3249
				// avoid leaking source attachment properties (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=183413)
3250
				IJavaProject[] projects = manager.getJavaModel().getJavaProjects();
3251
				for (int i = 0, length = projects.length; i < length; i++) {
3252
					IClasspathEntry[] classpath = ((JavaProject) projects[i]).getResolvedClasspath();
3253
					if (classpath != null) {
3254
						for (int j = 0, length2 = classpath.length; j < length2; j++) {
3255
							IClasspathEntry entry = classpath[j];
3256
							if (entry.getSourceAttachmentPath() != null)
3257
								Util.setSourceAttachmentProperty(entry.getPath(), null);
3258
							// else source might have been attached by IPackageFragmentRoot#attachSource(...), we keep it
3259
						}
3260
					}
3261
				}
3262
				
3263
				// initialize delta state
3264
				manager.deltaState.rootsAreStale = true; // in case it was already initialized before we cleaned up the source attachment proprties
3245
				manager.deltaState.initializeRoots();
3265
				manager.deltaState.initializeRoots();
3246
			} finally {
3266
			} finally {
3247
				manager.batchContainerInitializationsProgress.set(null);
3267
				manager.batchContainerInitializationsProgress.set(null);
Lines 3348-3353 Link Here
3348
			} catch (JavaModelException e) {
3368
			} catch (JavaModelException e) {
3349
				// refreshing failed: ignore
3369
				// refreshing failed: ignore
3350
			}
3370
			}
3371
			
3351
		} finally {
3372
		} finally {
3352
			if (monitor != null) monitor.done();
3373
			if (monitor != null) monitor.done();
3353
		}
3374
		}
(-)src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java (+25 lines)
Lines 708-713 Link Here
708
	}
708
	}
709
}
709
}
710
710
711
/*
712
 * Ensures that a source attached during a session is not taken into account on restart
713
 * if the entry has a source attachment.
714
 * (regression test for bug 183413 PDE can't find the source for plug-ins in the target)
715
 */
716
public void testRestart() throws Exception {
717
	try {
718
		this.pkgFragmentRoot.attachSource(new Path("/AttachSourceTests/attachsrc.new.zip"), new Path("")/*source root*/, null/*no progress*/);
719
		
720
		simulateExitRestart();
721
		JavaCore.initializeAfterLoad(null);
722
		
723
		// ensure source is correct
724
		IClassFile cf = this.pkgFragmentRoot.getPackageFragment("x.y").getClassFile("A.class");
725
		IMethod method = cf.getType().getMethod("foo", new String[] {});
726
		assertSourceEquals(
727
			"unexpected source for foo()",
728
			"public void foo() {\n" + 
729
			"	}",
730
			method.getSource());
731
	} finally {
732
		this.pkgFragmentRoot.attachSource(null/*no source attachment*/, null/*no source root*/, null/*no progress*/);
733
	}
734
}
735
711
/**
736
/**
712
 * Attaches a source zip to a jar.  The source zip has
737
 * Attaches a source zip to a jar.  The source zip has
713
 * a nested root structure and exists as a resource.  Tests that
738
 * a nested root structure and exists as a resource.  Tests that

Return to bug 183413