| Summary: | IMethodBinding#getJavaElement returns wrong IMethod in case of equally named constructor | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Andreas Thies <andreas.thies> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | minor | ||
| Priority: | P3 | CC: | jarthana |
| Version: | 4.3 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | stalebug | ||
Just a note that the JDT team is short on resources and focused on the Java 8 effort. It's unlikely that we will get to this soon. In case anyone is interested in coming up with a patch, you are welcome to post a patch. 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. |
Create AST for the program package a; public class A { public A() { } void A() { } } and use an ASTVisitor to find the MethodDeclaration node for the method "void A()". methodDeclaration.isConstructor() -> returns false methodDeclaration.resolveBinding().isConstructor() -> returns false ((IMethod) methodDeclaration.resolveBinding().getJavaElement()).isConstructor() -> returns true There seems to be a bug within IMethodBinding#getJavaElement, since it returns the equally named constructor instead of the method. You can also reproduce this bug through the UI. If you have a method call to "void A()" and you ctrl+click the method name, you are redirected to the constructor insted of the bound method. Since this bug is quite artificial (methods in Java should start with a lower case letter) I marked it as a minor bug.