Bug 251629 - Adding JUnit by quick fix throws IAE
Summary: Adding JUnit by quick fix throws IAE
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.5 M3   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-21 17:44 EDT by Benjamin Muskalla CLA
Modified: 2009-02-27 10:58 EST (History)
2 users (show)

See Also:


Attachments
Fix for R3_4_maintenance (1.73 KB, patch)
2009-02-27 10:58 EST, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Muskalla CLA 2008-10-21 17:44:51 EDT
N20081005-2000

Paste the following into an empty project:
------------
package p;

public class ATest extends TestCase {

}
------------

Use quick fix to "Add Junit 3 to build path". This throws the following IAE:
java.lang.IllegalArgumentException: Attempted to beginRule: MultiRule[P/tests,P/.org.eclipse.jdt.core.external.folders], does not match outer scope rule: P/tests
	at org.eclipse.core.runtime.Assert.isLegal(Assert.java:64)
	at org.eclipse.core.internal.jobs.ThreadJob.illegalPush(ThreadJob.java:122)
	at org.eclipse.core.internal.jobs.ThreadJob.push(ThreadJob.java:232)
	at org.eclipse.core.internal.jobs.ImplicitJobs.begin(ImplicitJobs.java:58)
	at org.eclipse.core.internal.jobs.JobManager.beginRule(JobManager.java:231)
	at org.eclipse.core.internal.resources.WorkManager.checkIn(WorkManager.java:117)
	at org.eclipse.core.internal.resources.Workspace.prepareOperation(Workspace.java:1747)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1795)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:786)
	at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2855)
	at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2871)
	at org.eclipse.jdt.internal.corext.refactoring.changes.ClasspathChange.perform(ClasspathChange.java:88)
	at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
	at org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:260)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
	at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:308)
	at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.executeChange(UIPerformChangeOperation.java:110)
	at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:225)
	at org.eclipse.jdt.internal.junit.ui.JUnitQuickFixProcessor$1.run(JUnitQuickFixProcessor.java:239)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:446)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:354)
	at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2487)
	at org.eclipse.jdt.internal.junit.ui.JUnitQuickFixProcessor$JUnitClasspathFixCorrectionProposal.apply(JUnitQuickFixProcessor.java:231)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:929)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:875)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:1302)
	at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:806)
	<snip>
Comment 1 Dani Megert CLA 2008-10-22 11:46:58 EDT
This used to work but got broken during M3. Looks related to external folder support.
Comment 2 Jerome Lanneluc CLA 2008-10-23 12:40:50 EDT
Problem is with org.eclipse.jdt.internal.junit.ui.JUnitQuickFixProcessor.JUnitClasspathFixCorrectionProposal.apply(IDocument) that wrongly assumes that the IProject scheduling rule is enough when running setRawClasspath(). However this method specifies that:
"This operation acquires a lock on the workspace's root."

Back to JDT/UI.
Comment 3 Dani Megert CLA 2008-10-24 03:10:22 EDT
Jérome I agree. Why did it work so far? If a fix was made that now surfaces this now I suggest to add a section to the migration guide.
Comment 4 Dani Megert CLA 2008-10-24 05:09:27 EDT
Fixed in HEAD.
Available in builds > N20081023-2000.
Comment 5 Jerome Lanneluc CLA 2008-10-24 06:09:34 EDT
As you guessed, it worked because external folders were not considered.
As for documenting it, I'm not convinced this is useful since the spec is quite clear, so clients following the spec should not see this issue.
Comment 6 Dani Megert CLA 2008-10-27 05:58:08 EDT
> I'm not convinced this is useful since the spec is quite
>clear, so clients following the spec should not see this issue.
I completely agree that this is the clients fault but I think it would be useful because so far those clients just worked fine and people often copy our code even if it's broken. Hence a hint in the FAQ part of the migration guide might would be quite useful.
Comment 7 Dani Megert CLA 2008-10-28 06:48:24 EDT
Verified in I20081027-1300.
Comment 8 Markus Keller CLA 2009-02-27 10:58:54 EST
Created attachment 127010 [details]
Fix for R3_4_maintenance

Released to R3_4_maintenance (to catch up with bug 249930 comment 27).