| Summary: | IMethodBinding#getJavaElement() returns incorrect result in case of method overloading and type shadowing | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Andreas Thies <andreas.thies> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | Olivier_Thomann |
| Version: | 3.7 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
*** This bug has been marked as a duplicate of bug 275853 *** |
Build Identifier: M20100909-0800 In case of two methods with same name and equally named (but different) parameter types IMethodBinding#getJavaElement returns incorrectly the same IJavaElement for both methods. Reproducible: Always Steps to Reproduce: 1. Create a java project with the following classes: package a; public class A {} package b; public class A {} package y; import b.A; public class Y { public void m(a.A a) {} public void m(A a) {} } 2. Run the following code within an eclipse plugin ICompilationUnit icu = (ICompilationUnit) JavaCore.create("=TestProject/src<y{Y.java"); ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setSource(icu); parser.setResolveBindings(true); CompilationUnit cu = (CompilationUnit) parser.createAST(null); final List<MethodDeclaration> mds = new ArrayList<MethodDeclaration>(2); cu.accept(new ASTVisitor() { @Override public boolean visit(MethodDeclaration methodDeclaration) { mds.add(methodDeclaration); return super.visit(methodDeclaration); } }); MethodDeclaration md1 = mds.get(0); MethodDeclaration md2 = mds.get(1); IMethodBinding binding1 = md1.resolveBinding(); IMethodBinding binding2 = md2.resolveBinding(); IJavaElement javaElement1 = binding1.getJavaElement(); IJavaElement javaElement2 = binding2.getJavaElement(); System.out.println(md1.equals(md2)); // false System.out.println(binding1.equals(binding2)); // false // should be false, but is true System.out.println(javaElement1.equals(javaElement2)); // is =TestProject/src<y{B.java[B~m~Qa.A; System.out.println(javaElement1.getHandleIdentifier()); // =TestProject/src<y{B.java[B~m~Qa.A; // is =TestProject/src<y{B.java[B~m~Qa.A; but should be =TestProject/src<y{Y.java[Y~m~QA; System.out.println(javaElement2.getHandleIdentifier()); // =TestProject/src<y{B.java[B~m~Qa.A;