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 52261 Details for
Bug 156736
[compiler] Add compiler option to warn overriding methods that do not call super
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Last patch + regression tests
patch_156736.txt (text/plain), 33.69 KB, created by
Olivier Thomann
on 2006-10-18 15:03:25 EDT
(
hide
)
Description:
Last patch + regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2006-10-18 15:03:25 EDT
Size:
33.69 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.77 >diff -u -r1.77 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 17 Oct 2006 21:24:12 -0000 1.77 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 18 Oct 2006 19:01:07 -0000 >@@ -1038,6 +1038,7 @@ > " specialParamHiding constructor or setter parameter hiding another field\n" + > " static-access macro for indirectStatic and staticReceiver\n" + > " staticReceiver + non-static reference to static member\n" + >+ " super overriding a method without making a super invocation\n" + > " suppress + enable @SuppressWarnings\n" + > " synthetic-access same as syntheticAccess\n" + > " syntheticAccess synthetic access for innerclass\n" + >@@ -1168,6 +1169,7 @@ > " <option key=\"org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion\" value=\"warning\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.nullReference\" value=\"ignore\"/>\n" + >+ " <option key=\"org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod\" value=\"warning\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\n" + >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.101 >diff -u -r1.101 MethodVerifyTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 12 Oct 2006 18:53:58 -0000 1.101 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 18 Oct 2006 19:01:07 -0000 >@@ -25,6 +25,11 @@ > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > > public class MethodVerifyTest extends AbstractComparableTest { >+ static { >+// TESTS_NAMES = new String[] { "test000" }; >+// TESTS_NUMBERS = new int[] { 113, 114, 115 }; >+ TESTS_RANGE = new int[] { 113, -1}; >+ } > > public MethodVerifyTest(String name) { > super(name); >@@ -6981,4 +6986,232 @@ > assertTrue("should have one bridge method", found); > } > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736 >+public void test113() { >+ Map options = this.getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "abstract class Y {\n" + >+ " abstract void foo();\n" + >+ "}\n" + >+ "public class X extends Y {\n" + >+ " void foo() {\n" + >+ " // should not complain for missing super call, since overriding \n" + >+ " // abstract method\n" + >+ " }\n" + >+ "}" >+ }, >+ "", >+ null, >+ true, >+ null, >+ options, >+ null >+ ); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736 >+public void test114() { >+ 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" + >+ " void foo() {}\n" + >+ "}\n" + >+ "public class X extends Y {\n" + >+ " @Override\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " void foo() {\n" + >+ " ^^^^^\n" + >+ "The method X.foo() is overriding a method without making a super invocation\n" + >+ "----------\n", >+ null, >+ true, >+ options >+ ); >+ } >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736 >+public void test115() { >+ if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) { >+ Map options = this.getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class Y {\n" + >+ " void foo() {}\n" + >+ "}\n" + >+ "public class X extends Y {\n" + >+ " @Override\n" + >+ " void foo() {\n" + >+ " super.foo();\n" + >+ " }\n" + >+ "}" >+ }, >+ "", >+ null, >+ true, >+ null, >+ options, >+ null >+ ); >+ } >+} >+//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 >+ ); >+ } >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736 >+public void test117() { >+ 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" + >+ " Object foo() {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n" + >+ "public class X extends Y {\n" + >+ " @Override\n" + >+ " Object foo() {\n" + >+ " return new Y() {\n" + >+ " @Override\n" + >+ " Object foo() {\n" + >+ " return null;\n" + >+ " }\n" + >+ " };" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 8)\n" + >+ " Object foo() {\n" + >+ " ^^^^^\n" + >+ "The method X.foo() is overriding a method without making a super invocation\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 11)\n" + >+ " Object foo() {\n" + >+ " ^^^^^\n" + >+ "The method new Y(){}.foo() is overriding a method without making a super invocation\n" + >+ "----------\n", >+ null, >+ true, >+ options >+ ); >+ } >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736 >+public void test118() { >+ 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<E> {\n" + >+ " <U extends E> U foo() {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "public class X<T> extends Y<T> {\n" + >+ " @Override\n" + >+ " <V extends T> V foo() {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 9)\n" + >+ " <V extends T> V foo() {\n" + >+ " ^^^^^\n" + >+ "The method X<T>.foo() is overriding a method without making a super invocation\n" + >+ "----------\n", >+ null, >+ true, >+ options >+ ); >+ } >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736 >+public void test119() { >+ 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<E> {\n" + >+ " E foo() {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "public class X<T> extends Y<T> {\n" + >+ " @Override\n" + >+ " T foo() {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 9)\n" + >+ " T foo() {\n" + >+ " ^^^^^\n" + >+ "The method X<T>.foo() is overriding a method without making a super invocation\n" + >+ "----------\n", >+ null, >+ true, >+ options >+ ); >+ } >+} > } >#P org.eclipse.jdt.core >Index: formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java,v >retrieving revision 1.56 >diff -u -r1.56 DefaultCodeFormatter.java >--- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java 21 Jun 2006 17:05:04 -0000 1.56 >+++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java 18 Oct 2006 19:01:09 -0000 >@@ -327,6 +327,7 @@ > optionsMap.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.DISABLED); > optionsMap.put(CompilerOptions.OPTION_ReportMethodWithConstructorName, CompilerOptions.IGNORE); > optionsMap.put(CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, CompilerOptions.IGNORE); >+ optionsMap.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.IGNORE); > optionsMap.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE); > optionsMap.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.DISABLED); > optionsMap.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v >retrieving revision 1.74 >diff -u -r1.74 ASTNode.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 4 Oct 2006 10:07:21 -0000 1.74 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 18 Oct 2006 19:01:08 -0000 >@@ -155,6 +155,7 @@ > > // for block and method declaration > public static final int UndocumentedEmptyBlock = Bit4; >+ public static final int OverridingMethodWithSupercall = Bit5; > > // for compilation unit > public static final int HasAllMethodBodies = Bit5; >@@ -176,7 +177,6 @@ > // for null reference analysis > public static final int IsNonNull = Bit18; > >- > // constants used when checking invocation arguments > public static final int INVOCATION_ARGUMENT_OK = 0; > public static final int INVOCATION_ARGUMENT_UNCHECKED = 1; >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.56 >diff -u -r1.56 MethodDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 13 Oct 2006 19:20:46 -0000 1.56 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 18 Oct 2006 19:01:08 -0000 >@@ -10,16 +10,22 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >-import org.eclipse.jdt.core.compiler.*; >-import org.eclipse.jdt.internal.compiler.CompilationResult; >+import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.ASTVisitor; >+import org.eclipse.jdt.internal.compiler.CompilationResult; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > 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.lookup.*; >-import org.eclipse.jdt.internal.compiler.parser.*; >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; >+import org.eclipse.jdt.internal.compiler.lookup.ClassScope; >+import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; >+import org.eclipse.jdt.internal.compiler.lookup.TagBits; >+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; >+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; >+import org.eclipse.jdt.internal.compiler.parser.Parser; > import org.eclipse.jdt.internal.compiler.problem.AbortMethod; >+import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; > > public class MethodDeclaration extends AbstractMethodDeclaration { > >@@ -142,9 +148,10 @@ > } > > // 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; >+ if (compilerOptions.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(); >@@ -157,7 +164,7 @@ > this.scope.problemReporter().missingOverrideAnnotation(this); > } > } >- >+ > // by grammatical construction, interface methods are always abstract > switch (TypeDeclaration.kind(this.scope.referenceType().modifiers)) { > case TypeDeclaration.ENUM_DECL : >@@ -176,7 +183,18 @@ > this.scope.problemReporter().methodNeedingNoBody(this); > } > } >- super.resolveStatements(); >+ super.resolveStatements(); >+ >+ // TagBits.OverridingMethodWithSupercall is set during the resolveStatements() call >+ if (compilerOptions.getSeverity(CompilerOptions.OverridingMethodWithoutSuperInvocation) != ProblemSeverities.Ignore) { >+ if (this.binding != null) { >+ int bindingModifiers = this.binding.modifiers; >+ if ((bindingModifiers & (ExtraCompilerModifiers.AccOverriding|ExtraCompilerModifiers.AccImplementing)) == ExtraCompilerModifiers.AccOverriding >+ && (this.bits & ASTNode.OverridingMethodWithSupercall) == 0) { >+ this.scope.problemReporter().overridesMethodWithoutSuperInvocation(this.binding); >+ } >+ } >+ } > } > > public void traverse( >Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v >retrieving revision 1.114 >diff -u -r1.114 MessageSend.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 16 Oct 2006 19:39:36 -0000 1.114 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 18 Oct 2006 19:01:08 -0000 >@@ -16,6 +16,7 @@ > import org.eclipse.jdt.internal.compiler.flow.*; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.impl.Constant; >+import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.codegen.*; > import org.eclipse.jdt.internal.compiler.lookup.*; >@@ -414,13 +415,14 @@ > } > return this.resolvedType; > } >+ final CompilerOptions compilerOptions = scope.compilerOptions(); > if (!binding.isStatic()) { > // the "receiver" must not be a type, in other words, a NameReference that the TC has bound to a Type > if (receiverIsType) { > scope.problemReporter().mustUseAStaticMethod(this, binding); > if (this.actualReceiverType.isRawType() > && (this.receiver.bits & IgnoreRawTypeCheck) == 0 >- && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) { >+ && compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) { > scope.problemReporter().rawTypeReference(this.receiver, this.actualReceiverType); > } > } else { >@@ -457,7 +459,7 @@ > // from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object) > if (actualReceiverType.isArrayType() > && this.binding.parameters == Binding.NO_PARAMETERS >- && scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5 >+ && compilerOptions.complianceLevel >= ClassFileConstants.JDK1_5 > && CharOperation.equals(this.binding.selector, CLONE)) { > this.resolvedType = actualReceiverType; > } else { >@@ -465,6 +467,18 @@ > if (returnType != null) returnType = returnType.capture(scope, this.sourceEnd); > this.resolvedType = returnType; > } >+ if (receiver.isSuper() && compilerOptions.getSeverity(CompilerOptions.OverridingMethodWithoutSuperInvocation) != ProblemSeverities.Ignore) { >+ final ReferenceContext referenceContext = scope.methodScope().referenceContext; >+ if (referenceContext instanceof AbstractMethodDeclaration) { >+ final AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) referenceContext; >+ MethodBinding enclosingMethodBinding = abstractMethodDeclaration.binding; >+ if (enclosingMethodBinding.isOverriding() >+ && CharOperation.equals(this.binding.selector, enclosingMethodBinding.selector) >+ && this.binding.areParametersEqual(enclosingMethodBinding)) { >+ abstractMethodDeclaration.bits |= ASTNode.OverridingMethodWithSupercall; >+ } >+ } >+ } > return this.resolvedType; > } > >Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v >retrieving revision 1.570 >diff -u -r1.570 messages.properties >--- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 17 Oct 2006 13:22:47 -0000 1.570 >+++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 18 Oct 2006 19:01:08 -0000 >@@ -238,6 +238,7 @@ > \ specialParamHiding constructor or setter parameter hiding another field\n\ > \ static-access macro for indirectStatic and staticReceiver\n\ > \ staticReceiver + non-static reference to static member\n\ >+\ super overriding a method without making a super invocation\n\ > \ suppress + enable @SuppressWarnings\n\ > \ synthetic-access same as syntheticAccess\n\ > \ syntheticAccess synthetic access for innerclass\n\ >Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v >retrieving revision 1.265 >diff -u -r1.265 Main.java >--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 17 Oct 2006 21:16:52 -0000 1.265 >+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 18 Oct 2006 19:01:08 -0000 >@@ -1646,6 +1646,10 @@ > this.options.put( > CompilerOptions.OPTION_ReportFallthroughCase, > isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE); >+ } else if (token.equals("super")) { //$NON-NLS-1$ >+ this.options.put( >+ CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, >+ isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE); > } else { > throw new InvalidInputException(this.bind("configure.invalidWarning", token)); //$NON-NLS-1$ > } >Index: compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java,v >retrieving revision 1.170 >diff -u -r1.170 CompilerOptions.java >--- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 3 Oct 2006 15:18:47 -0000 1.170 >+++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 18 Oct 2006 19:01:09 -0000 >@@ -105,6 +105,7 @@ > public static final String OPTION_FatalOptionalError = "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; //$NON-NLS-1$ > public static final String OPTION_ReportParameterAssignment = "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$ > public static final String OPTION_ReportFallthroughCase = "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; //$NON-NLS-1$ >+ public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation = "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$ > > // Backward compatibility > public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$ >@@ -187,6 +188,7 @@ > public static final long UnusedLabel = ASTNode.Bit47L; > public static final long ParameterAssignment = ASTNode.Bit48L; > public static final long FallthroughCase = ASTNode.Bit49L; >+ public static final long OverridingMethodWithoutSuperInvocation = ASTNode.Bit50L; > > // Default severity level for handlers > public long errorThreshold = 0; >@@ -406,6 +408,7 @@ > optionsMap.put(OPTION_ReportUnhandledWarningToken, getSeverityString(UnhandledWarningToken)); > optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment)); > optionsMap.put(OPTION_ReportFallthroughCase, getSeverityString(FallthroughCase)); >+ optionsMap.put(OPTION_ReportOverridingMethodWithoutSuperInvocation, getSeverityString(OverridingMethodWithoutSuperInvocation)); > return optionsMap; > } > >@@ -647,6 +650,7 @@ > if ((optionValue = optionsMap.get(OPTION_ReportUnusedLabel)) != null) updateSeverity(UnusedLabel, optionValue); > if ((optionValue = optionsMap.get(OPTION_ReportParameterAssignment)) != null) updateSeverity(ParameterAssignment, optionValue); > if ((optionValue = optionsMap.get(OPTION_ReportFallthroughCase)) != null) updateSeverity(FallthroughCase, optionValue); >+ if ((optionValue = optionsMap.get(OPTION_ReportOverridingMethodWithoutSuperInvocation)) != null) updateSeverity(OverridingMethodWithoutSuperInvocation, optionValue); > > // Javadoc options > if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) { >@@ -914,6 +918,7 @@ > OPTION_ReportUnusedPrivateMember, > OPTION_ReportVarargsArgumentNeedCast, > OPTION_ReportUnhandledWarningToken, >+ OPTION_ReportOverridingMethodWithoutSuperInvocation > }; > return result; > } >@@ -976,6 +981,8 @@ > return "null"; //$NON-NLS-1$ > case (int) (FallthroughCase >>> 32) : > return "fallthrough"; //$NON-NLS-1$ >+ case (int) (OverridingMethodWithoutSuperInvocation >>> 32) : >+ return "super"; //$NON-NLS-1$ > } > } > return null; >@@ -996,6 +1003,7 @@ > "restriction", //$NON-NLS-1$ > "serial", //$NON-NLS-1$ > "static-access", //$NON-NLS-1$ >+ "super", //$NON-NLS-1$ > "synthetic-access", //$NON-NLS-1$ > "unchecked", //$NON-NLS-1$ > "unqualified-field-access", //$NON-NLS-1$ >@@ -1053,6 +1061,9 @@ > return IndirectStaticAccess | NonStaticAccessToStatic; > if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$ > return AccessEmulation; >+ if ("super".equals(warningToken)) { //$NON-NLS-1$ >+ return OverridingMethodWithoutSuperInvocation; >+ } > break; > case 'u' : > if ("unused".equals(warningToken)) //$NON-NLS-1$ >Index: compiler/org/eclipse/jdt/internal/compiler/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java,v >retrieving revision 1.57 >diff -u -r1.57 Util.java >--- compiler/org/eclipse/jdt/internal/compiler/util/Util.java 3 Oct 2006 19:38:26 -0000 1.57 >+++ compiler/org/eclipse/jdt/internal/compiler/util/Util.java 18 Oct 2006 19:01:09 -0000 >@@ -404,6 +404,25 @@ > > /** > * INTERNAL USE-ONLY >+ * Search the column number corresponding to a specific position >+ */ >+ public static final int searchColumnNumber(int[] startLineIndexes, int lineNumber, int position) { >+ switch(lineNumber) { >+ case 1 : >+ return position + 1; >+ case 2: >+ return position - startLineIndexes[0]; >+ default: >+ int line = lineNumber - 2; >+ int length = startLineIndexes.length; >+ if (line >= length) { >+ return position - startLineIndexes[length - 1]; >+ } >+ return position - startLineIndexes[line]; >+ } >+ } >+ /** >+ * INTERNAL USE-ONLY > * Search the line number corresponding to a specific position > */ > public static final int searchLineNumber(int[] startLineIndexes, int position) { >Index: model/org/eclipse/jdt/core/JavaCore.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v >retrieving revision 1.554 >diff -u -r1.554 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 6 Oct 2006 17:43:34 -0000 1.554 >+++ model/org/eclipse/jdt/core/JavaCore.java 18 Oct 2006 19:01:09 -0000 >@@ -675,6 +675,12 @@ > /** > * Possible configurable option ID. > * @see #getDefaultOptions() >+ * @since 3.3 >+ */ >+ public static final String COMPILER_PB_OVERRIDING_METHOD_WITHOUT_SUPER_INVOCATION = PLUGIN_ID + ".compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$ >+ /** >+ * Possible configurable option ID. >+ * @see #getDefaultOptions() > */ > public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$ > /** >@@ -2321,6 +2327,13 @@ > * - possible values: { "error", "warning", "ignore" } > * - default: "ignore" > * >+ * COMPILER / Reporting Overriding method that doesn't call the super method invocation >+ * When enabled, the compiler will issue an error or a warning if a method is overriding a method without calling >+ * the super invocation. >+ * - option id: "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation" >+ * - possible values: { "error", "warning", "ignore" } >+ * - default: "ignore" >+ * > * BUILDER / Specifying Filters for Resource Copying Control > * Allow to specify some filters to control the resource copy process. > * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter" >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java,v >retrieving revision 1.26 >diff -u -r1.26 ProblemHandler.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java 3 Oct 2006 19:38:26 -0000 1.26 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java 18 Oct 2006 19:01:09 -0000 >@@ -103,7 +103,7 @@ > ? Util.searchLineNumber(unitResult.getLineSeparatorPositions(), problemStartPosition) > : 0; > int columnNumber = problemStartPosition >= 0 >- ? searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition) >+ ? Util.searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition) > : 0; > CategorizedProblem problem = > this.createProblem( >@@ -162,19 +162,4 @@ > public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext referenceContext) { > unitResult.record(problem, referenceContext); > } >-public static final int searchColumnNumber(int[] startLineIndexes, int lineNumber, int position) { >- switch(lineNumber) { >- case 1 : >- return position + 1; >- case 2: >- return position - startLineIndexes[0]; >- default: >- int line = lineNumber - 2; >- int length = startLineIndexes.length; >- if (line >= length) { >- return position - startLineIndexes[length - 1]; >- } >- return position - startLineIndexes[line]; >- } >-} > } >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.209 >diff -u -r1.209 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 17 Oct 2006 21:21:56 -0000 1.209 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 18 Oct 2006 19:01:09 -0000 >@@ -342,6 +342,7 @@ > 413 = The return type is incompatible with {0}, thus this interface cannot be implemented > 414 = Exception {0} is not compatible with throws clause in {1}, thus this interface cannot be implemented > 415 = The variable argument type {0} of the method {1} must be the last parameter >+416 = The method {0} is overriding a method without making a super invocation > > 420 = Code snippet support cannot find the class {0} > 421 = Code snippet support cannot find the method {0}.{1}({2}) >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.323 >diff -u -r1.323 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 29 Sep 2006 18:38:45 -0000 1.323 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 18 Oct 2006 19:01:09 -0000 >@@ -272,6 +272,8 @@ > > case IProblem.FallthroughCase: > return CompilerOptions.FallthroughCase; >+ case IProblem.OverridingMethodWithoutSuperInvocation: >+ return CompilerOptions.OverridingMethodWithoutSuperInvocation; > } > return 0; > } >@@ -361,6 +363,7 @@ > case (int)(CompilerOptions.NullReference >>> 32): > case (int)(CompilerOptions.IncompleteEnumSwitch >>> 32): > case (int)(CompilerOptions.FallthroughCase >>> 32): >+ case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32): > return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM; > > case (int)(CompilerOptions.TypeParameterHiding >>> 32): >@@ -4895,6 +4898,26 @@ > localMethod.sourceStart(), > localMethod.sourceEnd()); > } >+public void overridesMethodWithoutSuperInvocation(MethodBinding localMethod) { >+ this.handle( >+ IProblem.OverridingMethodWithoutSuperInvocation, >+ new String[] { >+ new String( >+ CharOperation.concat( >+ localMethod.declaringClass.readableName(), >+ localMethod.readableName(), >+ '.')) >+ }, >+ new String[] { >+ new String( >+ CharOperation.concat( >+ localMethod.declaringClass.shortReadableName(), >+ localMethod.shortReadableName(), >+ '.')) >+ }, >+ localMethod.sourceStart(), >+ localMethod.sourceEnd()); >+} > public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) { > String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)}; > this.handle( >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.180 >diff -u -r1.180 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 13 Sep 2006 02:25:45 -0000 1.180 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 18 Oct 2006 19:01:08 -0000 >@@ -94,6 +94,7 @@ > * ExternalProblemFixable > * IBM Corporation - added the following constants > * AnnotationValueMustBeAnEnumConstant >+ * OverridingMethodWithoutSuperInvocation > *******************************************************************************/ > package org.eclipse.jdt.core.compiler; > >@@ -735,7 +736,9 @@ > int IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod = MethodRelated + 414; > /** @since 3.1 */ > int IllegalVararg = MethodRelated + 415; >- >+ /** @since 3.3 */ >+ int OverridingMethodWithoutSuperInvocation = MethodRelated + 416; >+ > // code snippet support > int CodeSnippetMissingClass = Internal + 420; > int CodeSnippetMissingMethod = Internal + 421;
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 156736
:
52077
|
52122
| 52261