| Summary: | Type hierarchy missing entries for method references | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Simeon Andreev <simeon.danailov.andreev> | ||||
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> | ||||
| Status: | CLOSED MOVED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | Lars.Vogel, loskutov, sarika.sinha, stephan.herrmann, Vikas.Chandra | ||||
| Version: | 4.15 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| See Also: |
https://bugs.eclipse.org/bugs/show_bug.cgi?id=468561 https://git.eclipse.org/r/#/c/148364/ https://bugs.eclipse.org/bugs/show_bug.cgi?id=400905 https://bugs.eclipse.org/bugs/show_bug.cgi?id=539602 |
||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
|
Description
Simeon Andreev
Created attachment 281934 [details]
Screenshot showing only 1 hit for the interface, while more exist.
Note that I'm not 100% sure whether the Type Hierarchy view is really at fault here, when I examine DebugCommandAction in more detail. In particular DebugCommandAction does not implement IEnabledTarget, it implements org.eclipse.jface.action.Action.setEnabled(boolean) due to extending Action. Isn't this a violation of type safety, that went past the compiler? Getting the implementers of "org.eclipse.debug.internal.ui.commands.actions.IEnabledTarget.setEnabled(boolean)" with ctrl+click -> "Open Implementation" also yields exactly 1 implementer. (In reply to Simeon Andreev from comment #0) > > private IEnabledTarget fEnabledTarget = DebugCommandAction.this::setEnabled; Changing this to private IEnabledTarget fEnabledTarget = enabled -> setEnabled(enabled); Shows 2 hits for F4. Looking at https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html, I think its expected that the code in DebugCommandAction.fEnabledTarget works as it is now. The given example is basically the same as the code in DebugCommandAction. So this bug should be something missing in the type hierarchy computation. I'm looking at this: " Reference to an Instance Method of a Particular Object The following is an example of a reference to an instance method of a particular object: class ComparisonProvider { public int compareByName(Person a, Person b) { return a.getName().compareTo(b.getName()); } public int compareByAge(Person a, Person b) { return a.getBirthday().compareTo(b.getBirthday()); } } ComparisonProvider myComparisonProvider = new ComparisonProvider(); Arrays.sort(rosterAsArray, myComparisonProvider::compareByName); The method reference myComparisonProvider::compareByName invokes the method compareByName that is part of the object myComparisonProvider. The JRE infers the method type arguments, which in this case are (Person, Person). " (In reply to Simeon Andreev from comment #2) > Note that I'm not 100% sure whether the Type Hierarchy view is really at > fault here, when I examine DebugCommandAction in more detail. > > In particular DebugCommandAction does not implement IEnabledTarget, it > implements org.eclipse.jface.action.Action.setEnabled(boolean) due to > extending Action. Isn't this a violation of type safety, that went past the > compiler? In Bytecode Outline view you can see that a method reference object is created by the compiler, that calls at runtime exact the one setEnabled() method defined by the IEnabledTarget so it is qualified here as a field value. As this thing is synthetically inlined by the compiler *inside* the constructor call, this seem to be invisible for the JDT model. The difference to enabled -> setEnabled(enabled) is that for later, an extra synthetic method is created, which is what probably found by the JDT search. I guess if JDT search would inspect INVOKEDYNAMIC instructions, we might see better matches, but I assume JDT search doesn't work on instruction level. 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. |