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.
I have a J2SE project with Java and Groovy files (and JPA classes, but I don't think that is relevant). Any time I make the smallest change in one Java file, NetBeans goes into this long sequence of "Refreshing Workspace" and recompiling. I dumped the stack using jvisualvm and noticed that there was a Groovy process running: (I will attach the full stack trace and create trace logs as well.) "Java Source Worker Thread" daemon prio=10 tid=0x08d84c00 nid=0x20ef in Object.wait() [0xb0d11000..0xb0d12030] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x6e7a29c8> (a org.openide.windows.CloneableOpenSupport$Listener) at java.lang.Object.wait(Object.java:485) at org.openide.text.CloneableEditorSupport.openDocumentImpl(CloneableEditorSupport.java:756) at org.openide.text.CloneableEditorSupport.openDocumentImpl(CloneableEditorSupport.java:745) at org.openide.text.CloneableEditorSupport.openDocumentCheckIOE(CloneableEditorSupport.java:725) at org.openide.text.CloneableEditorSupport.openDocument(CloneableEditorSupport.java:720) - locked <0x6e7a29c8> (a org.openide.windows.CloneableOpenSupport$Listener) at org.openide.text.DataEditorSupport.openDocument(DataEditorSupport.java:400) at org.netbeans.modules.groovy.editor.AstUtilities.getBaseDocument(AstUtilities.java:130) at org.netbeans.modules.groovy.editor.parser.SourceUtils$1.read(SourceUtils.java:75) at org.netbeans.modules.groovy.editor.parser.GroovyParser.parseFiles(GroovyParser.java:116) at org.netbeans.modules.groovy.editor.parser.SourceUtils.runUserActionTask(SourceUtils.java:102) at org.netbeans.modules.groovy.editor.parser.GroovyVirtualSourceProvider.getClassNodes(GroovyVirtualSourceProvider.java:131) at org.netbeans.modules.groovy.editor.parser.GroovyVirtualSourceProvider.translate(GroovyVirtualSourceProvider.java:90) at org.netbeans.modules.java.source.usages.VirtualSourceProviderQuery.translate(VirtualSourceProviderQuery.java:125) at org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.parseFiles(RepositoryUpdater.java:2122) at org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.parseFiles(RepositoryUpdater.java:1822) at org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.compileFileFromRoots(RepositoryUpdater.java:2680) at org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.recompile(RepositoryUpdater.java:2564) at org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.access$3800(RepositoryUpdater.java:1239) at org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker$1.run(RepositoryUpdater.java:1575) at org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker$1.run(RepositoryUpdater.java:1281) at org.netbeans.modules.java.source.usages.ClassIndexManager.writeLock(ClassIndexManager.java:99) at org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.run(RepositoryUpdater.java:1278) at org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.run(RepositoryUpdater.java:1239) at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1588) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:619)
Created attachment 69999 [details] Thread dump while IDE was "Refreshing Workspace"
Created attachment 70000 [details] Log with -J-Dorg.netbeans.modules.java.source.usages.RepositoryUpdater.level=0
Created attachment 70001 [details] Log with -J-Dorg.netbeans.modules.java.source.usages.RepositoryUpdater.level=0
Can you please provide more information about how many java and groovy classes you have and how long the refresh takes?
From the log, I see the following problem: -the user edits the file, modifies a method/field/class signature, the file is saved -the file is compiled, and all the "dependent" files are recompiled - this is correct and is needed to show correct error badges (among other things). -but, as a side effect, all virtual files are recompiled - which is wrong, as it is useless (IMO), and slow See RepositoryUpdater.compileFileFromRoots, local variable virtualFiles. As a safest fix, I think that computation and recompilation of virtual files should be disabled when called from RU.recompile.
Caused by the groovy files which are rebuilt after save, should be easy to fix. Thanks for report.
http://hg.netbeans.org/main/rev/d367be04b2e4
Integrated into 'main-golden', will be available in build *200809180201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/d367be04b2e4 User: Tomas Zezula <tzezula@netbeans.org> Log: #147438:Workspace refreshes and builds any time Java file is changed