### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/CompatibilityRulesTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/CompatibilityRulesTests.java,v retrieving revision 1.16 diff -u -r1.16 CompatibilityRulesTests.java --- src/org/eclipse/jdt/core/tests/dom/CompatibilityRulesTests.java 29 Mar 2006 04:03:06 -0000 1.16 +++ src/org/eclipse/jdt/core/tests/dom/CompatibilityRulesTests.java 6 Apr 2006 09:57:36 -0000 @@ -730,4 +730,58 @@ } } + /* + * Ensures that a method in a subtype doesn't override the corresponding private method in the super type. + * (regression test for bug 132191 IMethodBinding.overrides(IMethodBinding) returns true even if the given argument is private.) + */ + public void test033() throws JavaModelException { + IMethodBinding[] bindings = createMethodBindings( + new String[] { + "/P/p1/X.java", + "package p1;\n" + + "public class X {\n" + + " private void foo() {\n" + + " }\n" + + "}", + "/P/p1/Y.java", + "package p1;\n" + + "public class Y extends X {\n" + + " void foo() {\n" + + " }\n" + + "}", + }, + new String[] { + "Lp1/Y;.foo()V", + "Lp1/X;.foo()V" + }); + assertTrue("Y#foo() should not override X#foo()", !bindings[0].overrides(bindings[1])); + } + + /* + * Ensures that a method in a subtype doesn't override the corresponding default method in the super type in a different package. + * (regression test for bug 132191 IMethodBinding.overrides(IMethodBinding) returns true even if the given argument is private.) + */ + public void test034() throws JavaModelException { + IMethodBinding[] bindings = createMethodBindings( + new String[] { + "/P/p1/X.java", + "package p1;\n" + + "public class X {\n" + + " void foo() {\n" + + " }\n" + + "}", + "/P/p2/Y.java", + "package p2;\n" + + "public class Y extends p1.X {\n" + + " void foo() {\n" + + " }\n" + + "}", + }, + new String[] { + "Lp2/Y;.foo()V", + "Lp1/X;.foo()V" + }); + assertTrue("Y#foo() should not override X#foo()", !bindings[0].overrides(bindings[1])); + } + } #P org.eclipse.jdt.core Index: dom/org/eclipse/jdt/core/dom/MethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java,v retrieving revision 1.74 diff -u -r1.74 MethodBinding.java --- dom/org/eclipse/jdt/core/dom/MethodBinding.java 29 Mar 2006 02:54:51 -0000 1.74 +++ dom/org/eclipse/jdt/core/dom/MethodBinding.java 6 Apr 2006 09:57:38 -0000 @@ -443,7 +443,10 @@ LookupEnvironment lookupEnvironment = this.resolver.lookupEnvironment(); if (lookupEnvironment == null) return false; MethodVerifier methodVerifier = lookupEnvironment.methodVerifier(); - return methodVerifier.doesMethodOverride(this.binding, superMethods[i]); + org.eclipse.jdt.internal.compiler.lookup.MethodBinding superMethod = superMethods[i]; + return !superMethod.isPrivate() + && !(superMethod.isDefault() && (superMethod.declaringClass.getPackage()) != this.binding.declaringClass.getPackage()) + && methodVerifier.doesMethodOverride(this.binding, superMethod); } } return false;