Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 289490

Summary: Type hierarchy for anonymous binary type - varying behaviors
Product: [Eclipse Project] JDT Reporter: Stephan Herrmann <stephan.herrmann>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 3.5   
Target Milestone: ---   
Hardware: Other   
OS: All   
Whiteboard: stalebug

Description Stephan Herrmann CLA 2009-09-15 12:14:00 EDT
(follow up from bug 284131 comment 8)

Given two projects: Src and Bin.
Src contains this class:

public class Test {
	class MyRunnable<T> {
		/** Doc of my uber run method. */
		public void run(T arg) { } 
	}
	void enclosingMethod(final int i) {
		new MyRunnable<Integer>() {
			/** The run implementation. */
			public void run(Integer j) {
				System.out.println(j);
			}
		}.run(3);
	}
}

Project Bin only contains a jar file compiled from p1.Test (incl. sources),
jar is on Bin's build path.

Excercise is to inspect the type hierarchy for the anonymous type
within enclosingMethod (selecting type name in the allocation expr
and hitting F4).

Two "features" appear/disappear according to some internal state:

(I) Hierarchy may or may not show duplicate types "MyRunnable<T>". To enable
this "feature" open both files (src and bin) in editors and select the binary
version and hit F4. To disable, close project "Src" and re-create hierarchy.
Actually, this feature is not related to anonymous types, works for any type.
What's confusing: if the src version is not open in an editor, but project
is open, it will not appear in the hierarchy.

(II) Hiearchy may or may not show the anonymous type.
Initially the anonymous type is not shown (sometimes?), after requesting 
the type hierarchy for method run() of the anonymous type, hierarchy will
"know" about the anonymous type and also show it in subsequent requests.
Unfortunately, after the anonymous type has been shown once, I see no
way to make it disappear again (incl. deleting indexes and wb restart),
so this may be difficult to track down. Right now, e.g., I get a missing
anonymous type only if Test is in the default package (!).

It seems that the anonymous type is never the focus type of the hierarchy.
This corresponds to the behaviour that the type name is interpreted
as a type reference, not a declaration (F2 shows super type doc, F3 jumps
to super type), so selecting the anonymous type is only possible by
selecting one of its methods. Is this by design?

Even with duplicate super types "MyRunnable<T>" the anonymous type will
show at most once.

With only the Src project open, the anonymous type is always there.
Comment 1 Stephan Herrmann CLA 2011-04-19 14:14:54 EDT
I just re-checked with HEAD and all can still be reproduced.
Comment 2 Eclipse Genie CLA 2020-03-11 13:58:45 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.