Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 56796 Details for
Bug 168331
[1.5][compiler] AbstractMethodError on interface method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix + test cases - improved
org.eclipse.jdt.core_03.txt (text/plain), 11.71 KB, created by
Maxime Daniel
on 2007-01-11 15:12:39 EST
(
hide
)
Description:
Fix + test cases - improved
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2007-01-11 15:12:39 EST
Size:
11.71 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java,v >retrieving revision 1.18 >diff -u -r1.18 InnerEmulationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java 11 Jan 2007 08:52:58 -0000 1.18 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java 11 Jan 2007 15:08:49 -0000 >@@ -5347,7 +5347,7 @@ > "----------\n"); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=168331 >-public void _test133() { >+public void test133() { > if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) { > this.runConformTest( > new String[] { >@@ -5382,7 +5382,7 @@ > } > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=168331 >-public void _test134() { >+public void test134() { > if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) { > this.runConformTest( > new String[] { >Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v >retrieving revision 1.108 >diff -u -r1.108 MethodVerifyTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 21 Dec 2006 19:41:39 -0000 1.108 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 11 Jan 2007 15:09:05 -0000 >@@ -708,14 +708,19 @@ > "abstract class X2 extends A implements J {}\n" > }, > "----------\n" + >- "1. ERROR in A.java (at line 2)\r\n" + >- " interface I extends J { Object foo(); }\r\n" + >+ "1. ERROR in A.java (at line 1)\n" + >+ " abstract class A implements I {}\n" + >+ " ^\n" + >+ "The return type is incompatible with J.foo(), I.foo()\n" + >+ "----------\n" + >+ "2. ERROR in A.java (at line 2)\n" + >+ " interface I extends J { Object foo(); }\n" + > " ^^^^^^\n" + > "The return type is incompatible with J.foo()\n" + > "----------\n" + > "----------\n" + >- "1. ERROR in X.java (at line 1)\r\n" + >- " abstract class X2 extends A implements J {}\r\n" + >+ "1. ERROR in X.java (at line 1)\n" + >+ " abstract class X2 extends A implements J {}\n" + > " ^^\n" + > "The return type is incompatible with I.foo(), J.foo()\n" + > "----------\n" >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v >retrieving revision 1.581 >diff -u -r1.581 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 10 Jan 2007 16:23:50 -0000 1.581 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 11 Jan 2007 15:08:41 -0000 >@@ -31465,22 +31465,32 @@ > }, > "S100MyClass = [Terry]MyClass = [Corbet]SUCCESS"); > } >-//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140643 >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=140643 > public void test0987() { > String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 > ? "----------\n" + >- "1. ERROR in X.java (at line 11)\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "The return type is incompatible with EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 11)\n" + > " public ISheetViewer getViewer() { return null; } \n" + > " ^^^^^^^^^^^^\n" + > "The return type is incompatible with EditPart.getViewer()\n" + > "----------\n" + >- "2. ERROR in X.java (at line 11)\n" + >+ "3. ERROR in X.java (at line 11)\n" + > " public ISheetViewer getViewer() { return null; } \n" + > " ^^^^^^^^^^^\n" + > "The method getViewer() of type AbstractLinkView<M> must override a superclass method\n" + > "----------\n" > : "----------\n" + >- "1. ERROR in X.java (at line 11)\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "The return type is incompatible with EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 11)\n" + > " public ISheetViewer getViewer() { return null; } \n" + > " ^^^^^^^^^^^^\n" + > "The return type is incompatible with EditPart.getViewer()\n" + >@@ -31521,7 +31531,7 @@ > }, > expectedOutput); > } >-//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140643 - variation >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=140643 - variation > public void test0988() { > this.runNegativeTest( > new String[] { >@@ -31572,7 +31582,7 @@ > "1. ERROR in X.java (at line 7)\n" + > " abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" + > " ^^^^^^^^^^^^^^^^\n" + >- "The return type is incompatible with AbstractEditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" + >+ "The return type is incompatible with ILinkViewElement.getViewer(), AbstractEditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" + > "----------\n" + > "2. ERROR in X.java (at line 11)\n" + > " public SheetViewer getViewer() { return null; } \n" + >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java,v >retrieving revision 1.34 >diff -u -r1.34 AmbiguousMethodTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 4 Dec 2006 09:06:28 -0000 1.34 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 11 Jan 2007 15:07:26 -0000 >@@ -1457,7 +1457,7 @@ > ""); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=162073 >-public void _test032() { >+public void test032() { > this.runConformTest( > new String[] { > "X.java", >@@ -1474,7 +1474,28 @@ > ""); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=162073 >-// variant that passes >+// variant that shows that the use of a substitution is needed during the bounds >+// check >+public void test032a() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class Z { }\n" + >+ "class Y <U> extends Z { }" + >+ "interface I {\n" + >+ " <T extends Y<T> & Cloneable> T foo(Number n);\n" + >+ "}\n" + >+ "interface J extends I {\n" + >+ " XX foo(Number n);\n" + >+ "}\n" + >+ "public abstract class X implements J {\n" + >+ "}\n" + >+ "abstract class XX extends Y<XX> implements Cloneable {}" >+ }, >+ ""); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=162073 >+// variant > public void test033() { > this.runConformTest( > new String[] { >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v >retrieving revision 1.64 >diff -u -r1.64 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 21 Dec 2006 19:22:05 -0000 1.64 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 11 Jan 2007 15:09:11 -0000 >@@ -313,9 +313,67 @@ > > super.checkInheritedMethods(methods, length); > } >+class OneOneSubstitution implements Substitution { >+ TypeBinding replaced, replacer; >+ OneOneSubstitution(TypeBinding replaced, TypeBinding replacer) { >+ this.replaced = replaced; >+ this.replacer = replacer; >+ } >+ public LookupEnvironment environment() { >+ return environment; >+ } >+ public boolean isRawSubstitution() { >+ return false; >+ } >+ public TypeBinding substitute(TypeVariableBinding typeVariable) { >+ return typeVariable == replaced ? replacer : typeVariable; >+ } >+} > boolean checkInheritedReturnTypes(MethodBinding[] methods, int length) { > if (methods[0].declaringClass.isClass()) > return super.checkInheritedReturnTypes(methods, length); >+ if (length <= 1) { >+ return true; // no need to continue since only 1 inherited method is left >+ } >+ // get rid of overriden methods coming from interfaces - if any >+ MethodBinding methodsToCheck[] = new MethodBinding[length]; // must not nullify methods slots in place >+ int count = length; >+ for (int i = 0; i < length; i++) { >+ methodsToCheck[i] = methods[i]; >+ } >+ MethodBinding existingMethod, inheritedMethod, substitute; >+ for (int i = 0; i < length; i++) { >+ if ((existingMethod = methodsToCheck[i]) != null) { >+ for (int j = 0; j < length; j++) { >+ if (i != j && (inheritedMethod = methodsToCheck[j]) != null && >+ existingMethod.declaringClass.implementsInterface(inheritedMethod.declaringClass, true)) { >+ substitute = computeSubstituteMethod(inheritedMethod, existingMethod); >+ if (substitute != null && doesSubstituteMethodOverride(existingMethod, substitute) && >+ (existingMethod.returnType.isCompatibleWith(substitute.returnType) || >+ substitute.returnType instanceof TypeVariableBinding && >+ ((TypeVariableBinding) substitute.returnType). >+ boundCheck( >+ new OneOneSubstitution(substitute.returnType, existingMethod.returnType), >+ existingMethod.returnType) == TypeConstants.OK)) { >+ count--; >+ methodsToCheck[j] = null; >+ } >+ } >+ } >+ } >+ } >+ if (count < length) { >+ if (count == 1) { >+ return true; // no need to continue since only 1 inherited method is left >+ } >+ for (int i = 0, j = 0; j < count; i++) { >+ if (methodsToCheck[i] != null) { >+ methodsToCheck[j++] = methodsToCheck[i]; >+ } >+ } >+ methods = methodsToCheck; >+ length = count; >+ } // else keep methods unchanged for further checks > > // its possible in 1.5 that A is compatible with B & C, but B is not compatible with C > for (int i = 0, l = length - 1; i < l;) { >@@ -552,14 +610,15 @@ > // one has type variables and substituteTwo did not pass bounds check in computeSubstituteMethod() > return one.typeVariables != Binding.NO_TYPE_VARIABLES && !(substituteTwo instanceof ParameterizedGenericMethodBinding); > } >+// caveat: returns false if a method is implemented but needs that a bridge >+// method be generated > boolean isInterfaceMethodImplemented(MethodBinding inheritedMethod, MethodBinding existingMethod, ReferenceBinding superType) { > if (inheritedMethod.original() != inheritedMethod && existingMethod.declaringClass.isInterface()) > return false; // must hold onto ParameterizedMethod to see if a bridge method is necessary > > inheritedMethod = computeSubstituteMethod(inheritedMethod, existingMethod); > return inheritedMethod != null >- && (inheritedMethod.returnType == existingMethod.returnType || >- inheritedMethod.returnType.isCompatibleWith(inheritedMethod.returnType)) >+ && inheritedMethod.returnType == existingMethod.returnType > && super.isInterfaceMethodImplemented(inheritedMethod, existingMethod, superType); > } > SimpleSet findSuperinterfaceCollisions(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 168331
:
56701
|
56796
|
56896