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.
SourceUtils.isMainClass() has two parts. First it looks for the class in the list of main classes in the index (from sources) and if not found it triggers an expensive task to look for the class in all classpath elements. The task can eventually be waiting on a parser lock in org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(). For the purpose of fixing issue 183972, a new method is needed which will search only in the index and then return false without doing the thorough parsing if not found in the index.
As discussed off line this will work only for sources not for binaries, eg. when you select the main class from platform or compile cp. But maven seems to use the isMC only for sources, so it should work.
The light way version will not be able to detect inherited main method, like: class A { psv main(String...) {} } class B extends A {} as the inheritance check requires parsing and should be done outside AWT. Is such a method with such a restriction useful for you?
I don't have a strong opinion. My guess is that inherited main() methods are not an important usecase which would have to be supported by Run File action on a project. Looking for Jesse's view as well...
(In reply to comment #3) > inherited main() methods are not an important usecase Agreed. You can't meaningfully inherit static methods anyway, and some bug checkers will flag attempts to use static methods via inheritance as bad code style. I would not expect B in your example to be marked as having a main method, i.e. it is OK for DefaultReplaceTokenProvider to enable Run File only on source files literally containing main.
Sounds good. Tomasi, please prepare the extra method.
OK, thanks Tondo and Jesse.
Fixed jet-main 2f07ff0e0bb7
Integrated into 'main-golden', will be available in build *201012110001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/2f07ff0e0bb7 User: Tomas Zezula <tzezula@netbeans.org> Log: #191648:More light-weight variant of SourceUtils.isMainClass() #193101:API review of SourceUtils.isMain