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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java (-1 / +73 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 28-34 Link Here
28
	static {
29
	static {
29
//		TESTS_NAMES = new String[] { "test000" };
30
//		TESTS_NAMES = new String[] { "test000" };
30
//		TESTS_NUMBERS = new int[] { 121 };
31
//		TESTS_NUMBERS = new int[] { 121 };
31
//		TESTS_RANGE = new int[] { 113, -1};
32
		TESTS_RANGE = new int[] { 160, 170};
32
	}
33
	}
33
34
34
	public MethodVerifyTest(String name) {
35
	public MethodVerifyTest(String name) {
Lines 8676-8679 Link Here
8676
		"----------\n"
8677
		"----------\n"
8677
	);
8678
	);
8678
}
8679
}
8680
8681
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239066
8682
public void test166() {
8683
	this.runNegativeTest(
8684
		new String[] {
8685
			"X.java",
8686
			"class X { synchronized void foo() {} }\n" +
8687
			"class Y extends X { @Override void foo() { } }"
8688
		},
8689
		"----------\n" +
8690
		"1. WARNING in X.java (at line 2)\n" +
8691
		"	class Y extends X { @Override void foo() { } }\n" +
8692
		"	                                   ^^^^^\n" +
8693
		"The method Y.foo() is overriding a synchronized method without being synchronized\n" +
8694
		"----------\n"
8695
	);
8696
}
8697
8698
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239066
8699
public void test167() {
8700
	this.runNegativeTest(
8701
		new String[] {
8702
			"X.java",
8703
			"public enum X {\n" + 
8704
			"  FOO { @Override void foo() { super.foo(); } };\n"+
8705
			"  synchronized void foo() { }\n"+
8706
			"}"
8707
		},
8708
		"----------\n" +
8709
		"1. WARNING in X.java (at line 2)\n" +
8710
		"	FOO { @Override void foo() { super.foo(); } };\n" +
8711
		"	                     ^^^^^\n" +
8712
		"The method new X(){}.foo() is overriding a synchronized method without being synchronized\n" +
8713
		"----------\n");
8714
}
8715
8716
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239066
8717
public void test168() {
8718
	this.runNegativeTest(
8719
			new String[] {
8720
					"X.java",
8721
					"public class X {\n" + 
8722
					"  void bar() { new X() { @Override void foo() {} }; }\n"+
8723
					"  synchronized void foo() { }\n"+
8724
					"}"
8725
			},
8726
			"----------\n" +
8727
			"1. WARNING in X.java (at line 2)\n" +
8728
			"	void bar() { new X() { @Override void foo() {} }; }\n"+
8729
			"	                                      ^^^^^\n" +
8730
			"The method new X(){}.foo() is overriding a synchronized method without being synchronized\n" +
8731
			"----------\n");
8732
}
8733
8734
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239066
8735
public void test169() {
8736
	this.runNegativeTest(
8737
			new String[] {
8738
					"X.java",
8739
					"public class X { synchronized void foo() {} }\n" +
8740
					"class Y extends X {}\n" +
8741
					"class Z extends Y { @Override void foo() {} }\n"
8742
			},
8743
			"----------\n" +
8744
			"1. WARNING in X.java (at line 3)\n" +
8745
			"	class Z extends Y { @Override void foo() {} }\n" +
8746
			"	                                   ^^^^^\n" +
8747
			"The method Z.foo() is overriding a synchronized method without being synchronized\n" +
8748
	"----------\n");
8749
}
8750
8679
}
8751
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java (+3 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 847-852 Link Here
847
		expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericConstructor", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
848
		expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericConstructor", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
848
		expectedProblemAttributes.put("ExternalProblemNotFixable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
849
		expectedProblemAttributes.put("ExternalProblemNotFixable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
849
		expectedProblemAttributes.put("ExternalProblemFixable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
850
		expectedProblemAttributes.put("ExternalProblemFixable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
851
		expectedProblemAttributes.put("MissingSynchronizedModifierInInheritedMethod", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
850
		StringBuffer failures = new StringBuffer();
852
		StringBuffer failures = new StringBuffer();
851
		Field[] fields = (iProblemClass = IProblem.class).getFields();
853
		Field[] fields = (iProblemClass = IProblem.class).getFields();
852
		boolean watchInternalCategory = false, printHeader = true;
854
		boolean watchInternalCategory = false, printHeader = true;
Lines 1994-1999 Link Here
1994
		expectedProblemAttributes.put("ExternalProblemNotFixable", SKIP);
1996
		expectedProblemAttributes.put("ExternalProblemNotFixable", SKIP);
1995
		expectedProblemAttributes.put("ExternalProblemFixable", SKIP);
1997
		expectedProblemAttributes.put("ExternalProblemFixable", SKIP);
1996
		expectedProblemAttributes.put("ComparingIdentical", new ProblemAttributes(JavaCore.COMPILER_PB_COMPARING_IDENTICAL));
1998
		expectedProblemAttributes.put("ComparingIdentical", new ProblemAttributes(JavaCore.COMPILER_PB_COMPARING_IDENTICAL));
1999
		expectedProblemAttributes.put("MissingSynchronizedModifierInInheritedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD));
1997
		Map constantNamesIndex = new HashMap();
2000
		Map constantNamesIndex = new HashMap();
1998
		Field[] fields = JavaCore.class.getFields();
2001
		Field[] fields = JavaCore.class.getFields();
1999
		for (int i = 0, length = fields.length; i < length; i++) {
2002
		for (int i = 0, length = fields.length; i < length; i++) {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+3 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 1678-1683 Link Here
1678
        "      staticReceiver     + non-static reference to static member\n" +
1679
        "      staticReceiver     + non-static reference to static member\n" +
1679
        "      super                overriding a method without making a super invocation\n" +
1680
        "      super                overriding a method without making a super invocation\n" +
1680
        "      suppress           + enable @SuppressWarnings\n" +
1681
        "      suppress           + enable @SuppressWarnings\n" +
1682
        "      syncOverride     overriding a synchronized method without synchronizing it\n" +
1681
        "      synthetic-access     same as syntheticAccess\n" +
1683
        "      synthetic-access     same as syntheticAccess\n" +
1682
        "      syntheticAccess      synthetic access for innerclass\n" +
1684
        "      syntheticAccess      synthetic access for innerclass\n" +
1683
        "      tasks(<tags separated by |>) tasks identified by tags inside comments\n" +
1685
        "      tasks(<tags separated by |>) tasks identified by tags inside comments\n" +
Lines 1808-1813 Link Here
1808
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility\" value=\"public\"/>\n" +
1810
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility\" value=\"public\"/>\n" +
1809
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation\" value=\"ignore\"/>\n" +
1811
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation\" value=\"ignore\"/>\n" +
1810
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.missingSerialVersion\" value=\"warning\"/>\n" +
1812
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.missingSerialVersion\" value=\"warning\"/>\n" +
1813
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod\" value=\"warning\"/>\n" +
1811
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.noEffectAssignment\" value=\"warning\"/>\n" +
1814
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.noEffectAssignment\" value=\"warning\"/>\n" +
1812
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion\" value=\"warning\"/>\n" +
1815
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion\" value=\"warning\"/>\n" +
1813
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral\" value=\"ignore\"/>\n" +
1816
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral\" value=\"ignore\"/>\n" +
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java (+4 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.lookup;
12
package org.eclipse.jdt.internal.compiler.lookup;
12
13
Lines 179-184 Link Here
179
				problemReporter(currentMethod).finalMethodCannotBeOverridden(currentMethod, inheritedMethod);
180
				problemReporter(currentMethod).finalMethodCannotBeOverridden(currentMethod, inheritedMethod);
180
			if (!isAsVisible(currentMethod, inheritedMethod))
181
			if (!isAsVisible(currentMethod, inheritedMethod))
181
				problemReporter(currentMethod).visibilityConflict(currentMethod, inheritedMethod);
182
				problemReporter(currentMethod).visibilityConflict(currentMethod, inheritedMethod);
183
			if(inheritedMethod.isSynchronized() && !currentMethod.isSynchronized()) {
184
				problemReporter(currentMethod).missingSynchronizedOnInheritedMethod(currentMethod, inheritedMethod);
185
			}
182
			if (options.reportDeprecationWhenOverridingDeprecatedMethod && inheritedMethod.isViewedAsDeprecated()) {
186
			if (options.reportDeprecationWhenOverridingDeprecatedMethod && inheritedMethod.isViewedAsDeprecated()) {
183
				if (!currentMethod.isViewedAsDeprecated() || options.reportDeprecationInsideDeprecatedCode) {
187
				if (!currentMethod.isViewedAsDeprecated() || options.reportDeprecationInsideDeprecatedCode) {
184
					// check against the other inherited methods to see if they hide this inheritedMethod
188
					// check against the other inherited methods to see if they hide this inheritedMethod
(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (+5 lines)
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Tom Tromey - Contribution for bug 125961
10
 *     Tom Tromey - Contribution for bug 125961
11
 *     Tom Tromey - Contribution for bug 159641
11
 *     Tom Tromey - Contribution for bug 159641
12
 *     Benjamin Muskalla - Contribution for bug 239066
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.jdt.internal.compiler.batch;
14
package org.eclipse.jdt.internal.compiler.batch;
14
15
Lines 3168-3173 Link Here
3168
		this.options.put(
3169
		this.options.put(
3169
				CompilerOptions.OPTION_ReportComparingIdentical,
3170
				CompilerOptions.OPTION_ReportComparingIdentical,
3170
				isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
3171
				isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
3172
	} else if (token.equals("syncOverride")) { //$NON-NLS-1$
3173
		this.options.put(
3174
				CompilerOptions.OPTION_ReportMissingSynchronizedOnInheritedMethod,
3175
				isEnabling ? CompilerOptions.ERROR : CompilerOptions.IGNORE);
3171
	} else if (token.equals("intfNonInherited") || token.equals("interfaceNonInherited")/*backward compatible*/) { //$NON-NLS-1$ //$NON-NLS-2$
3176
	} else if (token.equals("intfNonInherited") || token.equals("interfaceNonInherited")/*backward compatible*/) { //$NON-NLS-1$ //$NON-NLS-2$
3172
		this.options.put(
3177
		this.options.put(
3173
			CompilerOptions.OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
3178
			CompilerOptions.OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (+2 lines)
Lines 7-12 Link Here
7
#
7
#
8
# Contributors:
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
#		Benjamin Muskalla - Contribution for bug 239066
10
###############################################################################
11
###############################################################################
11
### JavaBatchCompiler messages.
12
### JavaBatchCompiler messages.
12
13
Lines 275-280 Link Here
275
\      staticReceiver     + non-static reference to static member\n\
276
\      staticReceiver     + non-static reference to static member\n\
276
\      super                overriding a method without making a super invocation\n\
277
\      super                overriding a method without making a super invocation\n\
277
\      suppress           + enable @SuppressWarnings\n\
278
\      suppress           + enable @SuppressWarnings\n\
279
\      syncOverride     overriding a synchronized method without synchronizing it\n\
278
\      synthetic-access     same as syntheticAccess\n\
280
\      synthetic-access     same as syntheticAccess\n\
279
\      syntheticAccess      synthetic access for innerclass\n\
281
\      syntheticAccess      synthetic access for innerclass\n\
280
\      tasks(<tags separated by |>) tasks identified by tags inside comments\n\
282
\      tasks(<tags separated by |>) tasks identified by tags inside comments\n\
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (+2 lines)
Lines 7-12 Link Here
7
#
7
#
8
# Contributors:
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
#		Benjamin Muskalla - Contribution for bug 239066
10
###############################################################################
11
###############################################################################
11
0 = {0}
12
0 = {0}
12
1 = super cannot be used in java.lang.Object
13
1 = super cannot be used in java.lang.Object
Lines 348-353 Link Here
348
414 = Exception {0} is not compatible with throws clause in {1}, thus this interface cannot be implemented
349
414 = Exception {0} is not compatible with throws clause in {1}, thus this interface cannot be implemented
349
415 = The variable argument type {0} of the method {1} must be the last parameter
350
415 = The variable argument type {0} of the method {1} must be the last parameter
350
416 = The method {0} is overriding a method without making a super invocation
351
416 = The method {0} is overriding a method without making a super invocation
352
417 = The method {0}.{1}({2}) is overriding a synchronized method without being synchronized
351
353
352
420 = Code snippet support cannot find the class {0}
354
420 = Code snippet support cannot find the class {0}
353
421 = Code snippet support cannot find the method {0}.{1}({2}) 
355
421 = Code snippet support cannot find the method {0}.{1}({2}) 
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (+21 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.problem;
12
package org.eclipse.jdt.internal.compiler.problem;
12
13
Lines 318-323 Link Here
318
319
319
		case IProblem.ComparingIdentical:
320
		case IProblem.ComparingIdentical:
320
			return CompilerOptions.ComparingIdentical;
321
			return CompilerOptions.ComparingIdentical;
322
			
323
		case IProblem.MissingSynchronizedModifierInInheritedMethod:
324
			return CompilerOptions.MissingSynchronizedModifierInInheritedMethod;
321
	}
325
	}
322
	return 0;
326
	return 0;
323
}
327
}
Lines 410-415 Link Here
410
				case (int)(CompilerOptions.FallthroughCase >>> 32):
414
				case (int)(CompilerOptions.FallthroughCase >>> 32):
411
				case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32):
415
				case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32):
412
				case (int)(CompilerOptions.ComparingIdentical >>> 32):
416
				case (int)(CompilerOptions.ComparingIdentical >>> 32):
417
				case (int)(CompilerOptions.MissingSynchronizedModifierInInheritedMethod >> 32):
413
					return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
418
					return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
414
419
415
				case (int)(CompilerOptions.TypeHiding >>> 32):
420
				case (int)(CompilerOptions.TypeHiding >>> 32):
Lines 4910-4915 Link Here
4910
		typeDecl.sourceStart,
4915
		typeDecl.sourceStart,
4911
		typeDecl.sourceEnd);
4916
		typeDecl.sourceEnd);
4912
}
4917
}
4918
public void missingSynchronizedOnInheritedMethod(MethodBinding currentMethod, MethodBinding inheritedMethod) {
4919
	this.handle(
4920
			IProblem.MissingSynchronizedModifierInInheritedMethod,
4921
			new String[] {
4922
					new String(currentMethod.declaringClass.readableName()),
4923
					new String(currentMethod.selector),
4924
					typesAsString(currentMethod.isVarargs(), currentMethod.parameters, false),
4925
			},
4926
			new String[] {
4927
					new String(currentMethod.declaringClass.shortReadableName()),
4928
					new String(currentMethod.selector),
4929
					typesAsString(currentMethod.isVarargs(), currentMethod.parameters, true),
4930
			},
4931
			currentMethod.sourceStart(),
4932
			currentMethod.sourceEnd());
4933
}
4913
public void missingTypeInConstructor(ASTNode location, MethodBinding constructor) {
4934
public void missingTypeInConstructor(ASTNode location, MethodBinding constructor) {
4914
	List missingTypes = constructor.collectMissingTypes(null);
4935
	List missingTypes = constructor.collectMissingTypes(null);
4915
	TypeBinding missingType = (TypeBinding) missingTypes.get(0);
4936
	TypeBinding missingType = (TypeBinding) missingTypes.get(0);
(-)model/org/eclipse/jdt/core/JavaCore.java (-1 / +14 lines)
Lines 80-85 Link Here
80
 *     IBM Corporation - added the following constant:
80
 *     IBM Corporation - added the following constant:
81
 *                                 COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_EXEMPT_EXCEPTION_AND_THROWABLE
81
 *                                 COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_EXEMPT_EXCEPTION_AND_THROWABLE
82
 *     IBM Corporation - added getOptionForConfigurableSeverity(int)
82
 *     IBM Corporation - added getOptionForConfigurableSeverity(int)
83
 *     Benjamin Muskalla - added COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD
83
 *******************************************************************************/
84
 *******************************************************************************/
84
package org.eclipse.jdt.core;
85
package org.eclipse.jdt.core;
85
86
Lines 1468-1474 Link Here
1468
	 * @category CompilerOptionID
1469
	 * @category CompilerOptionID
1469
	 */
1470
	 */
1470
	public static final String COMPILER_PB_COMPARING_IDENTICAL = PLUGIN_ID + ".compiler.problem.comparingIdentical"; //$NON-NLS-1$
1471
	public static final String COMPILER_PB_COMPARING_IDENTICAL = PLUGIN_ID + ".compiler.problem.comparingIdentical"; //$NON-NLS-1$
1471
1472
	/**
1473
	 * Compiler option ID: Reporting Missing Synchronized Modifier On Inherited Method.
1474
	 * <p>When enabled, the compiler will issue an error or a warning if a method
1475
	 * overrides a synchronized method without having a synchronized modifier.
1476
	 * <dl>
1477
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod"</code></dd>
1478
	 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
1479
	 * <dt>Default:</dt><dd><code>"warning"</code></dd>
1480
	 * </dl>
1481
	 * @since 3.5
1482
	 * @category CompilerOptionID
1483
	 */
1484
	public static final String COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD = PLUGIN_ID + ".compiler.problem.missingSynchronizedOnInheritedMethod"; //$NON-NLS-1$
1472
	/**
1485
	/**
1473
	 * Core option ID: Computing Project Build Order.
1486
	 * Core option ID: Computing Project Build Order.
1474
	 * <p>Indicate whether JavaCore should enforce the project build order to be based on
1487
	 * <p>Indicate whether JavaCore should enforce the project build order to be based on
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (-1 / +11 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.impl;
12
package org.eclipse.jdt.internal.compiler.impl;
12
13
Lines 120-125 Link Here
120
	public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
121
	public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
121
	public static final String OPTION_ReportRedundantSuperinterface =  "org.eclipse.jdt.core.compiler.problem.redundantSuperinterface"; //$NON-NLS-1$
122
	public static final String OPTION_ReportRedundantSuperinterface =  "org.eclipse.jdt.core.compiler.problem.redundantSuperinterface"; //$NON-NLS-1$
122
	public static final String OPTION_ReportComparingIdentical =  "org.eclipse.jdt.core.compiler.problem.comparingIdentical"; //$NON-NLS-1$
123
	public static final String OPTION_ReportComparingIdentical =  "org.eclipse.jdt.core.compiler.problem.comparingIdentical"; //$NON-NLS-1$
124
	public static final String OPTION_ReportMissingSynchronizedOnInheritedMethod =  "org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod"; //$NON-NLS-1$
123
125
124
	// Backward compatibility
126
	// Backward compatibility
125
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
127
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
Lines 215-220 Link Here
215
	public static final long UnusedWarningToken = ASTNode.Bit55L;
217
	public static final long UnusedWarningToken = ASTNode.Bit55L;
216
	public static final long RedundantSuperinterface = ASTNode.Bit56L;
218
	public static final long RedundantSuperinterface = ASTNode.Bit56L;
217
	public static final long ComparingIdentical = ASTNode.Bit57L;
219
	public static final long ComparingIdentical = ASTNode.Bit57L;
220
	public static final long MissingSynchronizedModifierInInheritedMethod= ASTNode.Bit58L;
218
221
219
	// Map: String optionKey --> Long irritant>
222
	// Map: String optionKey --> Long irritant>
220
	private static Map OptionToIrritants;
223
	private static Map OptionToIrritants;
Lines 251-257 Link Here
251
		| UnusedTypeArguments
254
		| UnusedTypeArguments
252
		| NullReference
255
		| NullReference
253
		| UnusedWarningToken
256
		| UnusedWarningToken
254
		| ComparingIdentical;
257
		| ComparingIdentical
258
		| MissingSynchronizedModifierInInheritedMethod;
255
259
256
	// By default only lines and source attributes are generated.
260
	// By default only lines and source attributes are generated.
257
	public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
261
	public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
Lines 463-468 Link Here
463
		optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED);
467
		optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED);
464
		optionsMap.put(OPTION_ReportRedundantSuperinterface, getSeverityString(RedundantSuperinterface));
468
		optionsMap.put(OPTION_ReportRedundantSuperinterface, getSeverityString(RedundantSuperinterface));
465
		optionsMap.put(OPTION_ReportComparingIdentical, getSeverityString(ComparingIdentical));
469
		optionsMap.put(OPTION_ReportComparingIdentical, getSeverityString(ComparingIdentical));
470
		optionsMap.put(OPTION_ReportMissingSynchronizedOnInheritedMethod, getSeverityString(MissingSynchronizedModifierInInheritedMethod));
466
		return optionsMap;
471
		return optionsMap;
467
	}
472
	}
468
473
Lines 595-600 Link Here
595
					return OPTION_ReportRedundantSuperinterface;
600
					return OPTION_ReportRedundantSuperinterface;
596
				case (int)(ComparingIdentical >>> 32) :
601
				case (int)(ComparingIdentical >>> 32) :
597
					return OPTION_ReportComparingIdentical;
602
					return OPTION_ReportComparingIdentical;
603
				case (int)(MissingSynchronizedModifierInInheritedMethod >>> 32) :
604
					return OPTION_ReportMissingSynchronizedOnInheritedMethod;
598
			}
605
			}
599
		}
606
		}
600
		return null;
607
		return null;
Lines 884-889 Link Here
884
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedTypeArgumentsForMethodInvocation)) != null) updateSeverity(UnusedTypeArguments, optionValue);
891
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedTypeArgumentsForMethodInvocation)) != null) updateSeverity(UnusedTypeArguments, optionValue);
885
		if ((optionValue = optionsMap.get(OPTION_ReportRedundantSuperinterface)) != null) updateSeverity(RedundantSuperinterface, optionValue);
892
		if ((optionValue = optionsMap.get(OPTION_ReportRedundantSuperinterface)) != null) updateSeverity(RedundantSuperinterface, optionValue);
886
		if ((optionValue = optionsMap.get(OPTION_ReportComparingIdentical)) != null) updateSeverity(ComparingIdentical, optionValue);
893
		if ((optionValue = optionsMap.get(OPTION_ReportComparingIdentical)) != null) updateSeverity(ComparingIdentical, optionValue);
894
		if ((optionValue = optionsMap.get(OPTION_ReportMissingSynchronizedOnInheritedMethod)) != null) updateSeverity(MissingSynchronizedModifierInInheritedMethod, optionValue);
887
895
888
		// Javadoc options
896
		// Javadoc options
889
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
897
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
Lines 1081-1086 Link Here
1081
		buf.append("\n\t- unused type arguments for method/constructor invocation: ").append(getSeverityString(UnusedTypeArguments)); //$NON-NLS-1$
1089
		buf.append("\n\t- unused type arguments for method/constructor invocation: ").append(getSeverityString(UnusedTypeArguments)); //$NON-NLS-1$
1082
		buf.append("\n\t- redundant superinterface: ").append(getSeverityString(RedundantSuperinterface)); //$NON-NLS-1$
1090
		buf.append("\n\t- redundant superinterface: ").append(getSeverityString(RedundantSuperinterface)); //$NON-NLS-1$
1083
		buf.append("\n\t- comparing identical expr: ").append(getSeverityString(ComparingIdentical)); //$NON-NLS-1$
1091
		buf.append("\n\t- comparing identical expr: ").append(getSeverityString(ComparingIdentical)); //$NON-NLS-1$
1092
		buf.append("\n\t- missing synchronized on inherited method: ").append(getSeverityString(MissingSynchronizedModifierInInheritedMethod)); //$NON-NLS-1$
1084
		return buf.toString();
1093
		return buf.toString();
1085
	}
1094
	}
1086
1095
Lines 1321-1326 Link Here
1321
		"unqualified-field-access", //$NON-NLS-1$
1330
		"unqualified-field-access", //$NON-NLS-1$
1322
		"unused", //$NON-NLS-1$
1331
		"unused", //$NON-NLS-1$
1323
	};
1332
	};
1333
	
1324
	public static long warningTokenToIrritants(String warningToken) {
1334
	public static long warningTokenToIrritants(String warningToken) {
1325
		// keep in sync with warningTokens and warningTokenFromIrritant
1335
		// keep in sync with warningTokens and warningTokenFromIrritant
1326
		if (warningToken == null || warningToken.length() == 0) return 0;
1336
		if (warningToken == null || warningToken.length() == 0) return 0;
(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+5 lines)
Lines 113-118 Link Here
113
 *                                 InvalidUsageOfTypeParametersForEnumDeclaration
113
 *                                 InvalidUsageOfTypeParametersForEnumDeclaration
114
 *     IBM Corporation - added the following constants
114
 *     IBM Corporation - added the following constants
115
 *								   RedundantSuperinterface
115
 *								   RedundantSuperinterface
116
 *		Benjamin Muskalla - added the following constants
117
 *									MissingSynchronizedModifierInInheritedMethod
118
 *									
116
 *******************************************************************************/
119
 *******************************************************************************/
117
package org.eclipse.jdt.core.compiler;
120
package org.eclipse.jdt.core.compiler;
118
121
Lines 769-774 Link Here
769
	int IllegalVararg = MethodRelated + 415;
772
	int IllegalVararg = MethodRelated + 415;
770
	/** @since 3.3 */
773
	/** @since 3.3 */
771
	int OverridingMethodWithoutSuperInvocation = MethodRelated + 416;
774
	int OverridingMethodWithoutSuperInvocation = MethodRelated + 416;
775
	/** @since 3.5 */
776
	int MissingSynchronizedModifierInInheritedMethod= MethodRelated + 417;
772
777
773
	// code snippet support
778
	// code snippet support
774
	int CodeSnippetMissingClass = Internal + 420;
779
	int CodeSnippetMissingClass = Internal + 420;
(-)guide/jdt_api_options.htm (+14 lines)
Lines 805-810 Link Here
805
</tr>
805
</tr>
806
806
807
<tr>
807
<tr>
808
<td colspan=2><b>Reporting Missing synchronized modifier of inherited methods</b> (<b><a href="../reference/api/org/eclipse/jdt/core/JavaCore.html#COMPILER_PB_MISSING_COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD">COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD</a></b>)</td>
809
</tr>
810
<tr valign="top">
811
<td rowspan=3>When enabled, the compiler will issue an error or a warning whenever a method overrides a synchronized method without having a synchronized modifier.</td>
812
<td><b><a href="../reference/api/org/eclipse/jdt/core/JavaCore.html#ERROR">ERROR</a></b></td>
813
</tr>
814
<tr valign="top">
815
<td><b><a href="../reference/api/org/eclipse/jdt/core/JavaCore.html#WARNING"><i>WARNING</i></a></b></td>
816
</tr>
817
<tr valign="top">
818
<td><b><a href="../reference/api/org/eclipse/jdt/core/JavaCore.html#IGNORE">IGNORE</a></b></td>
819
</tr>
820
821
<tr>
808
<td colspan=2><b>Reporting Assignment with No Effect</b> (<b><a href="../reference/api/org/eclipse/jdt/core/JavaCore.html#COMPILER_PB_NO_EFFECT_ASSIGNMENT">COMPILER_PB_NO_EFFECT_ASSIGNMENT</a></b>)</td>
822
<td colspan=2><b>Reporting Assignment with No Effect</b> (<b><a href="../reference/api/org/eclipse/jdt/core/JavaCore.html#COMPILER_PB_NO_EFFECT_ASSIGNMENT">COMPILER_PB_NO_EFFECT_ASSIGNMENT</a></b>)</td>
809
</tr>
823
</tr>
810
<tr valign="top">
824
<tr valign="top">

Return to bug 239066