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.

Bug 194569 - CreatedModifiedFiles.PackageInfo sometimes fails to find API class
Summary: CreatedModifiedFiles.PackageInfo sometimes fails to find API class
Status: RESOLVED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on: 207486
Blocks:
  Show dependency tree
 
Reported: 2011-01-21 10:03 UTC by tim_sa
Modified: 2012-05-08 00:16 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 172194


Attachments
stacktrace (2.93 KB, text/plain)
2011-01-21 10:03 UTC, tim_sa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tim_sa 2011-01-21 10:03:25 UTC
Build: NetBeans IDE 6.9.1 (Build 201011082200)
VM: Java HotSpot(TM) 64-Bit Server VM, 11.2-b01, Java(TM) SE Runtime Environment, 1.6.0_12-b04
OS: Windows Vista

Stacktrace: 
java.lang.IllegalArgumentException: No such annotation could be found: org.netbeans.spi.options.OptionsPanelController.ContainerRegistration
   at org.netbeans.modules.apisupport.project.CreatedModifiedFilesFactory$PackageInfo$1$1.run(CreatedModifiedFilesFactory.java:842)
   at org.netbeans.modules.apisupport.project.CreatedModifiedFilesFactory$PackageInfo$1$1.run(CreatedModifiedFilesFactory.java:833)
   at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:665)
   at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:154)
   at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:138)
   at org.netbeans.modules.parsing.impl.TaskProcessor$1.call(TaskProcessor.java:200)
Comment 1 tim_sa 2011-01-21 10:03:29 UTC
Created attachment 105234 [details]
stacktrace
Comment 2 Jesse Glick 2011-01-21 14:13:29 UTC
Not reproducible so far as I know; probably some kind of race condition. (Reporter: just try rerunning wizard.) I suspect a bug in java.source or parsing.impl but it is hard to tell. See bug #119887 comment #10 for example with a more informative stack trace (added in 7400ee597b40). The user finishes the wizard, the right API dependency is added to the project, a Java source modification task is started, and it tries to look up a class in the new API and fails.
Comment 3 Jesse Glick 2011-01-21 14:19:43 UTC
(In reply to comment #2)
> it tries to look up a class in the new API and fails.

Specifically: workingCopy.getElements().getTypeElement(fqn) returns null when workingCopy.getClasspathInfo() appears to contain the JAR defining this class. This makes me suspect a problem with the class index not catching up with the parser.
Comment 4 Jesse Glick 2011-01-22 00:18:53 UTC
I think I can reproduce it. Start the IDE with a clean userdir (probably just var/cache/ index matters), create a new module project, create a primary option panel permitting secondary panels. The deps are added, project scanning starts, and the exception is thrown (the wizard then stays open).

If you cancel the wizard, remove the deps from the project, and try again, then it works fine. Which would be consistent with the problem being a class index that has not yet been created.
Comment 5 Jan Lahoda 2011-01-27 14:23:18 UTC
Both JavaSource.runUserActionTask and JS.runModificationTask are able to interrupt scanning (currently only between source roots). If the caches need to be correct, run inside a JS.runWhenScanFinished or after SourceUtils.waitScanFinished().
Comment 6 Jesse Glick 2011-01-27 14:28:56 UTC
OK, I will try one of those.
Comment 7 Jesse Glick 2012-04-13 13:58:35 UTC
core-main #63839d9fb5d5
Comment 8 Jesse Glick 2012-04-13 14:09:00 UTC
This fix seems to work, but it looks wrong somehow. waitScanFinished is deprecated so that is out. runWhenScanFinished is available, but offers only a CompilationController, which I cannot figure out how to do anything with. So I am continuing to use runModificationTask which gives me the WorkingCopy I need, just _inside_ runWhenScanFinished.

Surely I am not the first person to need to make a change to Java source files that has to work reliably in the presence of scanning. Is there no more natural idiom? JavaHT_Modification [1] says nothing about this. runModificationTask Javadoc does not mention runWhenScanFinished or the possibility that it might be running in the middle of an uncompleted scan (*).

(*) It just says "will cancel processing of all the phase completion tasks until this task does not finish" which I do not quite understand - it is not grammatical English. Do you mean "until this task finishes"?

[1] http://wiki.netbeans.org/JavaHT_Modification
Comment 9 Quality Engineering 2012-04-14 09:45:44 UTC
Integrated into 'main-golden', will be available in build *201204140400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/63839d9fb5d5
User: Jesse Glick <jglick@netbeans.org>
Log: #194569: CreatedModifiedFiles.PackageInfo sometimes fails to find API class
Comment 10 Jesse Glick 2012-05-07 21:07:29 UTC
runWhenScanFinished does not really work, it just turns the problem into an IOE which gets ignored by the Finish button so the dialog stays open until deps are downloaded (at which point you can click Finish again and it will work):

INFO [org.openide.WizardDescriptor]
java.io.IOException: No annotation org.netbeans.api.javahelp.HelpSetRegistration in ClasspathInfo ....
	at org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles$PackageInfo$1$1$1.run(CreatedModifiedFiles.java:1178)
	at org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles$PackageInfo$1$1$1.run(CreatedModifiedFiles.java:1170)
	at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:644)
	at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:634)
	at org.netbeans.modules.java.source.parsing.MimeTask.run(MimeTask.java:83)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:583)
	at org.netbeans.modules.parsing.api.ParserManager$MimeTaskAction.run(ParserManager.java:376)
	at org.netbeans.modules.parsing.api.ParserManager$MimeTaskAction.run(ParserManager.java:360)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:200)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:197)
	at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:176)
	at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:360)
	at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:72)
	at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:197)
	at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:331)
	at org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:417)
Caused: java.io.IOException
	at org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:429)
	at org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:409)
	at org.netbeans.api.java.source.JavaSource.runModificationTask(JavaSource.java:655)
	at org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles$PackageInfo$1$1.run(CreatedModifiedFiles.java:1170)
	at org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles$PackageInfo$1$1.run(CreatedModifiedFiles.java:1168)
	at org.netbeans.modules.java.source.parsing.MimeTask.run(MimeTask.java:83)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:583)
	at org.netbeans.modules.parsing.api.ParserManager$MimeTaskAction.run(ParserManager.java:376)
	at org.netbeans.modules.parsing.api.ParserManager$MimeTaskAction.run(ParserManager.java:360)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:200)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:197)
	at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:176)
	at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:360)
	at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:72)
	at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:197)
	at org.netbeans.modules.parsing.impl.RunWhenScanFinishedSupport.runWhenScanFinished(RunWhenScanFinishedSupport.java:133)
	at org.netbeans.modules.parsing.api.ParserManager.parseWhenScanFinished(ParserManager.java:354)
	at org.netbeans.api.java.source.JavaSource.runWhenScanFinished(JavaSource.java:578)
Caused: java.io.IOException
	at org.netbeans.api.java.source.JavaSource.runWhenScanFinished(JavaSource.java:590)
	at org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles$PackageInfo$1.run(CreatedModifiedFiles.java:1168)
	at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:127)
	at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:607)
	at org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles$PackageInfo.run(CreatedModifiedFiles.java:1154)
	at org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles.run(CreatedModifiedFiles.java:331)
	at org.netbeans.modules.apisupport.project.ui.wizard.javahelp.NewJavaHelpIterator.instantiate(NewJavaHelpIterator.java:77)
	at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1024)
	at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:589)
	at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:432)
	at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:248)
	at org.openide.loaders.TemplateWizardIteratorWrapper.instantiate(TemplateWizardIteratorWrapper.java:160)
	at org.openide.WizardDescriptor.callInstantiateOpen(WizardDescriptor.java:1600)
	at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1541)
	at org.openide.WizardDescriptor.access$2000(WizardDescriptor.java:139)
[catch] at org.openide.WizardDescriptor$Listener$2$1.run(WizardDescriptor.java:2165)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1452)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2032)