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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+3 lines)
Lines 95-100 Link Here
95
 *     IBM Corporation - added the following constants
95
 *     IBM Corporation - added the following constants
96
 *                                 AnnotationValueMustBeAnEnumConstant
96
 *                                 AnnotationValueMustBeAnEnumConstant
97
 *                                 OverridingMethodWithoutSuperInvocation
97
 *                                 OverridingMethodWithoutSuperInvocation
98
 *                                 MethodMustOverrideOrImplement
98
 *******************************************************************************/
99
 *******************************************************************************/
99
package org.eclipse.jdt.core.compiler;
100
package org.eclipse.jdt.core.compiler;
100
 
101
 
Lines 1121-1126 Link Here
1121
	int AnnotationValueMustBeArrayInitializer = Internal + 632;
1122
	int AnnotationValueMustBeArrayInitializer = Internal + 632;
1122
	/** @since 3.3 */
1123
	/** @since 3.3 */
1123
	int AnnotationValueMustBeAnEnumConstant = Internal + 633;
1124
	int AnnotationValueMustBeAnEnumConstant = Internal + 633;
1125
	/** @since 3.3 */
1126
	int MethodMustOverrideOrImplement = MethodRelated + 634;
1124
	
1127
	
1125
	/**
1128
	/**
1126
	 * Corrupted binaries
1129
	 * Corrupted binaries
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (-1 / +1 lines)
Lines 526-531 Link Here
526
631 = Unhandled warning token {0}
526
631 = Unhandled warning token {0}
527
632 = The value for annotation attribute {0}.{1} must be an array initializer
527
632 = The value for annotation attribute {0}.{1} must be an array initializer
528
633 = The value for annotation attribute {0}.{1} must be an enum constant expression
528
633 = The value for annotation attribute {0}.{1} must be an enum constant expression
529
634 = The method {0}({1}) of type {2} must override or implement a supertype method
529
530
530
### CORRUPTED BINARIES
531
### CORRUPTED BINARIES
531
700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2}
532
700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2}
Lines 570-573 Link Here
570
857 = Incorrect number of type arguments for generic constructor <{3}>{0}({1}) of type {2}; it cannot be parameterized with arguments <{4}>
571
857 = Incorrect number of type arguments for generic constructor <{3}>{0}({1}) of type {2}; it cannot be parameterized with arguments <{4}>
571
858 = The parameterized constructor <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4})
572
858 = The parameterized constructor <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4})
572
859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}>
573
859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}>
573
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-1 / +2 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
				
275
			case IProblem.OverridingMethodWithoutSuperInvocation:
276
			case IProblem.OverridingMethodWithoutSuperInvocation:
276
				return CompilerOptions.OverridingMethodWithoutSuperInvocation;
277
				return CompilerOptions.OverridingMethodWithoutSuperInvocation;
277
		}
278
		}
Lines 4343-4349 Link Here
4343
public void methodMustOverride(AbstractMethodDeclaration method) {
4344
public void methodMustOverride(AbstractMethodDeclaration method) {
4344
	MethodBinding binding = method.binding;
4345
	MethodBinding binding = method.binding;
4345
	this.handle(
4346
	this.handle(
4346
		IProblem.MethodMustOverride,
4347
		this.options.sourceLevel == ClassFileConstants.JDK1_5 ? IProblem.MethodMustOverride : IProblem.MethodMustOverrideOrImplement,
4347
		new String[] {new String(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, false), new String(binding.declaringClass.readableName()), },
4348
		new String[] {new String(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, false), new String(binding.declaringClass.readableName()), },
4348
		new String[] {new String(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, true), new String(binding.declaringClass.shortReadableName()),},
4349
		new String[] {new String(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, true), new String(binding.declaringClass.shortReadableName()),},
4349
		method.sourceStart,
4350
		method.sourceStart,
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java (-6 / +15 lines)
Lines 151-170 Link Here
151
		final CompilerOptions compilerOptions = this.scope.compilerOptions();
151
		final CompilerOptions compilerOptions = this.scope.compilerOptions();
152
		checkOverride: {
152
		checkOverride: {
153
			if (this.binding == null) break checkOverride;
153
			if (this.binding == null) break checkOverride;
154
			if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5) break checkOverride;
154
			long sourceLevel = compilerOptions.sourceLevel;
155
			if (sourceLevel < ClassFileConstants.JDK1_5) break checkOverride;
155
			int bindingModifiers = this.binding.modifiers;
156
			int bindingModifiers = this.binding.modifiers;
156
			boolean hasOverrideAnnotation = (this.binding.tagBits & TagBits.AnnotationOverride) != 0;
157
			boolean hasOverrideAnnotation = (this.binding.tagBits & TagBits.AnnotationOverride) != 0;
157
			boolean isInterfaceMethod = this.binding.declaringClass.isInterface();
158
			boolean isInterfaceMethod = this.binding.declaringClass.isInterface();
158
			if (hasOverrideAnnotation) {
159
			if (hasOverrideAnnotation) {
159
				if ((bindingModifiers & ExtraCompilerModifiers.AccOverriding) == 0 || isInterfaceMethod || this.binding.isStatic())
160
				// no static method is considered overriding
160
					// claims to override, and doesn't actually do so
161
				if (!isInterfaceMethod && (bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccOverriding)) == ExtraCompilerModifiers.AccOverriding)
161
					this.scope.problemReporter().methodMustOverride(this);					
162
					break checkOverride;
162
			} else if (!isInterfaceMethod 	&& (bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccOverriding)) == ExtraCompilerModifiers.AccOverriding) {
163
				//	in 1.5, strictly for overriding superclass method
164
				//	in 1.6 and above, also tolerate implementing interface method
165
				if (sourceLevel >= ClassFileConstants.JDK1_6
166
						&& ((bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccImplementing)) == ExtraCompilerModifiers.AccImplementing))
167
					break checkOverride;
168
				// claims to override, and doesn't actually do so
169
				this.scope.problemReporter().methodMustOverride(this);					
170
			} else if (!isInterfaceMethod 	
171
						&& (bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccOverriding)) == ExtraCompilerModifiers.AccOverriding) {
163
				// actually overrides, but did not claim to do so
172
				// actually overrides, but did not claim to do so
164
				this.scope.problemReporter().missingOverrideAnnotation(this);
173
				this.scope.problemReporter().missingOverrideAnnotation(this);
165
			}
174
			}
166
		}
175
		}
167
		
176
				
168
		// by grammatical construction, interface methods are always abstract
177
		// by grammatical construction, interface methods are always abstract
169
		switch (TypeDeclaration.kind(this.scope.referenceType().modifiers)) {
178
		switch (TypeDeclaration.kind(this.scope.referenceType().modifiers)) {
170
			case TypeDeclaration.ENUM_DECL :
179
			case TypeDeclaration.ENUM_DECL :
(-)src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java (-136 / +271 lines)
Lines 22-27 Link Here
22
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
22
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
23
import org.eclipse.jdt.core.util.IClassFileReader;
23
import org.eclipse.jdt.core.util.IClassFileReader;
24
import org.eclipse.jdt.core.util.IMethodInfo;
24
import org.eclipse.jdt.core.util.IMethodInfo;
25
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
25
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
26
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
26
27
27
public class MethodVerifyTest extends AbstractComparableTest {
28
public class MethodVerifyTest extends AbstractComparableTest {
Lines 4381-4413 Link Here
4381
4382
4382
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99106
4383
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99106
4383
	public void test062() {
4384
	public void test062() {
4384
		this.runNegativeTest(
4385
		String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
4385
			new String[] {
4386
		?	"----------\n" + 
4386
				"Errors.java",
4387
				"public class Errors {\n" +
4388
				"	void foo() {\n" +
4389
				"		Ex<String> ex = new Ex<String>();\n" +
4390
				"		ex.proof(\"eclipse\");\n" +
4391
				"		ex.five(\"eclipse\");\n" +
4392
				"		ex.six(\"eclipse\");\n" +
4393
				"		Ex ex2 = ex;\n" +
4394
				"		ex2.proof(\"eclipse\");\n" +
4395
				"		ex2.five(\"eclipse\");\n" +
4396
				"		ex2.six(\"eclipse\");\n" +
4397
				"	}\n" +
4398
				"}\n" +
4399
				"class Top<TC> {\n" +
4400
				"	<TM> void proof(Object cTop) {}\n" +
4401
				"	<TM> void five(TC cTop) {}\n" +
4402
				"	void six(TC cTop) {}\n" +
4403
				"}\n" +
4404
				"class Ex<C> extends Top<C> {\n" +
4405
				"	@Override void proof(Object cTop) {}\n" +
4406
				"	@Override void five(C cEx) {}\n" +
4407
				"	@Override <M> void six(C cEx) {}\n" +
4408
				"}"
4409
			},
4410
			"----------\n" + 
4411
			"1. ERROR in Errors.java (at line 6)\n" + 
4387
			"1. ERROR in Errors.java (at line 6)\n" + 
4412
			"	ex.six(\"eclipse\");\n" + 
4388
			"	ex.six(\"eclipse\");\n" + 
4413
			"	   ^^^\n" + 
4389
			"	   ^^^\n" + 
Lines 4438-4443 Link Here
4438
			"	                   ^^^^^^^^^^\n" + 
4414
			"	                   ^^^^^^^^^^\n" + 
4439
			"The method six(C) of type Ex<C> must override a superclass method\n" + 
4415
			"The method six(C) of type Ex<C> must override a superclass method\n" + 
4440
			"----------\n"
4416
			"----------\n"
4417
		:	"----------\n" + 
4418
			"1. ERROR in Errors.java (at line 6)\n" + 
4419
			"	ex.six(\"eclipse\");\n" + 
4420
			"	   ^^^\n" + 
4421
			"The method six(String) is ambiguous for the type Ex<String>\n" + 
4422
			"----------\n" + 
4423
			"2. WARNING in Errors.java (at line 7)\n" + 
4424
			"	Ex ex2 = ex;\n" + 
4425
			"	^^\n" + 
4426
			"Ex is a raw type. References to generic type Ex<C> should be parameterized\n" + 
4427
			"----------\n" + 
4428
			"3. WARNING in Errors.java (at line 9)\n" + 
4429
			"	ex2.five(\"eclipse\");\n" + 
4430
			"	^^^^^^^^^^^^^^^^^^^\n" + 
4431
			"Type safety: The method five(Object) belongs to the raw type Ex. References to generic type Ex<C> should be parameterized\n" + 
4432
			"----------\n" + 
4433
			"4. ERROR in Errors.java (at line 10)\n" + 
4434
			"	ex2.six(\"eclipse\");\n" + 
4435
			"	    ^^^\n" + 
4436
			"The method six(Object) is ambiguous for the type Ex\n" + 
4437
			"----------\n" + 
4438
			"5. ERROR in Errors.java (at line 21)\n" + 
4439
			"	@Override <M> void six(C cEx) {}\n" + 
4440
			"	                   ^^^^^^^^^^\n" + 
4441
			"Name clash: The method six(C) of type Ex<C> has the same erasure as six(TC) of type Top<TC> but does not override it\n" + 
4442
			"----------\n" + 
4443
			"6. ERROR in Errors.java (at line 21)\n" + 
4444
			"	@Override <M> void six(C cEx) {}\n" + 
4445
			"	                   ^^^^^^^^^^\n" + 
4446
			"The method six(C) of type Ex<C> must override or implement a supertype method\n" + 
4447
			"----------\n";		
4448
				this.runNegativeTest(
4449
			new String[] {
4450
				"Errors.java",
4451
				"public class Errors {\n" +
4452
				"	void foo() {\n" +
4453
				"		Ex<String> ex = new Ex<String>();\n" +
4454
				"		ex.proof(\"eclipse\");\n" +
4455
				"		ex.five(\"eclipse\");\n" +
4456
				"		ex.six(\"eclipse\");\n" +
4457
				"		Ex ex2 = ex;\n" +
4458
				"		ex2.proof(\"eclipse\");\n" +
4459
				"		ex2.five(\"eclipse\");\n" +
4460
				"		ex2.six(\"eclipse\");\n" +
4461
				"	}\n" +
4462
				"}\n" +
4463
				"class Top<TC> {\n" +
4464
				"	<TM> void proof(Object cTop) {}\n" +
4465
				"	<TM> void five(TC cTop) {}\n" +
4466
				"	void six(TC cTop) {}\n" +
4467
				"}\n" +
4468
				"class Ex<C> extends Top<C> {\n" +
4469
				"	@Override void proof(Object cTop) {}\n" +
4470
				"	@Override void five(C cEx) {}\n" +
4471
				"	@Override <M> void six(C cEx) {}\n" +
4472
				"}"
4473
			},
4474
			expectedOutput
4441
			// we disagree about the ambiguous errors on lines 5, 9 & 20, see the message sends to proof()
4475
			// we disagree about the ambiguous errors on lines 5, 9 & 20, see the message sends to proof()
4442
			// 5: reference to five is ambiguous, both method <TM>five(TC) in Top<java.lang.String> and method five(C) in Ex<java.lang.String> match
4476
			// 5: reference to five is ambiguous, both method <TM>five(TC) in Top<java.lang.String> and method five(C) in Ex<java.lang.String> match
4443
			// 6: reference to six is ambiguous, both method six(TC) in Top<java.lang.String> and method <M>six(C) in Ex<java.lang.String> match
4477
			// 6: reference to six is ambiguous, both method six(TC) in Top<java.lang.String> and method <M>six(C) in Ex<java.lang.String> match
Lines 4665-4681 Link Here
4665
	}
4699
	}
4666
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=107045
4700
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=107045
4667
	public void test071() {
4701
	public void test071() {
4668
		this.runNegativeTest(
4702
		String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
4669
			new String[] {
4703
		?	"----------\n" + 
4670
				"D.java",
4671
				"class D extends B<Integer> {\n" +
4672
				"	@Override void m(Number t) {}\n" + 
4673
				"	@Override void m(Integer t) {}\n" + 
4674
				"}\n" + 
4675
				"class A<T extends Number> { void m(T t) {} }\n" +
4676
				"class B<S extends Integer> extends A<S> { @Override void m(S t) {} }"
4677
			},
4678
			"----------\n" + 
4679
			"1. ERROR in D.java (at line 2)\r\n" + 
4704
			"1. ERROR in D.java (at line 2)\r\n" + 
4680
			"	@Override void m(Number t) {}\r\n" + 
4705
			"	@Override void m(Number t) {}\r\n" + 
4681
			"	               ^^^^^^^^^^^\n" + 
4706
			"	               ^^^^^^^^^^^\n" + 
Lines 4691-4697 Link Here
4691
			"	                  ^^^^^^^\n" + 
4716
			"	                  ^^^^^^^\n" + 
4692
			"The type parameter S should not be bounded by the final type Integer. Final types cannot be further extended\n" + 
4717
			"The type parameter S should not be bounded by the final type Integer. Final types cannot be further extended\n" + 
4693
			"----------\n"
4718
			"----------\n"
4694
		);
4719
		:	"----------\n" + 
4720
			"1. ERROR in D.java (at line 2)\n" + 
4721
			"	@Override void m(Number t) {}\n" + 
4722
			"	               ^^^^^^^^^^^\n" + 
4723
			"Name clash: The method m(Number) of type D has the same erasure as m(T) of type A<T> but does not override it\n" + 
4724
			"----------\n" + 
4725
			"2. ERROR in D.java (at line 2)\n" + 
4726
			"	@Override void m(Number t) {}\n" + 
4727
			"	               ^^^^^^^^^^^\n" + 
4728
			"The method m(Number) of type D must override or implement a supertype method\n" + 
4729
			"----------\n" + 
4730
			"3. WARNING in D.java (at line 6)\n" + 
4731
			"	class B<S extends Integer> extends A<S> { @Override void m(S t) {} }\n" + 
4732
			"	                  ^^^^^^^\n" + 
4733
			"The type parameter S should not be bounded by the final type Integer. Final types cannot be further extended\n" + 
4734
			"----------\n";
4735
		this.runNegativeTest(
4736
			new String[] {
4737
				"D.java",
4738
				"class D extends B<Integer> {\n" +
4739
				"	@Override void m(Number t) {}\n" + 
4740
				"	@Override void m(Integer t) {}\n" + 
4741
				"}\n" + 
4742
				"class A<T extends Number> { void m(T t) {} }\n" +
4743
				"class B<S extends Integer> extends A<S> { @Override void m(S t) {} }"
4744
			},
4745
			expectedOutput);
4695
	}
4746
	}
4696
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=108780
4747
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=108780
4697
	public void test072() {
4748
	public void test072() {
Lines 4756-4761 Link Here
4756
	}
4807
	}
4757
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111350
4808
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111350
4758
	public void test073c() {
4809
	public void test073c() {
4810
		String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
4811
		?	"----------\n" + 
4812
			"1. ERROR in NumericArray4.java (at line 5)\r\n" + 
4813
			"	@Override public <U> void add(Number n) {}\r\n" + 
4814
			"	                          ^^^^^^^^^^^^^\n" + 
4815
			"The method add(Number) of type NumericArray4<T> must override a superclass method\n" + 
4816
			"----------\n"
4817
		:	"----------\n" + 
4818
			"1. ERROR in NumericArray4.java (at line 5)\n" + 
4819
			"	@Override public <U> void add(Number n) {}\n" + 
4820
			"	                          ^^^^^^^^^^^^^\n" + 
4821
			"The method add(Number) of type NumericArray4<T> must override or implement a supertype method\n" + 
4822
			"----------\n";
4759
		this.runNegativeTest(
4823
		this.runNegativeTest(
4760
			new String[] {
4824
			new String[] {
4761
				"NumericArray4.java",
4825
				"NumericArray4.java",
Lines 4766-4781 Link Here
4766
				"	@Override public <U> void add(Number n) {}\n" +
4830
				"	@Override public <U> void add(Number n) {}\n" +
4767
				"}"
4831
				"}"
4768
			},
4832
			},
4769
			"----------\n" + 
4833
			expectedOutput);
4770
			"1. ERROR in NumericArray4.java (at line 5)\r\n" + 
4771
			"	@Override public <U> void add(Number n) {}\r\n" + 
4772
			"	                          ^^^^^^^^^^^^^\n" + 
4773
			"The method add(Number) of type NumericArray4<T> must override a superclass method\n" + 
4774
			"----------\n"
4775
		);
4776
	}
4834
	}
4777
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111350
4835
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111350
4778
	public void test073d() {
4836
	public void test073d() {
4837
		String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
4838
		?	"----------\n" + 
4839
			"1. ERROR in NumericArray5.java (at line 5)\r\n" + 
4840
			"	@Override public void add(Number n, Integer i) {}\r\n" + 
4841
			"	                      ^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
4842
			"The method add(Number, Integer) of type NumericArray5<T> must override a superclass method\n" + 
4843
			"----------\n"
4844
		:	"----------\n" + 
4845
			"1. ERROR in NumericArray5.java (at line 5)\n" + 
4846
			"	@Override public void add(Number n, Integer i) {}\n" + 
4847
			"	                      ^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
4848
			"The method add(Number, Integer) of type NumericArray5<T> must override or implement a supertype method\n" + 
4849
			"----------\n";		
4779
		this.runNegativeTest(
4850
		this.runNegativeTest(
4780
			new String[] {
4851
			new String[] {
4781
				"NumericArray5.java",
4852
				"NumericArray5.java",
Lines 4786-4808 Link Here
4786
				"	@Override public void add(Number n, Integer i) {}\n" +
4857
				"	@Override public void add(Number n, Integer i) {}\n" +
4787
				"}"
4858
				"}"
4788
			},
4859
			},
4789
			"----------\n" + 
4860
			expectedOutput);
4790
			"1. ERROR in NumericArray5.java (at line 5)\r\n" + 
4791
			"	@Override public void add(Number n, Integer i) {}\r\n" + 
4792
			"	                      ^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
4793
			"The method add(Number, Integer) of type NumericArray5<T> must override a superclass method\n" + 
4794
			"----------\n"
4795
		);
4796
	}
4861
	}
4797
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100970
4862
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100970
4798
	public void test074() {
4863
	public void test074() {
4799
		this.runNegativeTest(
4864
		String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
4800
			new String[] {
4865
		?	"----------\n" + 
4801
				"I.java",
4802
				"interface I {}\n" +
4803
				"interface J extends I { @Override void clone(); }"
4804
			},
4805
			"----------\n" + 
4806
			"1. WARNING in I.java (at line 2)\n" + 
4866
			"1. WARNING in I.java (at line 2)\n" + 
4807
			"	interface J extends I { @Override void clone(); }\n" + 
4867
			"	interface J extends I { @Override void clone(); }\n" + 
4808
			"	                                       ^^^^^^^\n" + 
4868
			"	                                       ^^^^^^^\n" + 
Lines 4813-4829 Link Here
4813
			"	                                       ^^^^^^^\n" + 
4873
			"	                                       ^^^^^^^\n" + 
4814
			"The method clone() of type J must override a superclass method\n" + 
4874
			"The method clone() of type J must override a superclass method\n" + 
4815
			"----------\n"
4875
			"----------\n"
4816
		);
4876
		:	"----------\n" + 
4817
	}
4877
			"1. WARNING in I.java (at line 2)\n" + 
4818
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100970
4878
			"	interface J extends I { @Override void clone(); }\n" + 
4819
	public void test074a() {
4879
			"	                                       ^^^^^^^\n" + 
4880
			"The return type is incompatible with Object.clone(), thus this interface cannot be implemented\n" + 
4881
			"----------\n" + 
4882
			"2. ERROR in I.java (at line 2)\n" + 
4883
			"	interface J extends I { @Override void clone(); }\n" + 
4884
			"	                                       ^^^^^^^\n" + 
4885
			"The method clone() of type J must override or implement a supertype method\n" + 
4886
			"----------\n";		
4820
		this.runNegativeTest(
4887
		this.runNegativeTest(
4821
			new String[] {
4888
			new String[] {
4822
				"I.java",
4889
				"I.java",
4823
				"interface I { @Override void clone(); }\n" +
4890
				"interface I {}\n" +
4824
				"interface J extends I {}"
4891
				"interface J extends I { @Override void clone(); }"
4825
			},
4892
			},
4826
			"----------\n" + 
4893
			expectedOutput);
4894
	}
4895
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100970
4896
	public void test074a() {
4897
		String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
4898
		?	"----------\n" + 
4827
			"1. WARNING in I.java (at line 1)\n" + 
4899
			"1. WARNING in I.java (at line 1)\n" + 
4828
			"	interface I { @Override void clone(); }\n" + 
4900
			"	interface I { @Override void clone(); }\n" + 
4829
			"	                             ^^^^^^^\n" + 
4901
			"	                             ^^^^^^^\n" + 
Lines 4834-4840 Link Here
4834
			"	                             ^^^^^^^\n" + 
4906
			"	                             ^^^^^^^\n" + 
4835
			"The method clone() of type I must override a superclass method\n" + 
4907
			"The method clone() of type I must override a superclass method\n" + 
4836
			"----------\n"
4908
			"----------\n"
4837
		);
4909
		:	"----------\n" + 
4910
			"1. WARNING in I.java (at line 1)\n" + 
4911
			"	interface I { @Override void clone(); }\n" + 
4912
			"	                             ^^^^^^^\n" + 
4913
			"The return type is incompatible with Object.clone(), thus this interface cannot be implemented\n" + 
4914
			"----------\n" + 
4915
			"2. ERROR in I.java (at line 1)\n" + 
4916
			"	interface I { @Override void clone(); }\n" + 
4917
			"	                             ^^^^^^^\n" + 
4918
			"The method clone() of type I must override or implement a supertype method\n" + 
4919
			"----------\n";		
4920
		this.runNegativeTest(
4921
			new String[] {
4922
				"I.java",
4923
				"interface I { @Override void clone(); }\n" +
4924
				"interface J extends I {}"
4925
			},
4926
			expectedOutput);
4838
	}
4927
	}
4839
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100970
4928
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100970
4840
	public void test074b() {
4929
	public void test074b() {
Lines 4873-4878 Link Here
4873
	}
4962
	}
4874
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=107105
4963
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=107105
4875
	public void test075() {
4964
	public void test075() {
4965
		String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
4966
			?	"----------\n" + 
4967
				"1. ERROR in A.java (at line 2)\n" + 
4968
				"	class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + 
4969
				"	                                                              ^^^^^\n" + 
4970
				"Name clash: The method foo() of type B has the same erasure as foo() of type A but does not override it\n" + 
4971
				"----------\n" + 
4972
				"2. ERROR in A.java (at line 2)\n" + 
4973
				"	class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + 
4974
				"	                                                              ^^^^^\n" + 
4975
				"The method foo() of type B must override a superclass method\n" + 
4976
				"----------\n" + 
4977
				"3. WARNING in A.java (at line 3)\n" + 
4978
				"	class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + 
4979
				"	                                                  ^\n" + 
4980
				"I is a raw type. References to generic type I<TT> should be parameterized\n" + 
4981
				"----------\n" + 
4982
				"4. ERROR in A.java (at line 3)\n" + 
4983
				"	class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + 
4984
				"	                                                          ^^^^^\n" + 
4985
				"Name clash: The method foo() of type C has the same erasure as foo() of type A but does not override it\n" + 
4986
				"----------\n" + 
4987
				"5. ERROR in A.java (at line 3)\n" + 
4988
				"	class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + 
4989
				"	                                                          ^^^^^\n" + 
4990
				"The method foo() of type C must override a superclass method\n" + 
4991
				"----------\n"
4992
			:	"----------\n" + 
4993
				"1. ERROR in A.java (at line 2)\n" + 
4994
				"	class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + 
4995
				"	                                                              ^^^^^\n" + 
4996
				"Name clash: The method foo() of type B has the same erasure as foo() of type A but does not override it\n" + 
4997
				"----------\n" + 
4998
				"2. ERROR in A.java (at line 2)\n" + 
4999
				"	class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + 
5000
				"	                                                              ^^^^^\n" + 
5001
				"The method foo() of type B must override or implement a supertype method\n" + 
5002
				"----------\n" + 
5003
				"3. WARNING in A.java (at line 3)\n" + 
5004
				"	class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + 
5005
				"	                                                  ^\n" + 
5006
				"I is a raw type. References to generic type I<TT> should be parameterized\n" + 
5007
				"----------\n" + 
5008
				"4. ERROR in A.java (at line 3)\n" + 
5009
				"	class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + 
5010
				"	                                                          ^^^^^\n" + 
5011
				"Name clash: The method foo() of type C has the same erasure as foo() of type A but does not override it\n" + 
5012
				"----------\n" + 
5013
				"5. ERROR in A.java (at line 3)\n" + 
5014
				"	class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + 
5015
				"	                                                          ^^^^^\n" + 
5016
				"The method foo() of type C must override or implement a supertype method\n" + 
5017
				"----------\n";		
4876
		this.runNegativeTest(
5018
		this.runNegativeTest(
4877
			new String[] {
5019
			new String[] {
4878
				"A.java",
5020
				"A.java",
Lines 4884-4915 Link Here
4884
				"interface I<TT> {}\n" +
5026
				"interface I<TT> {}\n" +
4885
				"interface J {}"
5027
				"interface J {}"
4886
			},
5028
			},
4887
			"----------\n" + 
5029
			expectedOutput
4888
			"1. ERROR in A.java (at line 2)\n" + 
4889
			"	class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + 
4890
			"	                                                              ^^^^^\n" + 
4891
			"Name clash: The method foo() of type B has the same erasure as foo() of type A but does not override it\n" + 
4892
			"----------\n" + 
4893
			"2. ERROR in A.java (at line 2)\n" + 
4894
			"	class B extends A { @Override <T1, S1 extends J & I<S1>> void foo() { } }\n" + 
4895
			"	                                                              ^^^^^\n" + 
4896
			"The method foo() of type B must override a superclass method\n" + 
4897
			"----------\n" + 
4898
			"3. WARNING in A.java (at line 3)\n" + 
4899
			"	class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + 
4900
			"	                                                  ^\n" + 
4901
			"I is a raw type. References to generic type I<TT> should be parameterized\n" + 
4902
			"----------\n" + 
4903
			"4. ERROR in A.java (at line 3)\n" + 
4904
			"	class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + 
4905
			"	                                                          ^^^^^\n" + 
4906
			"Name clash: The method foo() of type C has the same erasure as foo() of type A but does not override it\n" + 
4907
			"----------\n" + 
4908
			"5. ERROR in A.java (at line 3)\n" + 
4909
			"	class C extends A { @Override <T2, S2 extends J & I> void foo() { } }\n" + 
4910
			"	                                                          ^^^^^\n" + 
4911
			"The method foo() of type C must override a superclass method\n" + 
4912
			"----------\n"
4913
			// A.java:2: method does not override a method from its superclass
5030
			// A.java:2: method does not override a method from its superclass
4914
			// A.java:3: method does not override a method from its superclass
5031
			// A.java:3: method does not override a method from its superclass
4915
		);
5032
		);
Lines 4930-4935 Link Here
4930
	}
5047
	}
4931
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=107105
5048
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=107105
4932
	public void test075b() {
5049
	public void test075b() {
5050
		String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
5051
		?	"----------\n" + 
5052
			"1. ERROR in A.java (at line 2)\r\n" + 
5053
			"	class B<V> extends A<V> { @Override <T1, S1 extends K & I<T1>> void foo(V v, T1 t, S1 s) { } }\r\n" + 
5054
			"	                                                                    ^^^^^^^^^^^^^^^^^^^^\n" + 
5055
			"The method foo(V, T1, S1) of type B<V> must override a superclass method\n" + 
5056
			"----------\n"
5057
		:	"----------\n" + 
5058
			"1. ERROR in A.java (at line 2)\n" + 
5059
			"	class B<V> extends A<V> { @Override <T1, S1 extends K & I<T1>> void foo(V v, T1 t, S1 s) { } }\n" + 
5060
			"	                                                                    ^^^^^^^^^^^^^^^^^^^^\n" + 
5061
			"The method foo(V, T1, S1) of type B<V> must override or implement a supertype method\n" + 
5062
			"----------\n";				
4933
		this.runNegativeTest(
5063
		this.runNegativeTest(
4934
			new String[] {
5064
			new String[] {
4935
				"A.java",
5065
				"A.java",
Lines 4939-4950 Link Here
4939
				"interface J {}\n" +
5069
				"interface J {}\n" +
4940
				"interface K extends J {}"
5070
				"interface K extends J {}"
4941
			},
5071
			},
4942
			"----------\n" + 
5072
			expectedOutput
4943
			"1. ERROR in A.java (at line 2)\r\n" + 
4944
			"	class B<V> extends A<V> { @Override <T1, S1 extends K & I<T1>> void foo(V v, T1 t, S1 s) { } }\r\n" + 
4945
			"	                                                                    ^^^^^^^^^^^^^^^^^^^^\n" + 
4946
			"The method foo(V, T1, S1) of type B<V> must override a superclass method\n" + 
4947
			"----------\n"
4948
			// A.java:2: method does not override a method from its superclass
5073
			// A.java:2: method does not override a method from its superclass
4949
		);
5074
		);
4950
	}
5075
	}
Lines 7069-7110 Link Here
7069
}
7194
}
7070
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
7195
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
7071
public void test116() {
7196
public void test116() {
7072
	if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) {
7197
   	Map options = this.getCompilerOptions();
7073
    	Map options = this.getCompilerOptions();
7198
   	options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR);
7074
    	options.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.ERROR);
7199
	String expectedOutput = new CompilerOptions(options).sourceLevel < ClassFileConstants.JDK1_6
7075
    	this.runNegativeTest(
7200
	?	"----------\n" + 
7076
    		new String[] {
7201
		"1. ERROR in X.java (at line 2)\n" + 
7077
    			"X.java",
7202
		"	Zork foo() {}\n" + 
7078
    			"class Y {\n" + 
7203
		"	^^^^\n" + 
7079
    			"  Zork foo() {}\n" + 
7204
		"Zork cannot be resolved to a type\n" + 
7080
    			"}\n" + 
7205
		"----------\n" + 
7081
    			"public class X extends Y {\n" + 
7206
		"2. ERROR in X.java (at line 6)\n" + 
7082
    			"  @Override\n" +
7207
		"	Object foo() {\n" + 
7083
    			"  Object foo() {\n" +
7208
		"	       ^^^^^\n" + 
7084
    			"     return new Y() {\n" +
7209
		"The method foo() of type X must override a superclass method\n" + 
7085
    			"         Object foo() {\n" +
7210
		"----------\n"
7086
    			"            return null;\n" +
7211
	:	"----------\n" + 
7087
    			"         }\n" +
7212
		"1. ERROR in X.java (at line 2)\n" + 
7088
    			"     };" +
7213
		"	Zork foo() {}\n" + 
7089
    			"  }\n" + 
7214
		"	^^^^\n" + 
7090
    			"}"
7215
		"Zork cannot be resolved to a type\n" + 
7091
    		},
7216
		"----------\n" + 
7092
    		"----------\n" + 
7217
		"2. ERROR in X.java (at line 6)\n" + 
7093
    		"1. ERROR in X.java (at line 2)\n" + 
7218
		"	Object foo() {\n" + 
7094
    		"	Zork foo() {}\n" + 
7219
		"	       ^^^^^\n" + 
7095
    		"	^^^^\n" + 
7220
		"The method foo() of type X must override or implement a supertype method\n" + 
7096
    		"Zork cannot be resolved to a type\n" + 
7221
		"----------\n";	
7097
    		"----------\n" + 
7222
   	this.runNegativeTest(
7098
    		"2. ERROR in X.java (at line 6)\n" + 
7223
		new String[] {
7099
    		"	Object foo() {\n" + 
7224
			"X.java",
7100
    		"	       ^^^^^\n" + 
7225
			"class Y {\n" + 
7101
    		"The method foo() of type X must override a superclass method\n" + 
7226
			"  Zork foo() {}\n" + 
7102
    		"----------\n",
7227
			"}\n" + 
7103
    		null,
7228
			"public class X extends Y {\n" + 
7104
    		true,
7229
			"  @Override\n" +
7105
    		options
7230
			"  Object foo() {\n" +
7106
    	);
7231
			"     return new Y() {\n" +
7107
	}
7232
			"         Object foo() {\n" +
7233
			"            return null;\n" +
7234
			"         }\n" +
7235
			"     };" +
7236
			"  }\n" + 
7237
			"}"
7238
		},
7239
		expectedOutput,
7240
		null,
7241
		true,
7242
		options	);
7108
}
7243
}
7109
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
7244
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156736
7110
public void test117() {
7245
public void test117() {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (-17 / +31 lines)
Lines 20-25 Link Here
20
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
20
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
21
import org.eclipse.jdt.core.tests.util.Util;
21
import org.eclipse.jdt.core.tests.util.Util;
22
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
22
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
23
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
23
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
24
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
24
25
25
public class GenericTypeTest extends AbstractComparableTest {
26
public class GenericTypeTest extends AbstractComparableTest {
Lines 32-38 Link Here
32
	// All specified tests which does not belong to the class are skipped...
33
	// All specified tests which does not belong to the class are skipped...
33
	static {
34
	static {
34
//		TESTS_NAMES = new String[] { "test0788" };
35
//		TESTS_NAMES = new String[] { "test0788" };
35
		TESTS_NUMBERS = new int[] { 1050, 1054 };
36
//		TESTS_NUMBERS = new int[] { 1050, 1054 };
36
//		TESTS_RANGE = new int[] { 821, -1 };
37
//		TESTS_RANGE = new int[] { 821, -1 };
37
	}
38
	}
38
	public static Test suite() {
39
	public static Test suite() {
Lines 31228-31233 Link Here
31228
}
31229
}
31229
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140643
31230
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140643
31230
public void test0987() {
31231
public void test0987() {
31232
	String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
31233
	?	"----------\n" + 
31234
		"1. ERROR in X.java (at line 7)\n" + 
31235
		"	abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" + 
31236
		"	               ^^^^^^^^^^^^^^^^\n" + 
31237
		"The return type is incompatible with EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" + 
31238
		"----------\n" + 
31239
		"2. ERROR in X.java (at line 11)\n" + 
31240
		"	public ISheetViewer getViewer() { return null; }	\n" + 
31241
		"	                    ^^^^^^^^^^^\n" + 
31242
		"The return type is incompatible with EditPart.getViewer()\n" + 
31243
		"----------\n" + 
31244
		"3. ERROR in X.java (at line 11)\n" + 
31245
		"	public ISheetViewer getViewer() { return null; }	\n" + 
31246
		"	                    ^^^^^^^^^^^\n" + 
31247
		"The method getViewer() of type AbstractLinkView<M> must override a superclass method\n" + 
31248
		"----------\n"
31249
	:	"----------\n" + 
31250
		"1. ERROR in X.java (at line 7)\n" + 
31251
		"	abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" + 
31252
		"	               ^^^^^^^^^^^^^^^^\n" + 
31253
		"The return type is incompatible with EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" + 
31254
		"----------\n" + 
31255
		"2. ERROR in X.java (at line 11)\n" + 
31256
		"	public ISheetViewer getViewer() { return null; }	\n" + 
31257
		"	                    ^^^^^^^^^^^\n" + 
31258
		"The return type is incompatible with EditPart.getViewer()\n" + 
31259
		"----------\n";	
31231
	this.runNegativeTest(
31260
	this.runNegativeTest(
31232
			new String[] {
31261
			new String[] {
31233
				"X.java",//===================
31262
				"X.java",//===================
Lines 31262-31283 Link Here
31262
				"\n" + 
31291
				"\n" + 
31263
				"interface EditPartViewer {}\n", // =================			
31292
				"interface EditPartViewer {}\n", // =================			
31264
			},
31293
			},
31265
			"----------\n" + 
31294
			expectedOutput);
31266
			"1. ERROR in X.java (at line 7)\n" + 
31267
			"	abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" + 
31268
			"	               ^^^^^^^^^^^^^^^^\n" + 
31269
			"The return type is incompatible with EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" + 
31270
			"----------\n" + 
31271
			"2. ERROR in X.java (at line 11)\n" + 
31272
			"	public ISheetViewer getViewer() { return null; }	\n" + 
31273
			"	                    ^^^^^^^^^^^\n" + 
31274
			"The return type is incompatible with EditPart.getViewer()\n" + 
31275
			"----------\n" + 
31276
			"3. ERROR in X.java (at line 11)\n" + 
31277
			"	public ISheetViewer getViewer() { return null; }	\n" + 
31278
			"	                    ^^^^^^^^^^^\n" + 
31279
			"The method getViewer() of type AbstractLinkView<M> must override a superclass method\n" + 
31280
			"----------\n");
31281
}
31295
}
31282
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140643 - variation
31296
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140643 - variation
31283
public void test0988() {
31297
public void test0988() {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java (-51 / +146 lines)
Lines 2437-2442 Link Here
2437
	}	
2437
	}	
2438
	// check @Override annotation - strictly for superclasses (overrides) and not interfaces (implements)
2438
	// check @Override annotation - strictly for superclasses (overrides) and not interfaces (implements)
2439
	public void test077() {
2439
	public void test077() {
2440
		String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
2441
			?	"----------\n" + 
2442
				"1. ERROR in X.java (at line 14)\n" + 
2443
				"	void foo() {}\n" + 
2444
				"	     ^^^^^\n" + 
2445
				"The method foo() of type X must override a superclass method\n" + 
2446
				"----------\n" + 
2447
				"2. ERROR in X.java (at line 18)\n" + 
2448
				"	public void baz() {}\n" + 
2449
				"	            ^^^^^\n" + 
2450
				"The method baz() of type X must override a superclass method\n" + 
2451
				"----------\n"
2452
			:	"----------\n" + 
2453
				"1. ERROR in X.java (at line 14)\n" + 
2454
				"	void foo() {}\n" + 
2455
				"	     ^^^^^\n" + 
2456
				"The method foo() of type X must override or implement a supertype method\n" + 
2457
				"----------\n";
2440
		this.runNegativeTest(
2458
		this.runNegativeTest(
2441
			new String[] {
2459
			new String[] {
2442
				"X.java",
2460
				"X.java",
Lines 2460-2476 Link Here
2460
				"	public void baz() {}\n" + 
2478
				"	public void baz() {}\n" + 
2461
				"}\n"
2479
				"}\n"
2462
			},
2480
			},
2463
			"----------\n" + 
2481
			expectedOutput);
2464
			"1. ERROR in X.java (at line 14)\n" + 
2465
			"	void foo() {}\n" + 
2466
			"	     ^^^^^\n" + 
2467
			"The method foo() of type X must override a superclass method\n" + 
2468
			"----------\n" + 
2469
			"2. ERROR in X.java (at line 18)\n" + 
2470
			"	public void baz() {}\n" + 
2471
			"	            ^^^^^\n" + 
2472
			"The method baz() of type X must override a superclass method\n" + 
2473
			"----------\n");
2474
	}
2482
	}
2475
	
2483
	
2476
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=80114
2484
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=80114
Lines 4488-4493 Link Here
4488
    }          
4496
    }          
4489
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90111 - variation
4497
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90111 - variation
4490
    public void test140() {
4498
    public void test140() {
4499
    	String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
4500
		?	"----------\n" + 
4501
    		"1. ERROR in X.java (at line 6)\r\n" + 
4502
    		"	static void foo(){}	\r\n" + 
4503
    		"	            ^^^^^\n" + 
4504
    		"The method foo() of type Bar must override a superclass method\n" + 
4505
    		"----------\n"
4506
		:	"----------\n" + 
4507
			"1. ERROR in X.java (at line 6)\n" + 
4508
			"	static void foo(){}	\n" + 
4509
			"	            ^^^^^\n" + 
4510
			"The method foo() of type Bar must override or implement a supertype method\n" + 
4511
			"----------\n";    	
4491
        this.runNegativeTest(
4512
        this.runNegativeTest(
4492
            new String[] {
4513
            new String[] {
4493
                "X.java",
4514
                "X.java",
Lines 4500-4511 Link Here
4500
				"}\n" + 
4521
				"}\n" + 
4501
				"\n"
4522
				"\n"
4502
            },
4523
            },
4503
    		"----------\n" + 
4524
            expectedOutput);
4504
    		"1. ERROR in X.java (at line 6)\r\n" + 
4505
    		"	static void foo(){}	\r\n" + 
4506
    		"	            ^^^^^\n" + 
4507
    		"The method foo() of type Bar must override a superclass method\n" + 
4508
    		"----------\n");
4509
    }              
4525
    }              
4510
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94867
4526
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94867
4511
    public void test141() {
4527
    public void test141() {
Lines 5611-5617 Link Here
5611
    }
5627
    }
5612
    //https://bugs.eclipse.org/bugs/show_bug.cgi?id=94759
5628
    //https://bugs.eclipse.org/bugs/show_bug.cgi?id=94759
5613
    public void test168() {
5629
    public void test168() {
5614
        this.runNegativeTest(
5630
    	String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
5631
			?	"----------\n" + 
5632
				"1. ERROR in X.java (at line 2)\n" + 
5633
				"	@Override I clone();\n" + 
5634
				"	            ^^^^^^^\n" + 
5635
				"The method clone() of type I must override a superclass method\n" + 
5636
				"----------\n" + 
5637
				"2. ERROR in X.java (at line 7)\n" + 
5638
				"	@Override void foo();\n" + 
5639
				"	               ^^^^^\n" + 
5640
				"The method foo() of type J must override a superclass method\n" + 
5641
				"----------\n"
5642
			:	"----------\n" + 
5643
				"1. ERROR in X.java (at line 2)\n" + 
5644
				"	@Override I clone();\n" + 
5645
				"	            ^^^^^^^\n" + 
5646
				"The method clone() of type I must override or implement a supertype method\n" + 
5647
				"----------\n";
5648
    	this.runNegativeTest(
5615
            new String[] {
5649
            new String[] {
5616
                "X.java",
5650
                "X.java",
5617
				"interface I {\n" + 
5651
				"interface I {\n" + 
Lines 5623-5639 Link Here
5623
				"	@Override void foo();\n" + 
5657
				"	@Override void foo();\n" + 
5624
				"}\n",
5658
				"}\n",
5625
           },
5659
           },
5626
		"----------\n" + 
5660
           expectedOutput);
5627
		"1. ERROR in X.java (at line 2)\n" + 
5628
		"	@Override I clone();\n" + 
5629
		"	            ^^^^^^^\n" + 
5630
		"The method clone() of type I must override a superclass method\n" + 
5631
		"----------\n" + 
5632
		"2. ERROR in X.java (at line 7)\n" + 
5633
		"	@Override void foo();\n" + 
5634
		"	               ^^^^^\n" + 
5635
		"The method foo() of type J must override a superclass method\n" + 
5636
		"----------\n");
5637
    }
5661
    }
5638
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=97220
5662
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=97220
5639
    public void test169() {
5663
    public void test169() {
Lines 6417-6422 Link Here
6417
}
6441
}
6418
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130017
6442
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130017
6419
public void test194() {
6443
public void test194() {
6444
	String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
6445
	?	"----------\n" + 
6446
		"1. ERROR in X.java (at line 5)\n" + 
6447
		"	@Override\n" + 
6448
		"	^^^^^^^^^\n" + 
6449
		"The annotation @Override is disallowed for this location\n" + 
6450
		"----------\n" + 
6451
		"2. ERROR in X.java (at line 9)\n" + 
6452
		"	public static void foo() {}\n" + 
6453
		"	                   ^^^^^\n" + 
6454
		"The method foo() of type X must override a superclass method\n" + 
6455
		"----------\n"
6456
	:	"----------\n" + 
6457
		"1. ERROR in X.java (at line 5)\n" + 
6458
		"	@Override\n" + 
6459
		"	^^^^^^^^^\n" + 
6460
		"The annotation @Override is disallowed for this location\n" + 
6461
		"----------\n" + 
6462
		"2. ERROR in X.java (at line 9)\n" + 
6463
		"	public static void foo() {}\n" + 
6464
		"	                   ^^^^^\n" + 
6465
		"The method foo() of type X must override or implement a supertype method\n" + 
6466
		"----------\n";	
6420
	this.runNegativeTest(
6467
	this.runNegativeTest(
6421
		new String[] {
6468
		new String[] {
6422
			"X.java",
6469
			"X.java",
Lines 6431-6447 Link Here
6431
			"    public static void foo() {}\n" + 
6478
			"    public static void foo() {}\n" + 
6432
			"}\n"
6479
			"}\n"
6433
		},
6480
		},
6434
		"----------\n" + 
6481
		expectedOutput);
6435
		"1. ERROR in X.java (at line 5)\n" + 
6436
		"	@Override\n" + 
6437
		"	^^^^^^^^^\n" + 
6438
		"The annotation @Override is disallowed for this location\n" + 
6439
		"----------\n" + 
6440
		"2. ERROR in X.java (at line 9)\n" + 
6441
		"	public static void foo() {}\n" + 
6442
		"	                   ^^^^^\n" + 
6443
		"The method foo() of type X must override a superclass method\n" + 
6444
		"----------\n");
6445
}
6482
}
6446
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130516
6483
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130516
6447
public void test195() {
6484
public void test195() {
Lines 6492-6497 Link Here
6492
}
6529
}
6493
// no override between package private methods
6530
// no override between package private methods
6494
public void test197() {
6531
public void test197() {
6532
	String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
6533
	?	"----------\n" + 
6534
		"1. WARNING in p\\X.java (at line 4)\n" + 
6535
		"	void foo() {\n" + 
6536
		"	     ^^^^^\n" + 
6537
		"The method X.foo() does not override the inherited method from OldStuff since it is private to a different package\n" + 
6538
		"----------\n" + 
6539
		"2. ERROR in p\\X.java (at line 4)\n" + 
6540
		"	void foo() {\n" + 
6541
		"	     ^^^^^\n" + 
6542
		"The method foo() of type X must override a superclass method\n" + 
6543
		"----------\n"
6544
	:	"----------\n" + 
6545
		"1. WARNING in p\\X.java (at line 4)\n" + 
6546
		"	void foo() {\n" + 
6547
		"	     ^^^^^\n" + 
6548
		"The method X.foo() does not override the inherited method from OldStuff since it is private to a different package\n" + 
6549
		"----------\n" + 
6550
		"2. ERROR in p\\X.java (at line 4)\n" + 
6551
		"	void foo() {\n" + 
6552
		"	     ^^^^^\n" + 
6553
		"The method foo() of type X must override or implement a supertype method\n" + 
6554
		"----------\n";		
6495
    this.runNegativeTest(
6555
    this.runNegativeTest(
6496
        new String[] {
6556
        new String[] {
6497
            "p/X.java",
6557
            "p/X.java",
Lines 6508-6524 Link Here
6508
			"	}	\n" + 
6568
			"	}	\n" + 
6509
			"}\n",
6569
			"}\n",
6510
        },
6570
        },
6511
		"----------\n" + 
6571
        expectedOutput);
6512
		"1. WARNING in p\\X.java (at line 4)\n" + 
6513
		"	void foo() {\n" + 
6514
		"	     ^^^^^\n" + 
6515
		"The method X.foo() does not override the inherited method from OldStuff since it is private to a different package\n" + 
6516
		"----------\n" + 
6517
		"2. ERROR in p\\X.java (at line 4)\n" + 
6518
		"	void foo() {\n" + 
6519
		"	     ^^^^^\n" + 
6520
		"The method foo() of type X must override a superclass method\n" + 
6521
		"----------\n");
6522
}    
6572
}    
6523
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=134129
6573
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=134129
6524
public void test198() {
6574
public void test198() {
Lines 7005-7008 Link Here
7005
		"The value for annotation attribute MyAnnotation.values must be an array initializer\n" + 
7055
		"The value for annotation attribute MyAnnotation.values must be an array initializer\n" + 
7006
		"----------\n");
7056
		"----------\n");
7007
}
7057
}
7058
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=141931
7059
public void test214() {
7060
	String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
7061
		?	"----------\n" + 
7062
			"1. ERROR in X.java (at line 3)\n" + 
7063
			"	void foo();\n" + 
7064
			"	     ^^^^^\n" + 
7065
			"The method foo() of type I must override a superclass method\n" + 
7066
			"----------\n" + 
7067
			"2. ERROR in X.java (at line 8)\n" + 
7068
			"	public void foo() {}\n" + 
7069
			"	            ^^^^^\n" + 
7070
			"The method foo() of type X must override a superclass method\n" + 
7071
			"----------\n" + 
7072
			"3. ERROR in X.java (at line 13)\n" + 
7073
			"	void foo();\n" + 
7074
			"	     ^^^^^\n" + 
7075
			"The method foo() of type J must override a superclass method\n" + 
7076
			"----------\n"
7077
		:	"----------\n" + 
7078
			"1. ERROR in X.java (at line 3)\n" + 
7079
			"	void foo();\n" + 
7080
			"	     ^^^^^\n" + 
7081
			"The method foo() of type I must override or implement a supertype method\n" + 
7082
			"----------\n";
7083
    this.runNegativeTest(
7084
        new String[] {
7085
            "X.java",
7086
			"interface I {\n" + 
7087
			"  @Override\n" + 
7088
			"  void foo();\n" + 
7089
			"  void bar();\n" + 
7090
			"}\n" + 
7091
			"public class X implements I {\n" + 
7092
			"  @Override\n" + 
7093
			"  public void foo() {}\n" + 
7094
			"  public void bar() {}\n" + 
7095
			"}\n" + 
7096
			"interface J extends I {\n" + 
7097
			"	@Override\n" + 
7098
			"	void foo();\n" + 
7099
			"}\n",
7100
        },
7101
        expectedOutput);
7102
}
7008
}
7103
}

Return to bug 141931