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 52296 Details for
Bug 141931
[1.5][compiler] @Override: upcoming changes of the reference implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
141931.txt (text/plain), 43.28 KB, created by
Philipe Mulet
on 2006-10-19 04:15:55 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2006-10-19 04:15:55 EDT
Size:
43.28 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v >retrieving revision 1.181 >diff -u -r1.181 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 18 Oct 2006 19:09:55 -0000 1.181 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 19 Oct 2006 08:12:38 -0000 >@@ -95,6 +95,7 @@ > * IBM Corporation - added the following constants > * AnnotationValueMustBeAnEnumConstant > * OverridingMethodWithoutSuperInvocation >+ * MethodMustOverrideOrImplement > *******************************************************************************/ > package org.eclipse.jdt.core.compiler; > >@@ -1121,6 +1122,8 @@ > int AnnotationValueMustBeArrayInitializer = Internal + 632; > /** @since 3.3 */ > int AnnotationValueMustBeAnEnumConstant = Internal + 633; >+ /** @since 3.3 */ >+ int MethodMustOverrideOrImplement = MethodRelated + 634; > > /** > * Corrupted binaries >Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v >retrieving revision 1.210 >diff -u -r1.210 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 18 Oct 2006 19:09:56 -0000 1.210 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 19 Oct 2006 08:12:42 -0000 >@@ -526,6 +526,7 @@ > 631 = Unhandled warning token {0} > 632 = The value for annotation attribute {0}.{1} must be an array initializer > 633 = The value for annotation attribute {0}.{1} must be an enum constant expression >+634 = The method {0}({1}) of type {2} must override or implement a supertype method > > ### CORRUPTED BINARIES > 700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2} >@@ -570,4 +571,3 @@ > 857 = Incorrect number of type arguments for generic constructor <{3}>{0}({1}) of type {2}; it cannot be parameterized with arguments <{4}> > 858 = The parameterized constructor <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4}) > 859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}> >- >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.324 >diff -u -r1.324 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 18 Oct 2006 19:09:56 -0000 1.324 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 19 Oct 2006 08:12:42 -0000 >@@ -272,6 +272,7 @@ > > case IProblem.FallthroughCase: > return CompilerOptions.FallthroughCase; >+ > case IProblem.OverridingMethodWithoutSuperInvocation: > return CompilerOptions.OverridingMethodWithoutSuperInvocation; > } >@@ -4343,7 +4344,7 @@ > public void methodMustOverride(AbstractMethodDeclaration method) { > MethodBinding binding = method.binding; > this.handle( >- IProblem.MethodMustOverride, >+ this.options.sourceLevel == ClassFileConstants.JDK1_5 ? IProblem.MethodMustOverride : IProblem.MethodMustOverrideOrImplement, > new String[] {new String(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, false), new String(binding.declaringClass.readableName()), }, > new String[] {new String(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, true), new String(binding.declaringClass.shortReadableName()),}, > method.sourceStart, >Index: compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java,v >retrieving revision 1.57 >diff -u -r1.57 MethodDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 18 Oct 2006 19:09:55 -0000 1.57 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 19 Oct 2006 08:12:38 -0000 >@@ -151,20 +151,29 @@ > final CompilerOptions compilerOptions = this.scope.compilerOptions(); > checkOverride: { > if (this.binding == null) break checkOverride; >- if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5) break checkOverride; >+ long sourceLevel = compilerOptions.sourceLevel; >+ if (sourceLevel < ClassFileConstants.JDK1_5) break checkOverride; > int bindingModifiers = this.binding.modifiers; > boolean hasOverrideAnnotation = (this.binding.tagBits & TagBits.AnnotationOverride) != 0; > boolean isInterfaceMethod = this.binding.declaringClass.isInterface(); > if (hasOverrideAnnotation) { >- if ((bindingModifiers & ExtraCompilerModifiers.AccOverriding) == 0 || isInterfaceMethod || this.binding.isStatic()) >- // claims to override, and doesn't actually do so >- this.scope.problemReporter().methodMustOverride(this); >- } else if (!isInterfaceMethod && (bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccOverriding)) == ExtraCompilerModifiers.AccOverriding) { >+ // no static method is considered overriding >+ if (!isInterfaceMethod && (bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccOverriding)) == ExtraCompilerModifiers.AccOverriding) >+ break checkOverride; >+ // in 1.5, strictly for overriding superclass method >+ // in 1.6 and above, also tolerate implementing interface method >+ if (sourceLevel >= ClassFileConstants.JDK1_6 >+ && ((bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccImplementing)) == ExtraCompilerModifiers.AccImplementing)) >+ break checkOverride; >+ // claims to override, and doesn't actually do so >+ this.scope.problemReporter().methodMustOverride(this); >+ } else if (!isInterfaceMethod >+ && (bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccOverriding)) == ExtraCompilerModifiers.AccOverriding) { > // actually overrides, but did not claim to do so > this.scope.problemReporter().missingOverrideAnnotation(this); > } > } >- >+ > // by grammatical construction, interface methods are always abstract > switch (TypeDeclaration.kind(this.scope.referenceType().modifiers)) { > case TypeDeclaration.ENUM_DECL : >#P org.eclipse.jdt.core.tests.compiler >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.102 >diff -u -r1.102 MethodVerifyTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 18 Oct 2006 19:09:41 -0000 1.102 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 19 Oct 2006 08:13:04 -0000 >@@ -22,6 +22,7 @@ > import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; > import org.eclipse.jdt.core.util.IClassFileReader; > import org.eclipse.jdt.core.util.IMethodInfo; >+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > > public class MethodVerifyTest extends AbstractComparableTest { >@@ -4381,33 +4382,8 @@ > > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=99106 > public void test062() { >- this.runNegativeTest( >- new String[] { >- "Errors.java", >- "public class Errors {\n" + >- " void foo() {\n" + >- " Ex<String> ex = new Ex<String>();\n" + >- " ex.proof(\"eclipse\");\n" + >- " ex.five(\"eclipse\");\n" + >- " ex.six(\"eclipse\");\n" + >- " Ex ex2 = ex;\n" + >- " ex2.proof(\"eclipse\");\n" + >- " ex2.five(\"eclipse\");\n" + >- " ex2.six(\"eclipse\");\n" + >- " }\n" + >- "}\n" + >- "class Top<TC> {\n" + >- " <TM> void proof(Object cTop) {}\n" + >- " <TM> void five(TC cTop) {}\n" + >- " void six(TC cTop) {}\n" + >- "}\n" + >- "class Ex<C> extends Top<C> {\n" + >- " @Override void proof(Object cTop) {}\n" + >- " @Override void five(C cEx) {}\n" + >- " @Override <M> void six(C cEx) {}\n" + >- "}" >- }, >- "----------\n" + >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + > "1. ERROR in Errors.java (at line 6)\n" + > " ex.six(\"eclipse\");\n" + > " ^^^\n" + >@@ -4438,6 +4414,64 @@ > " ^^^^^^^^^^\n" + > "The method six(C) of type Ex<C> must override a superclass method\n" + > "----------\n" >+ : "----------\n" + >+ "1. ERROR in Errors.java (at line 6)\n" + >+ " ex.six(\"eclipse\");\n" + >+ " ^^^\n" + >+ "The method six(String) is ambiguous for the type Ex<String>\n" + >+ "----------\n" + >+ "2. WARNING in Errors.java (at line 7)\n" + >+ " Ex ex2 = ex;\n" + >+ " ^^\n" + >+ "Ex is a raw type. References to generic type Ex<C> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in Errors.java (at line 9)\n" + >+ " ex2.five(\"eclipse\");\n" + >+ " ^^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method five(Object) belongs to the raw type Ex. References to generic type Ex<C> should be parameterized\n" + >+ "----------\n" + >+ "4. ERROR in Errors.java (at line 10)\n" + >+ " ex2.six(\"eclipse\");\n" + >+ " ^^^\n" + >+ "The method six(Object) is ambiguous for the type Ex\n" + >+ "----------\n" + >+ "5. ERROR in Errors.java (at line 21)\n" + >+ " @Override <M> void six(C cEx) {}\n" + >+ " ^^^^^^^^^^\n" + >+ "Name clash: The method six(C) of type Ex<C> has the same erasure as six(TC) of type Top<TC> but does not override it\n" + >+ "----------\n" + >+ "6. ERROR in Errors.java (at line 21)\n" + >+ " @Override <M> void six(C cEx) {}\n" + >+ " ^^^^^^^^^^\n" + >+ "The method six(C) of type Ex<C> must override or implement a supertype method\n" + >+ "----------\n"; >+ this.runNegativeTest( >+ new String[] { >+ "Errors.java", >+ "public class Errors {\n" + >+ " void foo() {\n" + >+ " Ex<String> ex = new Ex<String>();\n" + >+ " ex.proof(\"eclipse\");\n" + >+ " ex.five(\"eclipse\");\n" + >+ " ex.six(\"eclipse\");\n" + >+ " Ex ex2 = ex;\n" + >+ " ex2.proof(\"eclipse\");\n" + >+ " ex2.five(\"eclipse\");\n" + >+ " ex2.six(\"eclipse\");\n" + >+ " }\n" + >+ "}\n" + >+ "class Top<TC> {\n" + >+ " <TM> void proof(Object cTop) {}\n" + >+ " <TM> void five(TC cTop) {}\n" + >+ " void six(TC cTop) {}\n" + >+ "}\n" + >+ "class Ex<C> extends Top<C> {\n" + >+ " @Override void proof(Object cTop) {}\n" + >+ " @Override void five(C cEx) {}\n" + >+ " @Override <M> void six(C cEx) {}\n" + >+ "}" >+ }, >+ expectedOutput > // we disagree about the ambiguous errors on lines 5, 9 & 20, see the message sends to proof() > // 5: reference to five is ambiguous, both method <TM>five(TC) in Top<java.lang.String> and method five(C) in Ex<java.lang.String> match > // 6: reference to six is ambiguous, both method six(TC) in Top<java.lang.String> and method <M>six(C) in Ex<java.lang.String> match >@@ -4665,17 +4699,8 @@ > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=107045 > public void test071() { >- this.runNegativeTest( >- new String[] { >- "D.java", >- "class D extends B<Integer> {\n" + >- " @Override void m(Number t) {}\n" + >- " @Override void m(Integer t) {}\n" + >- "}\n" + >- "class A<T extends Number> { void m(T t) {} }\n" + >- "class B<S extends Integer> extends A<S> { @Override void m(S t) {} }" >- }, >- "----------\n" + >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + > "1. ERROR in D.java (at line 2)\r\n" + > " @Override void m(Number t) {}\r\n" + > " ^^^^^^^^^^^\n" + >@@ -4691,7 +4716,33 @@ > " ^^^^^^^\n" + > "The type parameter S should not be bounded by the final type Integer. Final types cannot be further extended\n" + > "----------\n" >- ); >+ : "----------\n" + >+ "1. ERROR in D.java (at line 2)\n" + >+ " @Override void m(Number t) {}\n" + >+ " ^^^^^^^^^^^\n" + >+ "Name clash: The method m(Number) of type D has the same erasure as m(T) of type A<T> but does not override it\n" + >+ "----------\n" + >+ "2. ERROR in D.java (at line 2)\n" + >+ " @Override void m(Number t) {}\n" + >+ " ^^^^^^^^^^^\n" + >+ "The method m(Number) of type D must override or implement a supertype method\n" + >+ "----------\n" + >+ "3. WARNING in D.java (at line 6)\n" + >+ " class B<S extends Integer> extends A<S> { @Override void m(S t) {} }\n" + >+ " ^^^^^^^\n" + >+ "The type parameter S should not be bounded by the final type Integer. Final types cannot be further extended\n" + >+ "----------\n"; >+ this.runNegativeTest( >+ new String[] { >+ "D.java", >+ "class D extends B<Integer> {\n" + >+ " @Override void m(Number t) {}\n" + >+ " @Override void m(Integer t) {}\n" + >+ "}\n" + >+ "class A<T extends Number> { void m(T t) {} }\n" + >+ "class B<S extends Integer> extends A<S> { @Override void m(S t) {} }" >+ }, >+ expectedOutput); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=108780 > public void test072() { >@@ -4756,6 +4807,19 @@ > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=111350 > public void test073c() { >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. ERROR in NumericArray4.java (at line 5)\r\n" + >+ " @Override public <U> void add(Number n) {}\r\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "The method add(Number) of type NumericArray4<T> must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. ERROR in NumericArray4.java (at line 5)\n" + >+ " @Override public <U> void add(Number n) {}\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "The method add(Number) of type NumericArray4<T> must override or implement a supertype method\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "NumericArray4.java", >@@ -4766,16 +4830,23 @@ > " @Override public <U> void add(Number n) {}\n" + > "}" > }, >- "----------\n" + >- "1. ERROR in NumericArray4.java (at line 5)\r\n" + >- " @Override public <U> void add(Number n) {}\r\n" + >- " ^^^^^^^^^^^^^\n" + >- "The method add(Number) of type NumericArray4<T> must override a superclass method\n" + >- "----------\n" >- ); >+ expectedOutput); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=111350 > public void test073d() { >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. ERROR in NumericArray5.java (at line 5)\r\n" + >+ " @Override public void add(Number n, Integer i) {}\r\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "The method add(Number, Integer) of type NumericArray5<T> must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. ERROR in NumericArray5.java (at line 5)\n" + >+ " @Override public void add(Number n, Integer i) {}\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "The method add(Number, Integer) of type NumericArray5<T> must override or implement a supertype method\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "NumericArray5.java", >@@ -4786,23 +4857,12 @@ > " @Override public void add(Number n, Integer i) {}\n" + > "}" > }, >- "----------\n" + >- "1. ERROR in NumericArray5.java (at line 5)\r\n" + >- " @Override public void add(Number n, Integer i) {}\r\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "The method add(Number, Integer) of type NumericArray5<T> must override a superclass method\n" + >- "----------\n" >- ); >+ expectedOutput); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=100970 > public void test074() { >- this.runNegativeTest( >- new String[] { >- "I.java", >- "interface I {}\n" + >- "interface J extends I { @Override void clone(); }" >- }, >- "----------\n" + >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + > "1. WARNING in I.java (at line 2)\n" + > " interface J extends I { @Override void clone(); }\n" + > " ^^^^^^^\n" + >@@ -4813,17 +4873,29 @@ > " ^^^^^^^\n" + > "The method clone() of type J must override a superclass method\n" + > "----------\n" >- ); >- } >- //https://bugs.eclipse.org/bugs/show_bug.cgi?id=100970 >- public void test074a() { >+ : "----------\n" + >+ "1. WARNING in I.java (at line 2)\n" + >+ " interface J extends I { @Override void clone(); }\n" + >+ " ^^^^^^^\n" + >+ "The return type is incompatible with Object.clone(), thus this interface cannot be implemented\n" + >+ "----------\n" + >+ "2. ERROR in I.java (at line 2)\n" + >+ " interface J extends I { @Override void clone(); }\n" + >+ " ^^^^^^^\n" + >+ "The method clone() of type J must override or implement a supertype method\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "I.java", >- "interface I { @Override void clone(); }\n" + >- "interface J extends I {}" >+ "interface I {}\n" + >+ "interface J extends I { @Override void clone(); }" > }, >- "----------\n" + >+ expectedOutput); >+ } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=100970 >+ public void test074a() { >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + > "1. WARNING in I.java (at line 1)\n" + > " interface I { @Override void clone(); }\n" + > " ^^^^^^^\n" + >@@ -4834,7 +4906,24 @@ > " ^^^^^^^\n" + > "The method clone() of type I must override a superclass method\n" + > "----------\n" >- ); >+ : "----------\n" + >+ "1. WARNING in I.java (at line 1)\n" + >+ " interface I { @Override void clone(); }\n" + >+ " ^^^^^^^\n" + >+ "The return type is incompatible with Object.clone(), thus this interface cannot be implemented\n" + >+ "----------\n" + >+ "2. ERROR in I.java (at line 1)\n" + >+ " interface I { @Override void clone(); }\n" + >+ " ^^^^^^^\n" + >+ "The method clone() of type I must override or implement a supertype method\n" + >+ "----------\n"; >+ this.runNegativeTest( >+ new String[] { >+ "I.java", >+ "interface I { @Override void clone(); }\n" + >+ "interface J extends I {}" >+ }, >+ expectedOutput); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=100970 > public void test074b() { >@@ -4873,6 +4962,59 @@ > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=107105 > public void test075() { >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. ERROR in A.java (at line 2)\n" + >+ " class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + >+ " ^^^^^\n" + >+ "Name clash: The method foo() of type B has the same erasure as foo() of type A but does not override it\n" + >+ "----------\n" + >+ "2. ERROR in A.java (at line 2)\n" + >+ " class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + >+ " ^^^^^\n" + >+ "The method foo() of type B must override a superclass method\n" + >+ "----------\n" + >+ "3. WARNING in A.java (at line 3)\n" + >+ " class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + >+ " ^\n" + >+ "I is a raw type. References to generic type I<TT> should be parameterized\n" + >+ "----------\n" + >+ "4. ERROR in A.java (at line 3)\n" + >+ " class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + >+ " ^^^^^\n" + >+ "Name clash: The method foo() of type C has the same erasure as foo() of type A but does not override it\n" + >+ "----------\n" + >+ "5. ERROR in A.java (at line 3)\n" + >+ " class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + >+ " ^^^^^\n" + >+ "The method foo() of type C must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. ERROR in A.java (at line 2)\n" + >+ " class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + >+ " ^^^^^\n" + >+ "Name clash: The method foo() of type B has the same erasure as foo() of type A but does not override it\n" + >+ "----------\n" + >+ "2. ERROR in A.java (at line 2)\n" + >+ " class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + >+ " ^^^^^\n" + >+ "The method foo() of type B must override or implement a supertype method\n" + >+ "----------\n" + >+ "3. WARNING in A.java (at line 3)\n" + >+ " class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + >+ " ^\n" + >+ "I is a raw type. References to generic type I<TT> should be parameterized\n" + >+ "----------\n" + >+ "4. ERROR in A.java (at line 3)\n" + >+ " class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + >+ " ^^^^^\n" + >+ "Name clash: The method foo() of type C has the same erasure as foo() of type A but does not override it\n" + >+ "----------\n" + >+ "5. ERROR in A.java (at line 3)\n" + >+ " class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + >+ " ^^^^^\n" + >+ "The method foo() of type C must override or implement a supertype method\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "A.java", >@@ -4884,32 +5026,7 @@ > "interface I<TT> {}\n" + > "interface J {}" > }, >- "----------\n" + >- "1. ERROR in A.java (at line 2)\n" + >- " class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + >- " ^^^^^\n" + >- "Name clash: The method foo() of type B has the same erasure as foo() of type A but does not override it\n" + >- "----------\n" + >- "2. ERROR in A.java (at line 2)\n" + >- " class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + >- " ^^^^^\n" + >- "The method foo() of type B must override a superclass method\n" + >- "----------\n" + >- "3. WARNING in A.java (at line 3)\n" + >- " class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + >- " ^\n" + >- "I is a raw type. References to generic type I<TT> should be parameterized\n" + >- "----------\n" + >- "4. ERROR in A.java (at line 3)\n" + >- " class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + >- " ^^^^^\n" + >- "Name clash: The method foo() of type C has the same erasure as foo() of type A but does not override it\n" + >- "----------\n" + >- "5. ERROR in A.java (at line 3)\n" + >- " class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + >- " ^^^^^\n" + >- "The method foo() of type C must override a superclass method\n" + >- "----------\n" >+ expectedOutput > // A.java:2: method does not override a method from its superclass > // A.java:3: method does not override a method from its superclass > ); >@@ -4930,6 +5047,19 @@ > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=107105 > public void test075b() { >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. ERROR in A.java (at line 2)\r\n" + >+ " class B<V> extends A<V> { @Override <T1, S1 extends K & I<T1>> void foo(V v, T1 t, S1 s) { } }\r\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "The method foo(V, T1, S1) of type B<V> must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. ERROR in A.java (at line 2)\n" + >+ " class B<V> extends A<V> { @Override <T1, S1 extends K & I<T1>> void foo(V v, T1 t, S1 s) { } }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "The method foo(V, T1, S1) of type B<V> must override or implement a supertype method\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "A.java", >@@ -4939,12 +5069,7 @@ > "interface J {}\n" + > "interface K extends J {}" > }, >- "----------\n" + >- "1. ERROR in A.java (at line 2)\r\n" + >- " class B<V> extends A<V> { @Override <T1, S1 extends K & I<T1>> void foo(V v, T1 t, S1 s) { } }\r\n" + >- " ^^^^^^^^^^^^^^^^^^^^\n" + >- "The method foo(V, T1, S1) of type B<V> must override a superclass method\n" + >- "----------\n" >+ expectedOutput > // A.java:2: method does not override a method from its superclass > ); > } >@@ -7069,42 +7194,52 @@ > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736 > public void test116() { >- if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) { >- Map options = this.getCompilerOptions(); >- options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR); >- this.runNegativeTest( >- new String[] { >- "X.java", >- "class Y {\n" + >- " Zork foo() {}\n" + >- "}\n" + >- "public class X extends Y {\n" + >- " @Override\n" + >- " Object foo() {\n" + >- " return new Y() {\n" + >- " Object foo() {\n" + >- " return null;\n" + >- " }\n" + >- " };" + >- " }\n" + >- "}" >- }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " Zork foo() {}\n" + >- " ^^^^\n" + >- "Zork cannot be resolved to a type\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 6)\n" + >- " Object foo() {\n" + >- " ^^^^^\n" + >- "The method foo() of type X must override a superclass method\n" + >- "----------\n", >- null, >- true, >- options >- ); >- } >+ Map options = this.getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR); >+ String expectedOutput = new CompilerOptions(options).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " Zork foo() {}\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 6)\n" + >+ " Object foo() {\n" + >+ " ^^^^^\n" + >+ "The method foo() of type X must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " Zork foo() {}\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 6)\n" + >+ " Object foo() {\n" + >+ " ^^^^^\n" + >+ "The method foo() of type X must override or implement a supertype method\n" + >+ "----------\n"; >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class Y {\n" + >+ " Zork foo() {}\n" + >+ "}\n" + >+ "public class X extends Y {\n" + >+ " @Override\n" + >+ " Object foo() {\n" + >+ " return new Y() {\n" + >+ " Object foo() {\n" + >+ " return null;\n" + >+ " }\n" + >+ " };" + >+ " }\n" + >+ "}" >+ }, >+ expectedOutput, >+ null, >+ true, >+ options ); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736 > public void test117() { >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.541 >diff -u -r1.541 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 12 Oct 2006 18:16:23 -0000 1.541 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 19 Oct 2006 08:13:01 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; > import org.eclipse.jdt.core.tests.util.Util; > import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; >+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > > public class GenericTypeTest extends AbstractComparableTest { >@@ -32,7 +33,7 @@ > // All specified tests which does not belong to the class are skipped... > static { > // TESTS_NAMES = new String[] { "test0788" }; >- TESTS_NUMBERS = new int[] { 1050, 1054 }; >+// TESTS_NUMBERS = new int[] { 1050, 1054 }; > // TESTS_RANGE = new int[] { 821, -1 }; > } > public static Test suite() { >@@ -31228,6 +31229,34 @@ > } > //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 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" + >+ "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 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"; > this.runNegativeTest( > new String[] { > "X.java",//=================== >@@ -31262,22 +31291,7 @@ > "\n" + > "interface EditPartViewer {}\n", // ================= > }, >- "----------\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" + >- "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"); >+ expectedOutput); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=140643 - variation > public void test0988() { >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v >retrieving revision 1.156 >diff -u -r1.156 AnnotationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 17 Oct 2006 21:22:39 -0000 1.156 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 19 Oct 2006 08:12:46 -0000 >@@ -2437,6 +2437,24 @@ > } > // check @Override annotation - strictly for superclasses (overrides) and not interfaces (implements) > public void test077() { >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. ERROR in X.java (at line 14)\n" + >+ " void foo() {}\n" + >+ " ^^^^^\n" + >+ "The method foo() of type X must override a superclass method\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 18)\n" + >+ " public void baz() {}\n" + >+ " ^^^^^\n" + >+ "The method baz() of type X must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. ERROR in X.java (at line 14)\n" + >+ " void foo() {}\n" + >+ " ^^^^^\n" + >+ "The method foo() of type X must override or implement a supertype method\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -2460,17 +2478,7 @@ > " public void baz() {}\n" + > "}\n" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 14)\n" + >- " void foo() {}\n" + >- " ^^^^^\n" + >- "The method foo() of type X must override a superclass method\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 18)\n" + >- " public void baz() {}\n" + >- " ^^^^^\n" + >- "The method baz() of type X must override a superclass method\n" + >- "----------\n"); >+ expectedOutput); > } > > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=80114 >@@ -4488,6 +4496,19 @@ > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90111 - variation > public void test140() { >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. ERROR in X.java (at line 6)\r\n" + >+ " static void foo(){} \r\n" + >+ " ^^^^^\n" + >+ "The method foo() of type Bar must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " static void foo(){} \n" + >+ " ^^^^^\n" + >+ "The method foo() of type Bar must override or implement a supertype method\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -4500,12 +4521,7 @@ > "}\n" + > "\n" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 6)\r\n" + >- " static void foo(){} \r\n" + >- " ^^^^^\n" + >- "The method foo() of type Bar must override a superclass method\n" + >- "----------\n"); >+ expectedOutput); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94867 > public void test141() { >@@ -5611,7 +5627,25 @@ > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=94759 > public void test168() { >- this.runNegativeTest( >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " @Override I clone();\n" + >+ " ^^^^^^^\n" + >+ "The method clone() of type I must override a superclass method\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 7)\n" + >+ " @Override void foo();\n" + >+ " ^^^^^\n" + >+ "The method foo() of type J must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " @Override I clone();\n" + >+ " ^^^^^^^\n" + >+ "The method clone() of type I must override or implement a supertype method\n" + >+ "----------\n"; >+ this.runNegativeTest( > new String[] { > "X.java", > "interface I {\n" + >@@ -5623,17 +5657,7 @@ > " @Override void foo();\n" + > "}\n", > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " @Override I clone();\n" + >- " ^^^^^^^\n" + >- "The method clone() of type I must override a superclass method\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 7)\n" + >- " @Override void foo();\n" + >- " ^^^^^\n" + >- "The method foo() of type J must override a superclass method\n" + >- "----------\n"); >+ expectedOutput); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=97220 > public void test169() { >@@ -6417,6 +6441,29 @@ > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=130017 > public void test194() { >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " @Override\n" + >+ " ^^^^^^^^^\n" + >+ "The annotation @Override is disallowed for this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 9)\n" + >+ " public static void foo() {}\n" + >+ " ^^^^^\n" + >+ "The method foo() of type X must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " @Override\n" + >+ " ^^^^^^^^^\n" + >+ "The annotation @Override is disallowed for this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 9)\n" + >+ " public static void foo() {}\n" + >+ " ^^^^^\n" + >+ "The method foo() of type X must override or implement a supertype method\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -6431,17 +6478,7 @@ > " public static void foo() {}\n" + > "}\n" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 5)\n" + >- " @Override\n" + >- " ^^^^^^^^^\n" + >- "The annotation @Override is disallowed for this location\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 9)\n" + >- " public static void foo() {}\n" + >- " ^^^^^\n" + >- "The method foo() of type X must override a superclass method\n" + >- "----------\n"); >+ expectedOutput); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=130516 > public void test195() { >@@ -6492,6 +6529,29 @@ > } > // no override between package private methods > public void test197() { >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. WARNING in p\\X.java (at line 4)\n" + >+ " void foo() {\n" + >+ " ^^^^^\n" + >+ "The method X.foo() does not override the inherited method from OldStuff since it is private to a different package\n" + >+ "----------\n" + >+ "2. ERROR in p\\X.java (at line 4)\n" + >+ " void foo() {\n" + >+ " ^^^^^\n" + >+ "The method foo() of type X must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. WARNING in p\\X.java (at line 4)\n" + >+ " void foo() {\n" + >+ " ^^^^^\n" + >+ "The method X.foo() does not override the inherited method from OldStuff since it is private to a different package\n" + >+ "----------\n" + >+ "2. ERROR in p\\X.java (at line 4)\n" + >+ " void foo() {\n" + >+ " ^^^^^\n" + >+ "The method foo() of type X must override or implement a supertype method\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "p/X.java", >@@ -6508,17 +6568,7 @@ > " } \n" + > "}\n", > }, >- "----------\n" + >- "1. WARNING in p\\X.java (at line 4)\n" + >- " void foo() {\n" + >- " ^^^^^\n" + >- "The method X.foo() does not override the inherited method from OldStuff since it is private to a different package\n" + >- "----------\n" + >- "2. ERROR in p\\X.java (at line 4)\n" + >- " void foo() {\n" + >- " ^^^^^\n" + >- "The method foo() of type X must override a superclass method\n" + >- "----------\n"); >+ expectedOutput); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=134129 > public void test198() { >@@ -7005,4 +7055,49 @@ > "The value for annotation attribute MyAnnotation.values must be an array initializer\n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=141931 >+public void test214() { >+ String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 >+ ? "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " void foo();\n" + >+ " ^^^^^\n" + >+ "The method foo() of type I must override a superclass method\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 8)\n" + >+ " public void foo() {}\n" + >+ " ^^^^^\n" + >+ "The method foo() of type X must override a superclass method\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 13)\n" + >+ " void foo();\n" + >+ " ^^^^^\n" + >+ "The method foo() of type J must override a superclass method\n" + >+ "----------\n" >+ : "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " void foo();\n" + >+ " ^^^^^\n" + >+ "The method foo() of type I must override or implement a supertype method\n" + >+ "----------\n"; >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "interface I {\n" + >+ " @Override\n" + >+ " void foo();\n" + >+ " void bar();\n" + >+ "}\n" + >+ "public class X implements I {\n" + >+ " @Override\n" + >+ " public void foo() {}\n" + >+ " public void bar() {}\n" + >+ "}\n" + >+ "interface J extends I {\n" + >+ " @Override\n" + >+ " void foo();\n" + >+ "}\n", >+ }, >+ expectedOutput); >+} > }
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 141931
:
41553
| 52296 |
52323