Bug 539824 - MainMethodSearchEngine.addSubtypes(...) invoked for no good reason
Summary: MainMethodSearchEngine.addSubtypes(...) invoked for no good reason
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.5   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-05 03:34 EDT by Mickael Istria CLA
Modified: 2022-10-13 00:46 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2018-10-05 03:34:43 EDT
I'm using Run As > Java Application on a class that has a proper main(...) method. However, it's taking some time to build a Type Hierarchy I didn't ask for.
I've tried jstack and see

	at org.eclipse.jdt.internal.core.SourceType.newTypeHierarchy(SourceType.java:844)
	at org.eclipse.jdt.internal.debug.ui.launcher.MainMethodSearchEngine.addSubtypes(MainMethodSearchEngine.java:129)
	at org.eclipse.jdt.internal.debug.ui.launcher.MainMethodSearchEngine.searchMainMethods(MainMethodSearchEngine.java:106)
	at org.eclipse.jdt.internal.debug.ui.launcher.MainMethodSearchEngine$1.run(MainMethodSearchEngine.java:166)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)


It seems like despite my class has a correct main(...) method, the launcher decides to look for other ones. I don't think it's a necessary nor desired behaviour in that case: let's just pick the correct one that's inside the current class and not care about the type hierarchy.
Comment 1 Sarika Sinha CLA 2018-10-05 04:11:20 EDT
Do you have the new indexer ?
See Bug 513334.
Comment 2 Mickael Istria CLA 2018-10-05 04:18:15 EDT
(In reply to Sarika Sinha from comment #1)
> Do you have the new indexer ?
> See Bug 513334.

Could be this.
However, what I question more in this ticket is why building a type hierarchy for this use case. Even if I wasn't facing the performance issue, it still seems like a waste of effort/CPU/energy to do so at this time.
Comment 3 Sarika Sinha CLA 2018-10-05 07:08:48 EDT
(In reply to Mickael Istria from comment #2)
> (In reply to Sarika Sinha from comment #1)
> > Do you have the new indexer ?
> > See Bug 513334.
> 
> Could be this.
> However, what I question more in this ticket is why building a type
> hierarchy for this use case. Even if I wasn't facing the performance issue,
> it still seems like a waste of effort/CPU/energy to do so at this time.

Java doc says -
         * Searches for all main methods in the given scope.
	 * Valid styles are IJavaElementSearchConstants.CONSIDER_BINARIES and
	 * IJavaElementSearchConstants.CONSIDER_EXTERNAL_JARS
	 *
	 * @param pm progress monitor
	 * @param scope search scope
	 * @param includeSubtypes whether to consider types that inherit a main method
Comment 4 Mickael Istria CLA 2018-10-05 07:20:35 EDT
(In reply to Sarika Sinha from comment #3)
> Java doc says -
>          * Searches for all main methods in the given scope.

Ok, so in that case, this method or class shouldn't be used when we know the current class has a valid main.
Comment 5 Sarika Sinha CLA 2018-10-06 12:59:43 EDT
(In reply to Mickael Istria from comment #4)
> (In reply to Sarika Sinha from comment #3)
> > Java doc says -
> >          * Searches for all main methods in the given scope.
> 
> Ok, so in that case, this method or class shouldn't be used when we know the
> current class has a valid main.

Want to contribute and add some tests ?
Comment 6 Mickael Istria CLA 2018-10-09 06:56:10 EDT
(In reply to Sarika Sinha from comment #5)
> Want to contribute and add some tests ?

Maybe some time later. I already have too many more important patches waiting for review on JDT before I can consider adding noise there.
Comment 7 Eclipse Genie CLA 2020-10-13 15:22:51 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 8 Eclipse Genie CLA 2022-10-13 00:46:21 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.