This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
SourcesHelper.registerExternalSourceRoots Javadoc states: "You may _not_ call this method inside the project's constructor, as it requires the actual project to exist and be registered in ProjectManager. Typically you would use Mutex.postWriteRequest to run it later, if you were creating the helper in your constructor, since the project construction normally occurs in read access." Unfortunately using pWR results in strange threading behavior, including unreliable tests (see #b5f07b919bea and #abb8ce297ad9 for example). Perhaps this weirdness could be avoided if the SourcesHelper constructor took an optional Project object (with the understanding that it need not yet be registered in ProjectManager). Then it would not need to find the Project from the AntProjectHelper, which would make it possible to register the external source roots synchronously.
Created attachment 69591 [details] Start of a patch
Has been a problem since the creation of SourcesHelper.
Well, if that's all what needs to be done to resolve this issue then I wonder why have not we done it earlier. Patch looks good to me. Thanks Jesse.
I would love to have this in 6.5, but if not, then I will need to work around the timing in the Eclipse project importer: after creating a new j2seproject (or web project), it cannot immediately use ProjectClassPathModifier, as external roots will not yet be owned; it needs to delay this action using postWriteRequest (to run after the registerExternalRoots).
Let's fix it for 6.5. Have you intentionally passed it to Milan or would you implement it yourself Jesse? If you introduce new API I'm happy to update Web/J2EE projects separately.
I just passed it to Milan as default owner and to get a review. I don't mind doing the work but it seems too late to make a change like this for 6.5, isn't it?
Actually it seems that this is not such a high priority; in the case of the Eclipse project import, the roots are actually registered inside the call to J2SEProjectGenerator.createProject, since we are running all this in write access: at org.netbeans.spi.project.support.ant.SourcesHelper.remarkExternalRoots(SourcesHelper.java:524) at org.netbeans.spi.project.support.ant.SourcesHelper.registerExternalRoots(SourcesHelper.java:516) at org.netbeans.modules.java.j2seproject.J2SESources$2.run(J2SESources.java:164) at org.openide.util.Mutex.leaveImpl(Mutex.java:902) at org.openide.util.Mutex.leave(Mutex.java:835) at org.openide.util.Mutex.readAccess(Mutex.java:333) at org.openide.util.Mutex$1R.run(Mutex.java:1299) at org.openide.util.Mutex.doWrapperAccess(Mutex.java:1318) at org.openide.util.Mutex.readAccess(Mutex.java:320) at org.netbeans.api.project.ProjectManager.findProject(ProjectManager.java:241) at org.netbeans.spi.project.support.ant.ProjectGenerator$1.run(ProjectGenerator.java:161) at org.netbeans.spi.project.support.ant.ProjectGenerator$1.run(ProjectGenerator.java:115) at org.openide.util.Mutex.writeAccess(Mutex.java:433) at org.openide.util.Mutex$1R.run(Mutex.java:1305) at org.openide.util.Mutex.doWrapperAccess(Mutex.java:1318) at org.openide.util.Mutex.writeAccess(Mutex.java:426) at org.netbeans.spi.project.support.ant.ProjectGenerator.createProject0(ProjectGenerator.java:114) at org.netbeans.spi.project.support.ant.ProjectGenerator.createProject(ProjectGenerator.java:108) at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.createProject(J2SEProjectGenerator.java:223) There seems to be some other problem making Eclipse import with external roots be broken, but I am still investigating what that might be.
*** Issue 142938 has been marked as a duplicate of this issue. ***
Lack of this seems to prevent a simple-looking patch to projectimport.eclipse.core from working (an AE is thrown similar to issue #142938 when you try to import a project). I will attach that patch here.
Created attachment 75644 [details] Desired patch
Reassigning to Jesse.
Created attachment 78555 [details] Updated patch
Please review.
Created attachment 79246 [details] Running patch... still working on this, expect to commit soon
core-main #23a442bff758
Integrated into 'main-golden', will be available in build *200904031400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/23a442bff758 User: Jesse Glick <jglick@netbeans.org> Log: Issue #146852: accept Project in a constructor for SourcesHelper to permit registerExternalRoots to run synch. Can help simplify tests, and makes control flow easier to understand and debug. Also taking advantage of synchronous control flow to optimize class loading in the Eclipse importer.
*** Issue 154263 has been marked as a duplicate of this issue. ***