View | Details | Raw Unified | Return to bug 156736 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+2 lines)
Lines 1038-1043 Link Here
1038
        "      specialParamHiding   constructor or setter parameter hiding another field\n" + 
1038
        "      specialParamHiding   constructor or setter parameter hiding another field\n" + 
1039
        "      static-access        macro for indirectStatic and staticReceiver\n" + 
1039
        "      static-access        macro for indirectStatic and staticReceiver\n" + 
1040
        "      staticReceiver     + non-static reference to static member\n" + 
1040
        "      staticReceiver     + non-static reference to static member\n" + 
1041
        "      super                overriding a method without making a super invocation\n" +
1041
        "      suppress           + enable @SuppressWarnings\n" + 
1042
        "      suppress           + enable @SuppressWarnings\n" + 
1042
        "      synthetic-access     same as syntheticAccess\n" + 
1043
        "      synthetic-access     same as syntheticAccess\n" + 
1043
        "      syntheticAccess      synthetic access for innerclass\n" + 
1044
        "      syntheticAccess      synthetic access for innerclass\n" + 
Lines 1168-1173 Link Here
1168
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion\" value=\"warning\"/>\n" + 
1169
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion\" value=\"warning\"/>\n" + 
1169
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral\" value=\"ignore\"/>\n" + 
1170
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral\" value=\"ignore\"/>\n" + 
1170
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.nullReference\" value=\"ignore\"/>\n" + 
1171
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.nullReference\" value=\"ignore\"/>\n" + 
1172
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation\" value=\"ignore\"/>\n" + 
1171
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod\" value=\"warning\"/>\n" + 
1173
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod\" value=\"warning\"/>\n" + 
1172
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" + 
1174
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" + 
1173
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\n" + 
1175
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\n" + 
(-)src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java (+233 lines)
Lines 25-30 Link Here
25
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
25
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
26
26
27
public class MethodVerifyTest extends AbstractComparableTest {
27
public class MethodVerifyTest extends AbstractComparableTest {
28
	static {
29
//		TESTS_NAMES = new String[] { "test000" };
30
//		TESTS_NUMBERS = new int[] { 113, 114, 115 };
31
		TESTS_RANGE = new int[] { 113, -1};
32
	}
28
33
29
	public MethodVerifyTest(String name) {
34
	public MethodVerifyTest(String name) {
30
		super(name);
35
		super(name);
Lines 6981-6984 Link Here
6981
		assertTrue("should have one bridge method", found);
6986
		assertTrue("should have one bridge method", found);
6982
	}
6987
	}
6983
}
6988
}
6989
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
6990
public void test113() {
6991
	Map options = this.getCompilerOptions();
6992
	options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR);
6993
	this.runConformTest(
6994
		new String[] {
6995
			"X.java",
6996
			"abstract class Y {\n" + 
6997
			"  abstract void foo();\n" + 
6998
			"}\n" + 
6999
			"public class X extends Y {\n" + 
7000
			"  void foo() {\n" + 
7001
			"    // should not complain for missing super call, since overriding \n" + 
7002
			"    // abstract method\n" + 
7003
			"  }\n" + 
7004
			"}"
7005
		},
7006
		"",
7007
		null,
7008
		true,
7009
		null,
7010
		options,
7011
		null
7012
	);
7013
}
7014
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
7015
public void test114() {
7016
	if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) {
7017
    	Map options = this.getCompilerOptions();
7018
    	options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR);
7019
    	this.runNegativeTest(
7020
    		new String[] {
7021
    			"X.java",
7022
    			"class Y {\n" + 
7023
    			"  void foo() {}\n" + 
7024
    			"}\n" + 
7025
    			"public class X extends Y {\n" + 
7026
    			"  @Override\n" +
7027
    			"  void foo() {\n" + 
7028
    			"  }\n" + 
7029
    			"}"
7030
    		},
7031
    		"----------\n" + 
7032
    		"1. ERROR in X.java (at line 6)\n" + 
7033
    		"	void foo() {\n" + 
7034
    		"	     ^^^^^\n" + 
7035
    		"The method X.foo() is overriding a method without making a super invocation\n" + 
7036
    		"----------\n",
7037
    		null,
7038
    		true,
7039
    		options
7040
    	);
7041
	}
7042
}
7043
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
7044
public void test115() {
7045
	if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) {
7046
    	Map options = this.getCompilerOptions();
7047
    	options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR);
7048
    	this.runConformTest(
7049
			new String[] {
7050
				"X.java",
7051
    			"class Y {\n" + 
7052
    			"  void foo() {}\n" + 
7053
    			"}\n" + 
7054
    			"public class X extends Y {\n" + 
7055
    			"  @Override\n" +
7056
    			"  void foo() {\n" + 
7057
    			"    super.foo();\n" + 
7058
    			"  }\n" + 
7059
    			"}"
7060
			},
7061
			"",
7062
			null,
7063
			true,
7064
			null,
7065
			options,
7066
			null
7067
		);
7068
	}
7069
}
7070
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
7071
public void test116() {
7072
	if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) {
7073
    	Map options = this.getCompilerOptions();
7074
    	options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR);
7075
    	this.runNegativeTest(
7076
    		new String[] {
7077
    			"X.java",
7078
    			"class Y {\n" + 
7079
    			"  Zork foo() {}\n" + 
7080
    			"}\n" + 
7081
    			"public class X extends Y {\n" + 
7082
    			"  @Override\n" +
7083
    			"  Object foo() {\n" +
7084
    			"     return new Y() {\n" +
7085
    			"         Object foo() {\n" +
7086
    			"            return null;\n" +
7087
    			"         }\n" +
7088
    			"     };" +
7089
    			"  }\n" + 
7090
    			"}"
7091
    		},
7092
    		"----------\n" + 
7093
    		"1. ERROR in X.java (at line 2)\n" + 
7094
    		"	Zork foo() {}\n" + 
7095
    		"	^^^^\n" + 
7096
    		"Zork cannot be resolved to a type\n" + 
7097
    		"----------\n" + 
7098
    		"2. ERROR in X.java (at line 6)\n" + 
7099
    		"	Object foo() {\n" + 
7100
    		"	       ^^^^^\n" + 
7101
    		"The method foo() of type X must override a superclass method\n" + 
7102
    		"----------\n",
7103
    		null,
7104
    		true,
7105
    		options
7106
    	);
7107
	}
7108
}
7109
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
7110
public void test117() {
7111
	if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) {
7112
    	Map options = this.getCompilerOptions();
7113
    	options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR);
7114
    	this.runNegativeTest(
7115
    		new String[] {
7116
    			"X.java",
7117
    			"class Y {\n" + 
7118
    			"  Object foo() {\n" +
7119
    			"     return null;\n" +
7120
    			"  }\n" + 
7121
    			"}\n" + 
7122
    			"public class X extends Y {\n" + 
7123
    			"  @Override\n" +
7124
    			"  Object foo() {\n" +
7125
    			"     return new Y() {\n" +
7126
       			"         @Override\n" +
7127
    			"         Object foo() {\n" +
7128
    			"            return null;\n" +
7129
    			"         }\n" +
7130
    			"     };" +
7131
    			"  }\n" + 
7132
    			"}"
7133
    		},
7134
    		"----------\n" + 
7135
    		"1. ERROR in X.java (at line 8)\n" + 
7136
    		"	Object foo() {\n" + 
7137
    		"	       ^^^^^\n" + 
7138
    		"The method X.foo() is overriding a method without making a super invocation\n" + 
7139
    		"----------\n" + 
7140
    		"2. ERROR in X.java (at line 11)\n" + 
7141
    		"	Object foo() {\n" + 
7142
    		"	       ^^^^^\n" + 
7143
    		"The method new Y(){}.foo() is overriding a method without making a super invocation\n" + 
7144
    		"----------\n",
7145
    		null,
7146
    		true,
7147
    		options
7148
    	);
7149
	}
7150
}
7151
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
7152
public void test118() {
7153
	if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) {
7154
    	Map options = this.getCompilerOptions();
7155
    	options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR);
7156
    	this.runNegativeTest(
7157
    		new String[] {
7158
    			"X.java",
7159
    			"class Y<E> {\n" + 
7160
    			"	<U extends E> U foo() {\n" + 
7161
    			"		return null;\n" + 
7162
    			"	}\n" + 
7163
    			"}\n" + 
7164
    			"\n" + 
7165
    			"public class X<T> extends Y<T> {\n" + 
7166
    			"	@Override\n" + 
7167
    			"	<V extends T> V foo() {\n" + 
7168
    			"		return null;\n" + 
7169
    			"	}\n" + 
7170
    			"}"
7171
    		},
7172
    		"----------\n" + 
7173
    		"1. ERROR in X.java (at line 9)\n" + 
7174
    		"	<V extends T> V foo() {\n" + 
7175
    		"	                ^^^^^\n" + 
7176
    		"The method X<T>.foo() is overriding a method without making a super invocation\n" + 
7177
    		"----------\n",
7178
    		null,
7179
    		true,
7180
    		options
7181
    	);
7182
	}
7183
}
7184
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
7185
public void test119() {
7186
	if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) {
7187
    	Map options = this.getCompilerOptions();
7188
    	options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR);
7189
    	this.runNegativeTest(
7190
    		new String[] {
7191
    			"X.java",
7192
    			"class Y<E> {\n" + 
7193
    			"	E foo() {\n" + 
7194
    			"		return null;\n" + 
7195
    			"	}\n" + 
7196
    			"}\n" + 
7197
    			"\n" + 
7198
    			"public class X<T> extends Y<T> {\n" + 
7199
    			"	@Override\n" + 
7200
    			"	T foo() {\n" + 
7201
    			"		return null;\n" + 
7202
    			"	}\n" + 
7203
    			"}"
7204
    		},
7205
    		"----------\n" + 
7206
    		"1. ERROR in X.java (at line 9)\n" + 
7207
    		"	T foo() {\n" + 
7208
    		"	  ^^^^^\n" + 
7209
    		"The method X<T>.foo() is overriding a method without making a super invocation\n" + 
7210
    		"----------\n",
7211
    		null,
7212
    		true,
7213
    		options
7214
    	);
7215
	}
7216
}
6984
}
7217
}
(-)formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java (+1 lines)
Lines 327-332 Link Here
327
			optionsMap.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.DISABLED); 
327
			optionsMap.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.DISABLED); 
328
			optionsMap.put(CompilerOptions.OPTION_ReportMethodWithConstructorName, CompilerOptions.IGNORE); 
328
			optionsMap.put(CompilerOptions.OPTION_ReportMethodWithConstructorName, CompilerOptions.IGNORE); 
329
			optionsMap.put(CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, CompilerOptions.IGNORE);
329
			optionsMap.put(CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, CompilerOptions.IGNORE);
330
			optionsMap.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.IGNORE);
330
			optionsMap.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
331
			optionsMap.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
331
			optionsMap.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.DISABLED); 
332
			optionsMap.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.DISABLED); 
332
			optionsMap.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED); 
333
			optionsMap.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED); 
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-1 / +1 lines)
Lines 155-160 Link Here
155
155
156
	// for block and method declaration
156
	// for block and method declaration
157
	public static final int UndocumentedEmptyBlock = Bit4;
157
	public static final int UndocumentedEmptyBlock = Bit4;
158
	public static final int OverridingMethodWithSupercall = Bit5;
158
159
159
	// for compilation unit
160
	// for compilation unit
160
	public static final int HasAllMethodBodies = Bit5;
161
	public static final int HasAllMethodBodies = Bit5;
Lines 176-182 Link Here
176
	// for null reference analysis
177
	// for null reference analysis
177
	public static final int IsNonNull = Bit18;
178
	public static final int IsNonNull = Bit18;
178
	
179
	
179
	
180
	// constants used when checking invocation arguments
180
	// constants used when checking invocation arguments
181
	public static final int INVOCATION_ARGUMENT_OK = 0;
181
	public static final int INVOCATION_ARGUMENT_OK = 0;
182
	public static final int INVOCATION_ARGUMENT_UNCHECKED = 1;
182
	public static final int INVOCATION_ARGUMENT_UNCHECKED = 1;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java (-7 / +25 lines)
Lines 10-25 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.ast;
11
package org.eclipse.jdt.internal.compiler.ast;
12
12
13
import org.eclipse.jdt.core.compiler.*;
13
import org.eclipse.jdt.core.compiler.CharOperation;
14
import org.eclipse.jdt.internal.compiler.CompilationResult;
15
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.ASTVisitor;
15
import org.eclipse.jdt.internal.compiler.CompilationResult;
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
17
import org.eclipse.jdt.internal.compiler.flow.ExceptionHandlingFlowContext;
17
import org.eclipse.jdt.internal.compiler.flow.ExceptionHandlingFlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext;
19
import org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext;
20
import org.eclipse.jdt.internal.compiler.lookup.*;
20
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
21
import org.eclipse.jdt.internal.compiler.parser.*;
21
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
22
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
23
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
24
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
25
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
26
import org.eclipse.jdt.internal.compiler.parser.Parser;
22
import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
27
import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
28
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
23
29
24
public class MethodDeclaration extends AbstractMethodDeclaration {
30
public class MethodDeclaration extends AbstractMethodDeclaration {
25
	
31
	
Lines 142-150 Link Here
142
		}
148
		}
143
		
149
		
144
		// check @Override annotation
150
		// check @Override annotation
151
		final CompilerOptions compilerOptions = this.scope.compilerOptions();
145
		checkOverride: {
152
		checkOverride: {
146
			if (this.binding == null) break checkOverride;
153
			if (this.binding == null) break checkOverride;
147
			if (this.scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5) break checkOverride;
154
			if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5) break checkOverride;
148
			int bindingModifiers = this.binding.modifiers;
155
			int bindingModifiers = this.binding.modifiers;
149
			boolean hasOverrideAnnotation = (this.binding.tagBits & TagBits.AnnotationOverride) != 0;
156
			boolean hasOverrideAnnotation = (this.binding.tagBits & TagBits.AnnotationOverride) != 0;
150
			boolean isInterfaceMethod = this.binding.declaringClass.isInterface();
157
			boolean isInterfaceMethod = this.binding.declaringClass.isInterface();
Lines 157-163 Link Here
157
				this.scope.problemReporter().missingOverrideAnnotation(this);
164
				this.scope.problemReporter().missingOverrideAnnotation(this);
158
			}
165
			}
159
		}
166
		}
160
				
167
		
161
		// by grammatical construction, interface methods are always abstract
168
		// by grammatical construction, interface methods are always abstract
162
		switch (TypeDeclaration.kind(this.scope.referenceType().modifiers)) {
169
		switch (TypeDeclaration.kind(this.scope.referenceType().modifiers)) {
163
			case TypeDeclaration.ENUM_DECL :
170
			case TypeDeclaration.ENUM_DECL :
Lines 176-182 Link Here
176
						this.scope.problemReporter().methodNeedingNoBody(this);
183
						this.scope.problemReporter().methodNeedingNoBody(this);
177
				}
184
				}
178
		}
185
		}
179
		super.resolveStatements(); 
186
		super.resolveStatements();
187
		
188
		// TagBits.OverridingMethodWithSupercall is set during the resolveStatements() call
189
		if (compilerOptions.getSeverity(CompilerOptions.OverridingMethodWithoutSuperInvocation) != ProblemSeverities.Ignore) {
190
			if (this.binding != null) {
191
        		int bindingModifiers = this.binding.modifiers;
192
        		if ((bindingModifiers & (ExtraCompilerModifiers.AccOverriding|ExtraCompilerModifiers.AccImplementing)) == ExtraCompilerModifiers.AccOverriding
193
        				&& (this.bits & ASTNode.OverridingMethodWithSupercall) == 0) {
194
        			this.scope.problemReporter().overridesMethodWithoutSuperInvocation(this.binding);
195
        		}
196
			}
197
		}
180
	}
198
	}
181
199
182
	public void traverse(
200
	public void traverse(
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-2 / +16 lines)
Lines 16-21 Link Here
16
import org.eclipse.jdt.internal.compiler.flow.*;
16
import org.eclipse.jdt.internal.compiler.flow.*;
17
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
17
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
18
import org.eclipse.jdt.internal.compiler.impl.Constant;
18
import org.eclipse.jdt.internal.compiler.impl.Constant;
19
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
19
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
20
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
20
import org.eclipse.jdt.internal.compiler.codegen.*;
21
import org.eclipse.jdt.internal.compiler.codegen.*;
21
import org.eclipse.jdt.internal.compiler.lookup.*;
22
import org.eclipse.jdt.internal.compiler.lookup.*;
Lines 414-426 Link Here
414
		}
415
		}
415
		return this.resolvedType;
416
		return this.resolvedType;
416
	}
417
	}
418
	final CompilerOptions compilerOptions = scope.compilerOptions();
417
	if (!binding.isStatic()) {
419
	if (!binding.isStatic()) {
418
		// the "receiver" must not be a type, in other words, a NameReference that the TC has bound to a Type
420
		// the "receiver" must not be a type, in other words, a NameReference that the TC has bound to a Type
419
		if (receiverIsType) {
421
		if (receiverIsType) {
420
			scope.problemReporter().mustUseAStaticMethod(this, binding);
422
			scope.problemReporter().mustUseAStaticMethod(this, binding);
421
			if (this.actualReceiverType.isRawType() 
423
			if (this.actualReceiverType.isRawType() 
422
					&& (this.receiver.bits & IgnoreRawTypeCheck) == 0 
424
					&& (this.receiver.bits & IgnoreRawTypeCheck) == 0 
423
					&& scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) {
425
					&& compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) {
424
				scope.problemReporter().rawTypeReference(this.receiver, this.actualReceiverType);
426
				scope.problemReporter().rawTypeReference(this.receiver, this.actualReceiverType);
425
			}
427
			}
426
		} else {
428
		} else {
Lines 457-463 Link Here
457
	// from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)
459
	// from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)
458
	if (actualReceiverType.isArrayType() 
460
	if (actualReceiverType.isArrayType() 
459
			&& this.binding.parameters == Binding.NO_PARAMETERS 
461
			&& this.binding.parameters == Binding.NO_PARAMETERS 
460
			&& scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5 
462
			&& compilerOptions.complianceLevel >= ClassFileConstants.JDK1_5 
461
			&& CharOperation.equals(this.binding.selector, CLONE)) {
463
			&& CharOperation.equals(this.binding.selector, CLONE)) {
462
		this.resolvedType = actualReceiverType;
464
		this.resolvedType = actualReceiverType;
463
	} else {
465
	} else {
Lines 465-470 Link Here
465
		if (returnType != null) returnType = returnType.capture(scope, this.sourceEnd);
467
		if (returnType != null) returnType = returnType.capture(scope, this.sourceEnd);
466
		this.resolvedType = returnType;
468
		this.resolvedType = returnType;
467
	}
469
	}
470
	if (receiver.isSuper() && compilerOptions.getSeverity(CompilerOptions.OverridingMethodWithoutSuperInvocation) != ProblemSeverities.Ignore) {
471
		final ReferenceContext referenceContext = scope.methodScope().referenceContext;
472
		if (referenceContext instanceof AbstractMethodDeclaration) {
473
			final AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) referenceContext;
474
			MethodBinding enclosingMethodBinding = abstractMethodDeclaration.binding;
475
			if (enclosingMethodBinding.isOverriding()
476
					&& CharOperation.equals(this.binding.selector, enclosingMethodBinding.selector)
477
					&& this.binding.areParametersEqual(enclosingMethodBinding)) {
478
				abstractMethodDeclaration.bits |= ASTNode.OverridingMethodWithSupercall;
479
			}
480
		}
481
	}
468
	return this.resolvedType;
482
	return this.resolvedType;
469
}
483
}
470
484
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (+1 lines)
Lines 238-243 Link Here
238
\      specialParamHiding   constructor or setter parameter hiding another field\n\
238
\      specialParamHiding   constructor or setter parameter hiding another field\n\
239
\      static-access        macro for indirectStatic and staticReceiver\n\
239
\      static-access        macro for indirectStatic and staticReceiver\n\
240
\      staticReceiver     + non-static reference to static member\n\
240
\      staticReceiver     + non-static reference to static member\n\
241
\      super                overriding a method without making a super invocation\n\
241
\      suppress           + enable @SuppressWarnings\n\
242
\      suppress           + enable @SuppressWarnings\n\
242
\      synthetic-access     same as syntheticAccess\n\
243
\      synthetic-access     same as syntheticAccess\n\
243
\      syntheticAccess      synthetic access for innerclass\n\
244
\      syntheticAccess      synthetic access for innerclass\n\
(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (+4 lines)
Lines 1646-1651 Link Here
1646
		this.options.put(
1646
		this.options.put(
1647
			CompilerOptions.OPTION_ReportFallthroughCase,
1647
			CompilerOptions.OPTION_ReportFallthroughCase,
1648
			isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
1648
			isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
1649
	} else if (token.equals("super")) { //$NON-NLS-1$
1650
		this.options.put(
1651
				CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation,
1652
				isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
1649
	} else {
1653
	} else {
1650
		throw new InvalidInputException(this.bind("configure.invalidWarning", token)); //$NON-NLS-1$
1654
		throw new InvalidInputException(this.bind("configure.invalidWarning", token)); //$NON-NLS-1$
1651
	}
1655
	}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (+11 lines)
Lines 105-110 Link Here
105
	public static final String OPTION_FatalOptionalError =  "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; //$NON-NLS-1$
105
	public static final String OPTION_FatalOptionalError =  "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; //$NON-NLS-1$
106
	public static final String OPTION_ReportParameterAssignment =  "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$
106
	public static final String OPTION_ReportParameterAssignment =  "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$
107
	public static final String OPTION_ReportFallthroughCase =  "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; //$NON-NLS-1$
107
	public static final String OPTION_ReportFallthroughCase =  "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; //$NON-NLS-1$
108
	public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation =  "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
108
	
109
	
109
	// Backward compatibility
110
	// Backward compatibility
110
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
111
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
Lines 187-192 Link Here
187
	public static final long UnusedLabel = ASTNode.Bit47L;
188
	public static final long UnusedLabel = ASTNode.Bit47L;
188
	public static final long ParameterAssignment = ASTNode.Bit48L;
189
	public static final long ParameterAssignment = ASTNode.Bit48L;
189
	public static final long FallthroughCase = ASTNode.Bit49L;
190
	public static final long FallthroughCase = ASTNode.Bit49L;
191
	public static final long OverridingMethodWithoutSuperInvocation = ASTNode.Bit50L;
190
	
192
	
191
	// Default severity level for handlers
193
	// Default severity level for handlers
192
	public long errorThreshold = 0;
194
	public long errorThreshold = 0;
Lines 406-411 Link Here
406
		optionsMap.put(OPTION_ReportUnhandledWarningToken, getSeverityString(UnhandledWarningToken));
408
		optionsMap.put(OPTION_ReportUnhandledWarningToken, getSeverityString(UnhandledWarningToken));
407
		optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment));
409
		optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment));
408
		optionsMap.put(OPTION_ReportFallthroughCase, getSeverityString(FallthroughCase));
410
		optionsMap.put(OPTION_ReportFallthroughCase, getSeverityString(FallthroughCase));
411
		optionsMap.put(OPTION_ReportOverridingMethodWithoutSuperInvocation, getSeverityString(OverridingMethodWithoutSuperInvocation));
409
		return optionsMap;		
412
		return optionsMap;		
410
	}
413
	}
411
	
414
	
Lines 647-652 Link Here
647
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedLabel)) != null) updateSeverity(UnusedLabel, optionValue);
650
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedLabel)) != null) updateSeverity(UnusedLabel, optionValue);
648
		if ((optionValue = optionsMap.get(OPTION_ReportParameterAssignment)) != null) updateSeverity(ParameterAssignment, optionValue);
651
		if ((optionValue = optionsMap.get(OPTION_ReportParameterAssignment)) != null) updateSeverity(ParameterAssignment, optionValue);
649
		if ((optionValue = optionsMap.get(OPTION_ReportFallthroughCase)) != null) updateSeverity(FallthroughCase, optionValue);
652
		if ((optionValue = optionsMap.get(OPTION_ReportFallthroughCase)) != null) updateSeverity(FallthroughCase, optionValue);
653
		if ((optionValue = optionsMap.get(OPTION_ReportOverridingMethodWithoutSuperInvocation)) != null) updateSeverity(OverridingMethodWithoutSuperInvocation, optionValue);
650
654
651
		// Javadoc options
655
		// Javadoc options
652
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
656
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
Lines 914-919 Link Here
914
			OPTION_ReportUnusedPrivateMember,
918
			OPTION_ReportUnusedPrivateMember,
915
			OPTION_ReportVarargsArgumentNeedCast,
919
			OPTION_ReportVarargsArgumentNeedCast,
916
			OPTION_ReportUnhandledWarningToken,
920
			OPTION_ReportUnhandledWarningToken,
921
			OPTION_ReportOverridingMethodWithoutSuperInvocation
917
		};
922
		};
918
		return result;
923
		return result;
919
	}
924
	}
Lines 976-981 Link Here
976
					return "null"; //$NON-NLS-1$
981
					return "null"; //$NON-NLS-1$
977
				case (int) (FallthroughCase >>> 32) :
982
				case (int) (FallthroughCase >>> 32) :
978
					return "fallthrough"; //$NON-NLS-1$
983
					return "fallthrough"; //$NON-NLS-1$
984
				case (int) (OverridingMethodWithoutSuperInvocation >>> 32) :
985
					return "super"; //$NON-NLS-1$				
979
			}
986
			}
980
		}
987
		}
981
		return null;
988
		return null;
Lines 996-1001 Link Here
996
		"restriction", //$NON-NLS-1$
1003
		"restriction", //$NON-NLS-1$
997
		"serial", //$NON-NLS-1$
1004
		"serial", //$NON-NLS-1$
998
		"static-access", //$NON-NLS-1$
1005
		"static-access", //$NON-NLS-1$
1006
		"super", //$NON-NLS-1$
999
		"synthetic-access", //$NON-NLS-1$
1007
		"synthetic-access", //$NON-NLS-1$
1000
		"unchecked", //$NON-NLS-1$
1008
		"unchecked", //$NON-NLS-1$
1001
		"unqualified-field-access", //$NON-NLS-1$
1009
		"unqualified-field-access", //$NON-NLS-1$
Lines 1053-1058 Link Here
1053
					return IndirectStaticAccess | NonStaticAccessToStatic;
1061
					return IndirectStaticAccess | NonStaticAccessToStatic;
1054
				if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$
1062
				if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$
1055
					return AccessEmulation;
1063
					return AccessEmulation;
1064
				if ("super".equals(warningToken)) { //$NON-NLS-1$
1065
					return OverridingMethodWithoutSuperInvocation;
1066
				}
1056
				break;
1067
				break;
1057
			case 'u' :
1068
			case 'u' :
1058
				if ("unused".equals(warningToken)) //$NON-NLS-1$
1069
				if ("unused".equals(warningToken)) //$NON-NLS-1$
(-)compiler/org/eclipse/jdt/internal/compiler/util/Util.java (+19 lines)
Lines 404-409 Link Here
404
404
405
	/**
405
	/**
406
	 * INTERNAL USE-ONLY
406
	 * INTERNAL USE-ONLY
407
	 * Search the column number corresponding to a specific position
408
	 */
409
	public static final int searchColumnNumber(int[] startLineIndexes, int lineNumber, int position) {
410
		switch(lineNumber) {
411
			case 1 :
412
				return position + 1;
413
			case 2:
414
				return position - startLineIndexes[0];
415
			default:
416
				int line = lineNumber - 2;
417
	    		int length = startLineIndexes.length;
418
	    		if (line >= length) {
419
	    			return position - startLineIndexes[length - 1];
420
	    		}
421
	    		return position - startLineIndexes[line];
422
		}
423
	}
424
	/**
425
	 * INTERNAL USE-ONLY
407
	 * Search the line number corresponding to a specific position
426
	 * Search the line number corresponding to a specific position
408
	 */
427
	 */
409
	public static final int searchLineNumber(int[] startLineIndexes, int position) {
428
	public static final int searchLineNumber(int[] startLineIndexes, int position) {
(-)model/org/eclipse/jdt/core/JavaCore.java (+13 lines)
Lines 675-680 Link Here
675
	/**
675
	/**
676
	 * Possible  configurable option ID.
676
	 * Possible  configurable option ID.
677
	 * @see #getDefaultOptions()
677
	 * @see #getDefaultOptions()
678
	 * @since 3.3
679
	 */
680
	public static final String COMPILER_PB_OVERRIDING_METHOD_WITHOUT_SUPER_INVOCATION = PLUGIN_ID + ".compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
681
	/**
682
	 * Possible  configurable option ID.
683
	 * @see #getDefaultOptions()
678
	 */
684
	 */
679
	public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
685
	public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
680
	/**
686
	/**
Lines 2321-2326 Link Here
2321
	 *     - possible values:   { "error", "warning", "ignore" }
2327
	 *     - possible values:   { "error", "warning", "ignore" }
2322
	 *     - default:           "ignore"
2328
	 *     - default:           "ignore"
2323
	 * 
2329
	 * 
2330
	 * COMPILER / Reporting Overriding method that doesn't call the super method invocation
2331
	 *    When enabled, the compiler will issue an error or a warning if a method is overriding a method without calling
2332
	 *    the super invocation.
2333
	 *     - option id:         "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"
2334
	 *     - possible values:   { "error", "warning", "ignore" }
2335
	 *     - default:           "ignore"
2336
	 * 
2324
	 * BUILDER / Specifying Filters for Resource Copying Control
2337
	 * BUILDER / Specifying Filters for Resource Copying Control
2325
	 *    Allow to specify some filters to control the resource copy process.
2338
	 *    Allow to specify some filters to control the resource copy process.
2326
	 *     - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
2339
	 *     - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java (-16 / +1 lines)
Lines 103-109 Link Here
103
			? Util.searchLineNumber(unitResult.getLineSeparatorPositions(), problemStartPosition)
103
			? Util.searchLineNumber(unitResult.getLineSeparatorPositions(), problemStartPosition)
104
			: 0;
104
			: 0;
105
	int columnNumber = problemStartPosition >= 0
105
	int columnNumber = problemStartPosition >= 0
106
			? searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition)
106
			? Util.searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition)
107
			: 0;
107
			: 0;
108
	CategorizedProblem problem = 
108
	CategorizedProblem problem = 
109
		this.createProblem(
109
		this.createProblem(
Lines 162-180 Link Here
162
public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext referenceContext) {
162
public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext referenceContext) {
163
	unitResult.record(problem, referenceContext);
163
	unitResult.record(problem, referenceContext);
164
}
164
}
165
public static final int searchColumnNumber(int[] startLineIndexes, int lineNumber, int position) {
166
	switch(lineNumber) {
167
		case 1 :
168
			return position + 1;
169
		case 2:
170
			return position - startLineIndexes[0];
171
		default:
172
			int line = lineNumber - 2;
173
    		int length = startLineIndexes.length;
174
    		if (line >= length) {
175
    			return position - startLineIndexes[length - 1];
176
    		}
177
    		return position - startLineIndexes[line];
178
	}
179
}
180
}
165
}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (+1 lines)
Lines 342-347 Link Here
342
413 = The return type is incompatible with {0}, thus this interface cannot be implemented
342
413 = The return type is incompatible with {0}, thus this interface cannot be implemented
343
414 = Exception {0} is not compatible with throws clause in {1}, thus this interface cannot be implemented
343
414 = Exception {0} is not compatible with throws clause in {1}, thus this interface cannot be implemented
344
415 = The variable argument type {0} of the method {1} must be the last parameter
344
415 = The variable argument type {0} of the method {1} must be the last parameter
345
416 = The method {0} is overriding a method without making a super invocation
345
346
346
420 = Code snippet support cannot find the class {0}
347
420 = Code snippet support cannot find the class {0}
347
421 = Code snippet support cannot find the method {0}.{1}({2}) 
348
421 = Code snippet support cannot find the method {0}.{1}({2}) 
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (+23 lines)
Lines 272-277 Link Here
272
	
272
	
273
			case IProblem.FallthroughCase:
273
			case IProblem.FallthroughCase:
274
				return CompilerOptions.FallthroughCase;
274
				return CompilerOptions.FallthroughCase;
275
			case IProblem.OverridingMethodWithoutSuperInvocation:
276
				return CompilerOptions.OverridingMethodWithoutSuperInvocation;
275
		}
277
		}
276
		return 0;
278
		return 0;
277
	}
279
	}
Lines 361-366 Link Here
361
				case (int)(CompilerOptions.NullReference >>> 32):
363
				case (int)(CompilerOptions.NullReference >>> 32):
362
				case (int)(CompilerOptions.IncompleteEnumSwitch >>> 32):
364
				case (int)(CompilerOptions.IncompleteEnumSwitch >>> 32):
363
				case (int)(CompilerOptions.FallthroughCase >>> 32):
365
				case (int)(CompilerOptions.FallthroughCase >>> 32):
366
				case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32):
364
					return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
367
					return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
365
	
368
	
366
				case (int)(CompilerOptions.TypeParameterHiding >>> 32):
369
				case (int)(CompilerOptions.TypeParameterHiding >>> 32):
Lines 4895-4900 Link Here
4895
		localMethod.sourceStart(),
4898
		localMethod.sourceStart(),
4896
		localMethod.sourceEnd());
4899
		localMethod.sourceEnd());
4897
}
4900
}
4901
public void overridesMethodWithoutSuperInvocation(MethodBinding localMethod) {
4902
	this.handle(
4903
		IProblem.OverridingMethodWithoutSuperInvocation,
4904
		new String[] {
4905
			new String(
4906
					CharOperation.concat(
4907
						localMethod.declaringClass.readableName(),
4908
						localMethod.readableName(),
4909
						'.'))
4910
			},
4911
		new String[] {
4912
			new String(
4913
					CharOperation.concat(
4914
						localMethod.declaringClass.shortReadableName(),
4915
						localMethod.shortReadableName(),
4916
						'.'))
4917
			},
4918
		localMethod.sourceStart(),
4919
		localMethod.sourceEnd());
4920
}
4898
public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) {
4921
public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) {
4899
	String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
4922
	String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
4900
	this.handle(
4923
	this.handle(
(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (-1 / +4 lines)
Lines 94-99 Link Here
94
 *                                 ExternalProblemFixable
94
 *                                 ExternalProblemFixable
95
 *     IBM Corporation - added the following constants
95
 *     IBM Corporation - added the following constants
96
 *                                 AnnotationValueMustBeAnEnumConstant
96
 *                                 AnnotationValueMustBeAnEnumConstant
97
 *                                 OverridingMethodWithoutSuperInvocation
97
 *******************************************************************************/
98
 *******************************************************************************/
98
package org.eclipse.jdt.core.compiler;
99
package org.eclipse.jdt.core.compiler;
99
 
100
 
Lines 735-741 Link Here
735
	int IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod = MethodRelated + 414;
736
	int IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod = MethodRelated + 414;
736
	/** @since 3.1 */
737
	/** @since 3.1 */
737
	int IllegalVararg = MethodRelated + 415;
738
	int IllegalVararg = MethodRelated + 415;
738
739
	/** @since 3.3 */
740
	int OverridingMethodWithoutSuperInvocation = MethodRelated + 416; 
741
	
739
	// code snippet support
742
	// code snippet support
740
	int CodeSnippetMissingClass = Internal + 420;
743
	int CodeSnippetMissingClass = Internal + 420;
741
	int CodeSnippetMissingMethod = Internal + 421;
744
	int CodeSnippetMissingMethod = Internal + 421;

Return to bug 156736