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 52323 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]
Backport to 3.2.2 (fix plus test cases)
org.eclipse.jdt.core_01.txt (text/plain), 12.83 KB, created by
Maxime Daniel
on 2006-10-19 12:04:07 EDT
(
hide
)
Description:
Backport to 3.2.2 (fix plus test cases)
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2006-10-19 12:04:07 EDT
Size:
12.83 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >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.494.2.9 >diff -u -r1.494.2.9 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 9 Oct 2006 11:45:31 -0000 1.494.2.9 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 19 Oct 2006 15:52:17 -0000 >@@ -19,6 +19,7 @@ > import org.eclipse.jdt.core.ToolFactory; > 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 { >@@ -31156,6 +31157,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",//=================== >@@ -31190,22 +31219,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.152.2.5 >diff -u -r1.152.2.5 AnnotationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 6 Oct 2006 09:18:16 -0000 1.152.2.5 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 19 Oct 2006 15:51:11 -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 a superclass 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 >@@ -5611,7 +5619,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 a superclass method\n" + >+ "----------\n"; >+ this.runNegativeTest( > new String[] { > "X.java", > "interface I {\n" + >@@ -5623,17 +5649,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() { >@@ -7005,4 +7021,78 @@ > "The array creation is unnecessary in an annotation value; only an array initializer is allowed\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 a superclass 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); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141931 >+// variant >+public void test215() { >+ String sources[] = new String[] { >+ "I.java", >+ "public interface I {\n" + >+ " void foo();\n" + >+ "}\n", >+ "X.java", >+ "abstract class X implements I {\n" + >+ "}\n", >+ "Y.java", >+ "class Y extends X {\n" + >+ " @Override\n" + >+ " public void foo() {}\n" + >+ "}\n"}; >+ if (new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6) { >+ this.runNegativeTest(sources, >+ "----------\n" + >+ "1. ERROR in Y.java (at line 3)\r\n" + >+ " public void foo() {}\r\n" + >+ " ^^^^^\n" + >+ "The method foo() of type Y must override a superclass method\n" + >+ "----------\n"); >+ } else { >+ this.runConformTest(sources, >+ ""); >+ } >+} > } >#P org.eclipse.jdt.core >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.55 >diff -u -r1.55 MethodDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 28 Mar 2006 20:29:56 -0000 1.55 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 19 Oct 2006 15:52:33 -0000 >@@ -17,6 +17,7 @@ > import org.eclipse.jdt.internal.compiler.flow.ExceptionHandlingFlowContext; > import org.eclipse.jdt.internal.compiler.flow.FlowInfo; > import org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext; >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.lookup.*; > import org.eclipse.jdt.internal.compiler.parser.*; > import org.eclipse.jdt.internal.compiler.problem.AbortMethod; >@@ -142,17 +143,27 @@ > } > > // check @Override annotation >+ final CompilerOptions compilerOptions = this.scope.compilerOptions(); > checkOverride: { > if (this.binding == null) break checkOverride; >- if (this.scope.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()) >+ // 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) { >+ } else if (!isInterfaceMethod >+ && (bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccOverriding)) == ExtraCompilerModifiers.AccOverriding) { > // actually overrides, but did not claim to do so > this.scope.problemReporter().missingOverrideAnnotation(this); > }
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