Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 339478 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (-1 / +2 lines)
Lines 1377-1383 Link Here
1377
	int MultiCatchNotBelow17 =  Syntax + Internal + 875;
1377
	int MultiCatchNotBelow17 =  Syntax + Internal + 875;
1378
	/** @since 3.7 */
1378
	/** @since 3.7 */
1379
	int PolymorphicMethodNotBelow17 = MethodRelated + 876;
1379
	int PolymorphicMethodNotBelow17 = MethodRelated + 876;
1380
1380
	/** @since 3.7 */
1381
	int InvalidUsageOfDiamondConstruct = Syntax + TypeRelated + 877;
1381
	/**
1382
	/**
1382
	 * External problems -- These are problems defined by other plugins
1383
	 * External problems -- These are problems defined by other plugins
1383
	 */
1384
	 */
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (-2 / +15 lines)
Lines 29-35 Link Here
29
	public TypeReference[] typeArguments;
29
	public TypeReference[] typeArguments;
30
	public TypeBinding[] genericTypeArguments;
30
	public TypeBinding[] genericTypeArguments;
31
	public FieldDeclaration enumConstant; // for enum constant initializations
31
	public FieldDeclaration enumConstant; // for enum constant initializations
32
32
	protected TypeBinding expectedType;
33
	
33
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
34
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
34
	// check captured variables are initialized in current context (26134)
35
	// check captured variables are initialized in current context (26134)
35
	checkCapturedLocalInitializationIfNecessary((ReferenceBinding)this.binding.declaringClass.erasure(), currentScope, flowInfo);
36
	checkCapturedLocalInitializationIfNecessary((ReferenceBinding)this.binding.declaringClass.erasure(), currentScope, flowInfo);
Lines 255-261 Link Here
255
		// initialization of an enum constant
256
		// initialization of an enum constant
256
		this.resolvedType = scope.enclosingReceiverType();
257
		this.resolvedType = scope.enclosingReceiverType();
257
	} else {
258
	} else {
258
		this.resolvedType = this.type.resolveType(scope, true /* check bounds*/);
259
		TypeBinding inferredArguments[] = null;
260
		if ((scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7) && (this.type.bits & ASTNode.IsDiamond) != 0) {
261
			if (this.expectedType != null && this.expectedType.isParameterizedTypeWithActualArguments())
262
				inferredArguments = ((ParameterizedTypeBinding)this.expectedType).arguments;
263
		}
264
		this.resolvedType = this.type.resolveType(scope, true /* check bounds*/, inferredArguments);
259
		checkParameterizedAllocation: {
265
		checkParameterizedAllocation: {
260
			if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>()
266
			if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>()
261
				ReferenceBinding currentType = (ReferenceBinding)this.resolvedType;
267
				ReferenceBinding currentType = (ReferenceBinding)this.resolvedType;
Lines 409-412 Link Here
409
	}
415
	}
410
	visitor.endVisit(this, scope);
416
	visitor.endVisit(this, scope);
411
}
417
}
418
/**
419
 * @see org.eclipse.jdt.internal.compiler.ast.Expression#setExpectedType(org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
420
 */
421
public void setExpectedType(TypeBinding expectedType) {
422
	this.expectedType = expectedType;
423
}
424
412
}
425
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java (-2 / +10 lines)
Lines 214-224 Link Here
214
					this.initialization.computeConversion(initializationScope, fieldType, initializationType);
214
					this.initialization.computeConversion(initializationScope, fieldType, initializationType);
215
				}
215
				}
216
			} else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) {
216
			} else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) {
217
217
				boolean isDiamond = false;
218
				if (this.initialization instanceof AllocationExpression) {	
219
					AllocationExpression allocationExpression = (AllocationExpression) this.initialization;
220
					if (initializationScope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7 
221
							&& allocationExpression.type != null
222
							&& (allocationExpression.type.bits & ASTNode.IsDiamond) != 0) {
223
						isDiamond = true;
224
					}
225
				}
218
				if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError()
226
				if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError()
219
					initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType);
227
					initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType);
220
				if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType)
228
				if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType)
221
						|| initializationType.isCompatibleWith(fieldType)) {
229
						|| initializationType.isCompatibleWith(fieldType, isDiamond)) {
222
					this.initialization.computeConversion(initializationScope, fieldType, initializationType);
230
					this.initialization.computeConversion(initializationScope, fieldType, initializationType);
223
					if (initializationType.needsUncheckedConversion(fieldType)) {
231
					if (initializationType.needsUncheckedConversion(fieldType)) {
224
						    initializationScope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, fieldType);
232
						    initializationScope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, fieldType);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java (-2 / +11 lines)
Lines 157-163 Link Here
157
	}
157
	}
158
158
159
	public void resolve(BlockScope scope) {
159
	public void resolve(BlockScope scope) {
160
160
		boolean isCompliant17 = scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7;
161
		// create a binding and add it to the scope
161
		// create a binding and add it to the scope
162
		TypeBinding variableType = this.type.resolveType(scope, true /* check bounds*/);
162
		TypeBinding variableType = this.type.resolveType(scope, true /* check bounds*/);
163
163
Lines 171-176 Link Here
171
				scope.problemReporter().variableTypeCannotBeVoidArray(this);
171
				scope.problemReporter().variableTypeCannotBeVoidArray(this);
172
				return;
172
				return;
173
			}
173
			}
174
			if (isCompliant17 && variableType.isParameterizedType() && (this.type.bits & ASTNode.IsDiamond) != 0) {
175
				scope.problemReporter().incorrectArityForParameterizedType(this.type, variableType.original(), ((ParameterizedTypeBinding)variableType).arguments);
176
				return;
177
			}
174
		}
178
		}
175
179
176
		Binding existingVariable = scope.getBinding(this.name, Binding.VARIABLE, this, false /*do not resolve hidden field*/);
180
		Binding existingVariable = scope.getBinding(this.name, Binding.VARIABLE, this, false /*do not resolve hidden field*/);
Lines 207-218 Link Here
207
				}
211
				}
208
			} else {
212
			} else {
209
			    this.initialization.setExpectedType(variableType);
213
			    this.initialization.setExpectedType(variableType);
214
			    boolean isDiamond = false;
210
				TypeBinding initializationType = this.initialization.resolveType(scope);
215
				TypeBinding initializationType = this.initialization.resolveType(scope);
216
				if (this.initialization instanceof AllocationExpression) {
217
					if (isCompliant17 && (((AllocationExpression) this.initialization).type.bits & ASTNode.IsDiamond) != 0)
218
						isDiamond = true;
219
				}
211
				if (initializationType != null) {
220
				if (initializationType != null) {
212
					if (variableType != initializationType) // must call before computeConversion() and typeMismatchError()
221
					if (variableType != initializationType) // must call before computeConversion() and typeMismatchError()
213
						scope.compilationUnitScope().recordTypeConversion(variableType, initializationType);
222
						scope.compilationUnitScope().recordTypeConversion(variableType, initializationType);
214
					if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, variableType)
223
					if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, variableType)
215
						|| initializationType.isCompatibleWith(variableType)) {
224
						|| initializationType.isCompatibleWith(variableType, isDiamond)) {
216
						this.initialization.computeConversion(scope, variableType, initializationType);
225
						this.initialization.computeConversion(scope, variableType, initializationType);
217
						if (initializationType.needsUncheckedConversion(variableType)) {
226
						if (initializationType.needsUncheckedConversion(variableType)) {
218
						    scope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, variableType);
227
						    scope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, variableType);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java (-3 / +24 lines)
Lines 27-32 Link Here
27
public class ParameterizedQualifiedTypeReference extends ArrayQualifiedTypeReference {
27
public class ParameterizedQualifiedTypeReference extends ArrayQualifiedTypeReference {
28
28
29
	public TypeReference[][] typeArguments;
29
	public TypeReference[][] typeArguments;
30
	public TypeBinding[] inferredTypeArgs;
30
31
31
	/**
32
	/**
32
	 * @param tokens
33
	 * @param tokens
Lines 37-42 Link Here
37
38
38
		super(tokens, dim, positions);
39
		super(tokens, dim, positions);
39
		this.typeArguments = typeArguments;
40
		this.typeArguments = typeArguments;
41
		this.inferredTypeArgs = null;
40
	}
42
	}
41
	public void checkBounds(Scope scope) {
43
	public void checkBounds(Scope scope) {
42
		if (this.resolvedType == null) return;
44
		if (this.resolvedType == null) return;
Lines 68-73 Link Here
68
	 * @return char[][]
70
	 * @return char[][]
69
	 */
71
	 */
70
	public char [][] getParameterizedTypeName(){
72
	public char [][] getParameterizedTypeName(){
73
		if ((this.bits & ASTNode.IsDiamond) != 0)
74
			return this.getTypeName();
71
		int length = this.tokens.length;
75
		int length = this.tokens.length;
72
		char[][] qParamName = new char[length][];
76
		char[][] qParamName = new char[length][];
73
		for (int i = 0; i < length; i++) {
77
		for (int i = 0; i < length; i++) {
Lines 222-227 Link Here
222
						argTypes[j] = argType;
226
						argTypes[j] = argType;
223
					}
227
					}
224
				}
228
				}
229
				if (argLength == 0 && (this.bits & ASTNode.IsDiamond) != 0 && this.inferredTypeArgs != null) {
230
					argTypes = this.inferredTypeArgs;
231
				}
225
				if (argHasError) {
232
				if (argHasError) {
226
					return null;
233
					return null;
227
				}
234
				}
Lines 247-254 Link Here
247
					}
254
					}
248
					return this.resolvedType;
255
					return this.resolvedType;
249
				} else if (argLength != typeVariables.length) { // check arity
256
				} else if (argLength != typeVariables.length) { // check arity
250
					scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes, i);
257
					if(scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7 && argLength == 0) {
251
					return null;
258
						if ((this.bits & ASTNode.IsDiamond) ==0) {
259
							scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes);
260
							return null;
261
						}
262
						// argLength = 0 ok if its the diamond case for compliance >= 1.7
263
						// also no need to check bounds for such a case
264
						checkBounds = false;
265
					} else {
266
						scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes, i);
267
						return null;
268
					}
252
				}
269
				}
253
				// check parameterizing non-static member type of raw type
270
				// check parameterizing non-static member type of raw type
254
				if (typeIsConsistent && !currentType.isStatic()) {
271
				if (typeIsConsistent && !currentType.isStatic()) {
Lines 343-349 Link Here
343
		}
360
		}
344
		return output;
361
		return output;
345
	}
362
	}
346
363
	
364
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds, TypeBinding[] inferredArgs) {
365
		this.inferredTypeArgs = inferredArgs;
366
	    return internalResolveType(scope, checkBounds);
367
	}
347
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
368
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
348
	    return internalResolveType(scope, checkBounds);
369
	    return internalResolveType(scope, checkBounds);
349
	}
370
	}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java (-2 / +25 lines)
Lines 27-37 Link Here
27
public class ParameterizedSingleTypeReference extends ArrayTypeReference {
27
public class ParameterizedSingleTypeReference extends ArrayTypeReference {
28
28
29
	public TypeReference[] typeArguments;
29
	public TypeReference[] typeArguments;
30
	public TypeBinding[] inferredTypeArgs;
30
31
31
	public ParameterizedSingleTypeReference(char[] name, TypeReference[] typeArguments, int dim, long pos){
32
	public ParameterizedSingleTypeReference(char[] name, TypeReference[] typeArguments, int dim, long pos){
32
		super(name, dim, pos);
33
		super(name, dim, pos);
33
		this.originalSourceEnd = this.sourceEnd;
34
		this.originalSourceEnd = this.sourceEnd;
34
		this.typeArguments = typeArguments;
35
		this.typeArguments = typeArguments;
36
		this.inferredTypeArgs = null;
35
	}
37
	}
36
	public void checkBounds(Scope scope) {
38
	public void checkBounds(Scope scope) {
37
		if (this.resolvedType == null) return;
39
		if (this.resolvedType == null) return;
Lines 57-62 Link Here
57
	 * @return char[][]
59
	 * @return char[][]
58
	 */
60
	 */
59
	public char [][] getParameterizedTypeName(){
61
	public char [][] getParameterizedTypeName(){
62
		if ((this.bits & ASTNode.IsDiamond) != 0)
63
			return this.getTypeName();
60
		StringBuffer buffer = new StringBuffer(5);
64
		StringBuffer buffer = new StringBuffer(5);
61
		buffer.append(this.token).append('<');
65
		buffer.append(this.token).append('<');
62
		for (int i = 0, length = this.typeArguments.length; i < length; i++) {
66
		for (int i = 0, length = this.typeArguments.length; i < length; i++) {
Lines 90-95 Link Here
90
     * No need to check for reference to raw type per construction
94
     * No need to check for reference to raw type per construction
91
     */
95
     */
92
	private TypeBinding internalResolveType(Scope scope, ReferenceBinding enclosingType, boolean checkBounds) {
96
	private TypeBinding internalResolveType(Scope scope, ReferenceBinding enclosingType, boolean checkBounds) {
97
		boolean isCompliant17 = scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7;
93
		// handle the error here
98
		// handle the error here
94
		this.constant = Constant.NotAConstant;
99
		this.constant = Constant.NotAConstant;
95
		if ((this.bits & ASTNode.DidResolve) != 0) { // is a shared type reference which was already resolved
100
		if ((this.bits & ASTNode.DidResolve) != 0) { // is a shared type reference which was already resolved
Lines 188-193 Link Here
188
			    argTypes[i] = argType;
193
			    argTypes[i] = argType;
189
		     }
194
		     }
190
		}
195
		}
196
		if (argLength == 0 && (this.bits & ASTNode.IsDiamond) != 0 && this.inferredTypeArgs != null) {
197
			argTypes = this.inferredTypeArgs;
198
		}
191
		if (argHasError) {
199
		if (argHasError) {
192
			return null;
200
			return null;
193
		}
201
		}
Lines 222-229 Link Here
222
			}
230
			}
223
			// if missing generic type, and compliance >= 1.5, then will rebuild a parameterized binding
231
			// if missing generic type, and compliance >= 1.5, then will rebuild a parameterized binding
224
		} else if (argLength != typeVariables.length) { // check arity
232
		} else if (argLength != typeVariables.length) { // check arity
225
			scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes);
233
			if(isCompliant17 && argLength == 0) {
226
			return null;
234
				if ((this.bits & ASTNode.IsDiamond) ==0) {
235
					scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes);
236
					return null;
237
				}
238
				// argLength = 0 ok if its the diamond case for compliance >= 1.7
239
				// also no need to check bounds for such a case
240
				checkBounds = false;
241
			} else {
242
				scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes);
243
				return null;
244
			}
227
		} else if (!currentType.isStatic()) {
245
		} else if (!currentType.isStatic()) {
228
			ReferenceBinding actualEnclosing = currentType.enclosingType();
246
			ReferenceBinding actualEnclosing = currentType.enclosingType();
229
			if (actualEnclosing != null && actualEnclosing.isRawType()){
247
			if (actualEnclosing != null && actualEnclosing.isRawType()){
Lines 281-286 Link Here
281
		return output;
299
		return output;
282
	}
300
	}
283
301
302
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds, TypeBinding[] inferredArgs) {
303
		this.inferredTypeArgs = inferredArgs;
304
	    return internalResolveType(scope, null, checkBounds);
305
	}
306
	
284
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
307
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
285
	    return internalResolveType(scope, null, checkBounds);
308
	    return internalResolveType(scope, null, checkBounds);
286
	}
309
	}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-1 / +17 lines)
Lines 236-242 Link Here
236
		boolean hasError = false;
236
		boolean hasError = false;
237
		boolean enclosingInstanceContainsCast = false;
237
		boolean enclosingInstanceContainsCast = false;
238
		boolean argsContainCast = false;
238
		boolean argsContainCast = false;
239
239
		boolean isCompliant17 = scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7;
240
		if (this.type != null) {	// this.type = null for enum initialization
241
			if (isCompliant17 && this.anonymousType != null && (this.type.bits & ASTNode.IsDiamond) != 0) {
242
				// don't allow diamond construct if this allocation expressions corresponds to an anonymous type being declared
243
				scope.problemReporter().invalidUsageOfDiamondConstruct(this.type);
244
				return null;
245
			}
246
		}
240
		if (this.enclosingInstance != null) {
247
		if (this.enclosingInstance != null) {
241
			if (this.enclosingInstance instanceof CastExpression) {
248
			if (this.enclosingInstance instanceof CastExpression) {
242
				this.enclosingInstance.bits |= ASTNode.DisableUnnecessaryCastCheck; // will check later on
249
				this.enclosingInstance.bits |= ASTNode.DisableUnnecessaryCastCheck; // will check later on
Lines 498-501 Link Here
498
		}
505
		}
499
		visitor.endVisit(this, scope);
506
		visitor.endVisit(this, scope);
500
	}
507
	}
508
	
509
	/**
510
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#setExpectedType(org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
511
	 */
512
	public void setExpectedType(TypeBinding expectedType) {
513
		this.expectedType = expectedType;
514
		if (this.expectedType != null && this.enclosingInstance != null)
515
			this.enclosingInstance.setExpectedType(this.expectedType.enclosingType());
516
	}
501
}
517
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java (+4 lines)
Lines 208-213 Link Here
208
	return internalResolveType(scope);
208
	return internalResolveType(scope);
209
}
209
}
210
210
211
public TypeBinding resolveType(BlockScope scope, boolean checkBounds, TypeBinding[] inferredArgs) {
212
	return internalResolveType(scope);
213
}
214
211
public TypeBinding resolveType(ClassScope scope) {
215
public TypeBinding resolveType(ClassScope scope) {
212
	return internalResolveType(scope);
216
	return internalResolveType(scope);
213
}
217
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java (-2 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
2
 * Copyright (c) 2005, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 31-36 Link Here
31
	public ReferenceBinding[] memberTypes;
31
	public ReferenceBinding[] memberTypes;
32
	public MethodBinding[] methods;
32
	public MethodBinding[] methods;
33
	private ReferenceBinding enclosingType;
33
	private ReferenceBinding enclosingType;
34
	private TypeBinding[] expectedArgumentTypes;
34
35
35
	public ParameterizedTypeBinding(ReferenceBinding type, TypeBinding[] arguments,  ReferenceBinding enclosingType, LookupEnvironment environment){
36
	public ParameterizedTypeBinding(ReferenceBinding type, TypeBinding[] arguments,  ReferenceBinding enclosingType, LookupEnvironment environment){
36
		this.environment = environment;
37
		this.environment = environment;
Lines 451-457 Link Here
451
	public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) {
452
	public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) {
452
		int argCount = argumentTypes.length;
453
		int argCount = argumentTypes.length;
453
		MethodBinding match = null;
454
		MethodBinding match = null;
454
455
		this.expectedArgumentTypes = argumentTypes;
455
		if ((this.tagBits & TagBits.AreMethodsComplete) != 0) { // have resolved all arg types & return type of the methods
456
		if ((this.tagBits & TagBits.AreMethodsComplete) != 0) { // have resolved all arg types & return type of the methods
456
			long range;
457
			long range;
457
			if ((range = ReferenceBinding.binarySearch(TypeConstants.INIT, this.methods)) >= 0) {
458
			if ((range = ReferenceBinding.binarySearch(TypeConstants.INIT, this.methods)) >= 0) {
Lines 955-960 Link Here
955
			    // lazy init, since cannot do so during binding creation if during supertype connection
956
			    // lazy init, since cannot do so during binding creation if during supertype connection
956
			    if (currentType.arguments == null)
957
			    if (currentType.arguments == null)
957
					currentType.initializeArguments(); // only for raw types
958
					currentType.initializeArguments(); // only for raw types
959
			    else if (currentType.arguments.length == 0) {	// diamond case
960
			    	// this.expectedArgumentTypes should have the argument list
961
			    	 if (currentType.expectedArgumentTypes != null  && currentType.expectedArgumentTypes.length != 0) {
962
			    		 return currentType.expectedArgumentTypes[originalVariable.rank];
963
			    	 }
964
			    	return originalVariable;
965
			    }
958
			    if (currentType.arguments != null)
966
			    if (currentType.arguments != null)
959
					return currentType.arguments[originalVariable.rank];
967
					return currentType.arguments[originalVariable.rank];
960
			}
968
			}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java (+12 lines)
Lines 1005-1010 Link Here
1005
 * In addition to improving performance, caching also ensures there is no infinite regression
1005
 * In addition to improving performance, caching also ensures there is no infinite regression
1006
 * since per nature, the compatibility check is recursive through parameterized type arguments (122775)
1006
 * since per nature, the compatibility check is recursive through parameterized type arguments (122775)
1007
 */
1007
 */
1008
public boolean isCompatibleWith(TypeBinding otherType, boolean isDiamondCase) {
1009
	if (isDiamondCase) {
1010
		if (this.erasure() == otherType.erasure())
1011
			return true;
1012
	}
1013
	return isCompatibleWith(otherType);
1014
}
1015
/**
1016
 * Answer true if the receiver type can be assigned to the argument type (right)
1017
 * In addition to improving performance, caching also ensures there is no infinite regression
1018
 * since per nature, the compatibility check is recursive through parameterized type arguments (122775)
1019
 */
1008
public boolean isCompatibleWith(TypeBinding otherType) {
1020
public boolean isCompatibleWith(TypeBinding otherType) {
1009
	if (otherType == this)
1021
	if (otherType == this)
1010
		return true;
1022
		return true;
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (-1 / +13 lines)
Lines 1310-1315 Link Here
1310
					fieldDecl.binding = null;
1310
					fieldDecl.binding = null;
1311
					return null;
1311
					return null;
1312
				}
1312
				}
1313
				if ((this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7) && 
1314
						fieldDecl.type != null &&
1315
						((fieldDecl.type.bits & ASTNode.IsDiamond) != 0)) {
1316
					this.scope.problemReporter().incorrectArityForParameterizedType(fieldDecl.type, fieldType, Binding.NO_TYPES);
1317
					fieldDecl.binding = null;
1318
					return null;
1319
				}
1313
				if (fieldType == TypeBinding.VOID) {
1320
				if (fieldType == TypeBinding.VOID) {
1314
					this.scope.problemReporter().variableTypeCannotBeVoid(fieldDecl);
1321
					this.scope.problemReporter().variableTypeCannotBeVoid(fieldDecl);
1315
					fieldDecl.binding = null;
1322
					fieldDecl.binding = null;
Lines 1390-1395 Link Here
1390
	final boolean reportUnavoidableGenericTypeProblems = this.scope.compilerOptions().reportUnavoidableGenericTypeProblems;
1397
	final boolean reportUnavoidableGenericTypeProblems = this.scope.compilerOptions().reportUnavoidableGenericTypeProblems;
1391
	boolean foundArgProblem = false;
1398
	boolean foundArgProblem = false;
1392
	Argument[] arguments = methodDecl.arguments;
1399
	Argument[] arguments = methodDecl.arguments;
1400
	boolean isCompliant17 = this.scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7;
1393
	if (arguments != null) {
1401
	if (arguments != null) {
1394
		int size = arguments.length;
1402
		int size = arguments.length;
1395
		method.parameters = Binding.NO_PARAMETERS;
1403
		method.parameters = Binding.NO_PARAMETERS;
Lines 1415-1420 Link Here
1415
		
1423
		
1416
			if (parameterType == null) {
1424
			if (parameterType == null) {
1417
				foundArgProblem = true;
1425
				foundArgProblem = true;
1426
			} else if (isCompliant17 && (arg.type.bits & ASTNode.IsDiamond) != 0) {
1427
				// a parameter type cannot use diamond construct
1428
				methodDecl.scope.problemReporter().incorrectArityForParameterizedType(arg.type, parameterType.original(), Binding.NO_TYPES);
1429
				foundArgProblem = true;
1418
			} else if (parameterType == TypeBinding.VOID) {
1430
			} else if (parameterType == TypeBinding.VOID) {
1419
				methodDecl.scope.problemReporter().argumentTypeCannotBeVoid(this, methodDecl, arg);
1431
				methodDecl.scope.problemReporter().argumentTypeCannotBeVoid(this, methodDecl, arg);
1420
				foundArgProblem = true;
1432
				foundArgProblem = true;
Lines 1436-1442 Link Here
1436
	}
1448
	}
1437
1449
1438
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=337799
1450
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=337799
1439
	if (this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7) {
1451
	if (isCompliant17) {
1440
		if ((method.tagBits & TagBits.AnnotationSafeVarargs) != 0) {
1452
		if ((method.tagBits & TagBits.AnnotationSafeVarargs) != 0) {
1441
			if (!method.isVarargs()) {
1453
			if (!method.isVarargs()) {
1442
				methodDecl.scope.problemReporter().safeVarargsOnFixedArityMethod(method);
1454
				methodDecl.scope.problemReporter().safeVarargsOnFixedArityMethod(method);
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 1183-1186 Link Here
1183
public TypeVariableBinding[] typeVariables() {
1183
public TypeVariableBinding[] typeVariables() {
1184
	return Binding.NO_TYPE_VARIABLES;
1184
	return Binding.NO_TYPE_VARIABLES;
1185
}
1185
}
1186
1187
public boolean isCompatibleWith(TypeBinding variableType, boolean isDiamond){
1188
	return isCompatibleWith(variableType);
1189
}
1186
}
1190
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-3 / +5 lines)
Lines 3956-3961 Link Here
3956
	// zero type arguments == <>
3956
	// zero type arguments == <>
3957
	pushOnGenericsLengthStack(-1);
3957
	pushOnGenericsLengthStack(-1);
3958
	concatGenericsLists();
3958
	concatGenericsLists();
3959
	this.intPtr--;	// no reference type to be consumed between < and >
3959
}
3960
}
3960
protected void consumeImportDeclaration() {
3961
protected void consumeImportDeclaration() {
3961
	// SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';'
3962
	// SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';'
Lines 8912-8919 Link Here
8912
		if (dim != 0) {
8913
		if (dim != 0) {
8913
			parameterizedSingleTypeReference.sourceEnd = this.endStatementPosition;
8914
			parameterizedSingleTypeReference.sourceEnd = this.endStatementPosition;
8914
		}
8915
		}
8915
		if (isDiamond) {
8916
		if (isDiamond && (this.options.sourceLevel >= ClassFileConstants.JDK1_7)) {
8916
			parameterizedSingleTypeReference.bits |= ASTNode.IsDiamond;
8917
			if (parameterizedSingleTypeReference.dimensions == 0)
8918
				parameterizedSingleTypeReference.bits |= ASTNode.IsDiamond;
8917
		}
8919
		}
8918
		return parameterizedSingleTypeReference;
8920
		return parameterizedSingleTypeReference;
8919
	} else {
8921
	} else {
Lines 8954-8960 Link Here
8954
		if (dim != 0) {
8956
		if (dim != 0) {
8955
			parameterizedQualifiedTypeReference.sourceEnd = this.endStatementPosition;
8957
			parameterizedQualifiedTypeReference.sourceEnd = this.endStatementPosition;
8956
		}
8958
		}
8957
		if (isDiamond) {
8959
		if (isDiamond && (this.options.sourceLevel >= ClassFileConstants.JDK1_7)) {
8958
			parameterizedQualifiedTypeReference.bits |= ASTNode.IsDiamond;
8960
			parameterizedQualifiedTypeReference.bits |= ASTNode.IsDiamond;
8959
		}
8961
		}
8960
		return parameterizedQualifiedTypeReference;
8962
		return parameterizedQualifiedTypeReference;
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (+8 lines)
Lines 3877-3882 Link Here
3877
		annotationTypeDeclaration.sourceStart,
3877
		annotationTypeDeclaration.sourceStart,
3878
		annotationTypeDeclaration.sourceEnd);
3878
		annotationTypeDeclaration.sourceEnd);
3879
}
3879
}
3880
public void invalidUsageOfDiamondConstruct(ASTNode typeRef) {
3881
	this.handle(
3882
		IProblem.InvalidUsageOfDiamondConstruct,
3883
		NoArgument,
3884
		NoArgument,
3885
		typeRef.sourceStart,
3886
		typeRef.sourceEnd);
3887
}
3880
public void invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration) {
3888
public void invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration) {
3881
	this.handle(
3889
	this.handle(
3882
		IProblem.InvalidUsageOfEnumDeclarations,
3890
		IProblem.InvalidUsageOfEnumDeclarations,
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (+1 lines)
Lines 638-643 Link Here
638
874 = Resource specification not allowed here for source level below 1.7
638
874 = Resource specification not allowed here for source level below 1.7
639
875 = Multi-catch parameters are not allowed for source level below 1.7
639
875 = Multi-catch parameters are not allowed for source level below 1.7
640
876 = Invocation of polymorphic methods not allowed for source level below 1.7
640
876 = Invocation of polymorphic methods not allowed for source level below 1.7
641
877 = Empty type argument list cannot be used in anonymous class declaration
641
642
642
### ELABORATIONS
643
### ELABORATIONS
643
## Access restrictions
644
## Access restrictions
(-)src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java (-23 / +25 lines)
Lines 422-429 Link Here
422
		expectedProblemAttributes.put("DuplicateParameterizedMethods", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
422
		expectedProblemAttributes.put("DuplicateParameterizedMethods", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
423
		expectedProblemAttributes.put("DuplicateSuperInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
423
		expectedProblemAttributes.put("DuplicateSuperInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
424
		expectedProblemAttributes.put("DuplicateTargetInTargetAnnotation", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
424
		expectedProblemAttributes.put("DuplicateTargetInTargetAnnotation", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
425
		expectedProblemAttributes.put("DuplicateTypes", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
426
		expectedProblemAttributes.put("DuplicateTypeVariable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
425
		expectedProblemAttributes.put("DuplicateTypeVariable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
426
		expectedProblemAttributes.put("DuplicateTypes", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
427
		expectedProblemAttributes.put("EmptyControlFlowStatement", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
427
		expectedProblemAttributes.put("EmptyControlFlowStatement", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
428
		expectedProblemAttributes.put("EnclosingInstanceInConstructorCall", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
428
		expectedProblemAttributes.put("EnclosingInstanceInConstructorCall", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
429
		expectedProblemAttributes.put("EndOfSource", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
429
		expectedProblemAttributes.put("EndOfSource", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
Lines 452-460 Link Here
452
		expectedProblemAttributes.put("FieldTypeNotVisible", DEPRECATED);
452
		expectedProblemAttributes.put("FieldTypeNotVisible", DEPRECATED);
453
		expectedProblemAttributes.put("FinalBoundForTypeVariable", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
453
		expectedProblemAttributes.put("FinalBoundForTypeVariable", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
454
		expectedProblemAttributes.put("FinalFieldAssignment", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
454
		expectedProblemAttributes.put("FinalFieldAssignment", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
455
		expectedProblemAttributes.put("FinallyMustCompleteNormally", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
456
		expectedProblemAttributes.put("FinalMethodCannotBeOverridden", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
455
		expectedProblemAttributes.put("FinalMethodCannotBeOverridden", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
457
		expectedProblemAttributes.put("FinalOuterLocalAssignment", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
456
		expectedProblemAttributes.put("FinalOuterLocalAssignment", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
457
		expectedProblemAttributes.put("FinallyMustCompleteNormally", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
458
		expectedProblemAttributes.put("ForbiddenReference", new ProblemAttributes(CategorizedProblem.CAT_RESTRICTION));
458
		expectedProblemAttributes.put("ForbiddenReference", new ProblemAttributes(CategorizedProblem.CAT_RESTRICTION));
459
		expectedProblemAttributes.put("GenericConstructorTypeArgumentMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
459
		expectedProblemAttributes.put("GenericConstructorTypeArgumentMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
460
		expectedProblemAttributes.put("GenericMethodTypeArgumentMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
460
		expectedProblemAttributes.put("GenericMethodTypeArgumentMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
Lines 583-588 Link Here
583
		expectedProblemAttributes.put("InvalidUnicodeEscape", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
583
		expectedProblemAttributes.put("InvalidUnicodeEscape", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
584
		expectedProblemAttributes.put("InvalidUsageOfAnnotationDeclarations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
584
		expectedProblemAttributes.put("InvalidUsageOfAnnotationDeclarations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
585
		expectedProblemAttributes.put("InvalidUsageOfAnnotations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
585
		expectedProblemAttributes.put("InvalidUsageOfAnnotations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
586
		expectedProblemAttributes.put("InvalidUsageOfDiamondConstruct", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
586
		expectedProblemAttributes.put("InvalidUsageOfEnumDeclarations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
587
		expectedProblemAttributes.put("InvalidUsageOfEnumDeclarations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
587
		expectedProblemAttributes.put("InvalidUsageOfForeachStatements", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
588
		expectedProblemAttributes.put("InvalidUsageOfForeachStatements", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
588
		expectedProblemAttributes.put("InvalidUsageOfStaticImports", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
589
		expectedProblemAttributes.put("InvalidUsageOfStaticImports", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
Lines 646-654 Link Here
646
		expectedProblemAttributes.put("JavadocNotVisibleField", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
647
		expectedProblemAttributes.put("JavadocNotVisibleField", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
647
		expectedProblemAttributes.put("JavadocNotVisibleMethod", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
648
		expectedProblemAttributes.put("JavadocNotVisibleMethod", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
648
		expectedProblemAttributes.put("JavadocNotVisibleType", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
649
		expectedProblemAttributes.put("JavadocNotVisibleType", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
650
		expectedProblemAttributes.put("JavadocParameterMismatch", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
649
		expectedProblemAttributes.put("JavadocParameterizedConstructorArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
651
		expectedProblemAttributes.put("JavadocParameterizedConstructorArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
650
		expectedProblemAttributes.put("JavadocParameterizedMethodArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
652
		expectedProblemAttributes.put("JavadocParameterizedMethodArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
651
		expectedProblemAttributes.put("JavadocParameterMismatch", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
652
		expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericConstructor", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
653
		expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericConstructor", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
653
		expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericMethod", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
654
		expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericMethod", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
654
		expectedProblemAttributes.put("JavadocUndefinedConstructor", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
655
		expectedProblemAttributes.put("JavadocUndefinedConstructor", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
Lines 662-677 Link Here
662
		expectedProblemAttributes.put("JavadocUsingDeprecatedField", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
663
		expectedProblemAttributes.put("JavadocUsingDeprecatedField", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
663
		expectedProblemAttributes.put("JavadocUsingDeprecatedMethod", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
664
		expectedProblemAttributes.put("JavadocUsingDeprecatedMethod", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
664
		expectedProblemAttributes.put("JavadocUsingDeprecatedType", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
665
		expectedProblemAttributes.put("JavadocUsingDeprecatedType", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
665
		expectedProblemAttributes.put("LocalVariableCannotBeNull", DEPRECATED);
666
		expectedProblemAttributes.put("LocalVariableCanOnlyBeNull", DEPRECATED);
666
		expectedProblemAttributes.put("LocalVariableCanOnlyBeNull", DEPRECATED);
667
		expectedProblemAttributes.put("LocalVariableCannotBeNull", DEPRECATED);
667
		expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT));
668
		expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT));
668
		expectedProblemAttributes.put("LocalVariableHidingLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT));
669
		expectedProblemAttributes.put("LocalVariableHidingLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT));
669
		expectedProblemAttributes.put("LocalVariableIsNeverUsed", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
670
		expectedProblemAttributes.put("LocalVariableIsNeverUsed", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
670
		expectedProblemAttributes.put("LocalVariableMayBeNull", DEPRECATED);
671
		expectedProblemAttributes.put("LocalVariableMayBeNull", DEPRECATED);
671
		expectedProblemAttributes.put("MaskedCatch", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
672
		expectedProblemAttributes.put("MaskedCatch", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
672
		expectedProblemAttributes.put("MethodButWithConstructorName", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
673
		expectedProblemAttributes.put("MethodButWithConstructorName", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
673
		expectedProblemAttributes.put("MethodCanBeStatic", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
674
		expectedProblemAttributes.put("MethodCanBePotentiallyStatic", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
674
		expectedProblemAttributes.put("MethodCanBePotentiallyStatic", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
675
		expectedProblemAttributes.put("MethodCanBeStatic", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
675
		expectedProblemAttributes.put("MethodMissingDeprecatedAnnotation", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
676
		expectedProblemAttributes.put("MethodMissingDeprecatedAnnotation", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
676
		expectedProblemAttributes.put("MethodMustOverride", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
677
		expectedProblemAttributes.put("MethodMustOverride", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
677
		expectedProblemAttributes.put("MethodMustOverrideOrImplement", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
678
		expectedProblemAttributes.put("MethodMustOverrideOrImplement", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
Lines 740-748 Link Here
740
		expectedProblemAttributes.put("PackageCollidesWithType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
741
		expectedProblemAttributes.put("PackageCollidesWithType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
741
		expectedProblemAttributes.put("PackageIsNotExpectedPackage", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
742
		expectedProblemAttributes.put("PackageIsNotExpectedPackage", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
742
		expectedProblemAttributes.put("ParameterAssignment", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
743
		expectedProblemAttributes.put("ParameterAssignment", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
744
		expectedProblemAttributes.put("ParameterMismatch", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
743
		expectedProblemAttributes.put("ParameterizedConstructorArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
745
		expectedProblemAttributes.put("ParameterizedConstructorArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
744
		expectedProblemAttributes.put("ParameterizedMethodArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
746
		expectedProblemAttributes.put("ParameterizedMethodArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
745
		expectedProblemAttributes.put("ParameterMismatch", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
746
		expectedProblemAttributes.put("ParsingError", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
747
		expectedProblemAttributes.put("ParsingError", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
747
		expectedProblemAttributes.put("ParsingErrorDeleteToken", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
748
		expectedProblemAttributes.put("ParsingErrorDeleteToken", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
748
		expectedProblemAttributes.put("ParsingErrorDeleteTokens", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
749
		expectedProblemAttributes.put("ParsingErrorDeleteTokens", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
Lines 760-766 Link Here
760
		expectedProblemAttributes.put("ParsingErrorOnKeywordNoSuggestion", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
761
		expectedProblemAttributes.put("ParsingErrorOnKeywordNoSuggestion", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
761
		expectedProblemAttributes.put("ParsingErrorReplaceTokens", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
762
		expectedProblemAttributes.put("ParsingErrorReplaceTokens", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
762
		expectedProblemAttributes.put("ParsingErrorUnexpectedEOF", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
763
		expectedProblemAttributes.put("ParsingErrorUnexpectedEOF", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
763
		expectedProblemAttributes.put("PolymorphicMethodNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));		expectedProblemAttributes.put("PossibleAccidentalBooleanAssignment", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
764
		expectedProblemAttributes.put("PolymorphicMethodNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
765
		expectedProblemAttributes.put("PossibleAccidentalBooleanAssignment", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
764
		expectedProblemAttributes.put("PotentialHeapPollutionFromVararg", new ProblemAttributes(CategorizedProblem.CAT_UNCHECKED_RAW));
766
		expectedProblemAttributes.put("PotentialHeapPollutionFromVararg", new ProblemAttributes(CategorizedProblem.CAT_UNCHECKED_RAW));
765
		expectedProblemAttributes.put("PotentialNullLocalVariableReference", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
767
		expectedProblemAttributes.put("PotentialNullLocalVariableReference", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
766
		expectedProblemAttributes.put("PublicClassMustMatchFileName", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
768
		expectedProblemAttributes.put("PublicClassMustMatchFileName", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
Lines 769-774 Link Here
769
		expectedProblemAttributes.put("RecursiveConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
771
		expectedProblemAttributes.put("RecursiveConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
770
		expectedProblemAttributes.put("RedefinedArgument", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
772
		expectedProblemAttributes.put("RedefinedArgument", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
771
		expectedProblemAttributes.put("RedefinedLocal", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
773
		expectedProblemAttributes.put("RedefinedLocal", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
774
		expectedProblemAttributes.put("RedundantDeclarationOfTypeArguments", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
772
		expectedProblemAttributes.put("RedundantLocalVariableNullAssignment", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
775
		expectedProblemAttributes.put("RedundantLocalVariableNullAssignment", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
773
		expectedProblemAttributes.put("RedundantNullCheckOnNonNullLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
776
		expectedProblemAttributes.put("RedundantNullCheckOnNonNullLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
774
		expectedProblemAttributes.put("RedundantNullCheckOnNullLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
777
		expectedProblemAttributes.put("RedundantNullCheckOnNullLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
Lines 790-795 Link Here
790
		expectedProblemAttributes.put("StaticMemberOfParameterizedType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
793
		expectedProblemAttributes.put("StaticMemberOfParameterizedType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
791
		expectedProblemAttributes.put("StaticMethodRequested", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
794
		expectedProblemAttributes.put("StaticMethodRequested", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
792
		expectedProblemAttributes.put("StringConstantIsExceedingUtf8Limit", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
795
		expectedProblemAttributes.put("StringConstantIsExceedingUtf8Limit", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
796
		expectedProblemAttributes.put("SuperInterfaceMustBeAnInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
797
		expectedProblemAttributes.put("SuperInterfacesCollide", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
798
		expectedProblemAttributes.put("SuperTypeUsingWildcard", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
793
		expectedProblemAttributes.put("SuperclassAmbiguous", DEPRECATED);
799
		expectedProblemAttributes.put("SuperclassAmbiguous", DEPRECATED);
794
		expectedProblemAttributes.put("SuperclassInheritedNameHidesEnclosingName", DEPRECATED);
800
		expectedProblemAttributes.put("SuperclassInheritedNameHidesEnclosingName", DEPRECATED);
795
		expectedProblemAttributes.put("SuperclassInternalNameProvided", DEPRECATED);
801
		expectedProblemAttributes.put("SuperclassInternalNameProvided", DEPRECATED);
Lines 797-805 Link Here
797
		expectedProblemAttributes.put("SuperclassNotFound", DEPRECATED);
803
		expectedProblemAttributes.put("SuperclassNotFound", DEPRECATED);
798
		expectedProblemAttributes.put("SuperclassNotVisible", DEPRECATED);
804
		expectedProblemAttributes.put("SuperclassNotVisible", DEPRECATED);
799
		expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
805
		expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
800
		expectedProblemAttributes.put("SuperInterfaceMustBeAnInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
801
		expectedProblemAttributes.put("SuperInterfacesCollide", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
802
		expectedProblemAttributes.put("SuperTypeUsingWildcard", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
803
		expectedProblemAttributes.put("Task", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
806
		expectedProblemAttributes.put("Task", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
804
		expectedProblemAttributes.put("ThisInStaticContext", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
807
		expectedProblemAttributes.put("ThisInStaticContext", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
805
		expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
808
		expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
Lines 847-853 Link Here
847
		expectedProblemAttributes.put("UnnecessaryCast", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
850
		expectedProblemAttributes.put("UnnecessaryCast", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
848
		expectedProblemAttributes.put("UnnecessaryElse", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
851
		expectedProblemAttributes.put("UnnecessaryElse", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
849
		expectedProblemAttributes.put("UnnecessaryInstanceof", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
852
		expectedProblemAttributes.put("UnnecessaryInstanceof", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
850
		expectedProblemAttributes.put("UnnecessaryOperator", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
851
		expectedProblemAttributes.put("UnnecessaryNLSTag", new ProblemAttributes(CategorizedProblem.CAT_NLS));
853
		expectedProblemAttributes.put("UnnecessaryNLSTag", new ProblemAttributes(CategorizedProblem.CAT_NLS));
852
		expectedProblemAttributes.put("UnqualifiedFieldAccess", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
854
		expectedProblemAttributes.put("UnqualifiedFieldAccess", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
853
		expectedProblemAttributes.put("UnreachableCatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
855
		expectedProblemAttributes.put("UnreachableCatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
Lines 1080-1087 Link Here
1080
		expectedProblemAttributes.put("DuplicateParameterizedMethods", SKIP);
1082
		expectedProblemAttributes.put("DuplicateParameterizedMethods", SKIP);
1081
		expectedProblemAttributes.put("DuplicateSuperInterface", SKIP);
1083
		expectedProblemAttributes.put("DuplicateSuperInterface", SKIP);
1082
		expectedProblemAttributes.put("DuplicateTargetInTargetAnnotation", SKIP);
1084
		expectedProblemAttributes.put("DuplicateTargetInTargetAnnotation", SKIP);
1083
		expectedProblemAttributes.put("DuplicateTypes", SKIP);
1084
		expectedProblemAttributes.put("DuplicateTypeVariable", SKIP);
1085
		expectedProblemAttributes.put("DuplicateTypeVariable", SKIP);
1086
		expectedProblemAttributes.put("DuplicateTypes", SKIP);
1085
		expectedProblemAttributes.put("EmptyControlFlowStatement", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT));
1087
		expectedProblemAttributes.put("EmptyControlFlowStatement", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT));
1086
		expectedProblemAttributes.put("EnclosingInstanceInConstructorCall", SKIP);
1088
		expectedProblemAttributes.put("EnclosingInstanceInConstructorCall", SKIP);
1087
		expectedProblemAttributes.put("EndOfSource", SKIP);
1089
		expectedProblemAttributes.put("EndOfSource", SKIP);
Lines 1110-1118 Link Here
1110
		expectedProblemAttributes.put("FieldTypeNotVisible", SKIP);
1112
		expectedProblemAttributes.put("FieldTypeNotVisible", SKIP);
1111
		expectedProblemAttributes.put("FinalBoundForTypeVariable", new ProblemAttributes(JavaCore.COMPILER_PB_FINAL_PARAMETER_BOUND));
1113
		expectedProblemAttributes.put("FinalBoundForTypeVariable", new ProblemAttributes(JavaCore.COMPILER_PB_FINAL_PARAMETER_BOUND));
1112
		expectedProblemAttributes.put("FinalFieldAssignment", SKIP);
1114
		expectedProblemAttributes.put("FinalFieldAssignment", SKIP);
1113
		expectedProblemAttributes.put("FinallyMustCompleteNormally", new ProblemAttributes(JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING));
1114
		expectedProblemAttributes.put("FinalMethodCannotBeOverridden", SKIP);
1115
		expectedProblemAttributes.put("FinalMethodCannotBeOverridden", SKIP);
1115
		expectedProblemAttributes.put("FinalOuterLocalAssignment", SKIP);
1116
		expectedProblemAttributes.put("FinalOuterLocalAssignment", SKIP);
1117
		expectedProblemAttributes.put("FinallyMustCompleteNormally", new ProblemAttributes(JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING));
1116
		expectedProblemAttributes.put("ForbiddenReference", new ProblemAttributes(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
1118
		expectedProblemAttributes.put("ForbiddenReference", new ProblemAttributes(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
1117
		expectedProblemAttributes.put("GenericConstructorTypeArgumentMismatch", SKIP);
1119
		expectedProblemAttributes.put("GenericConstructorTypeArgumentMismatch", SKIP);
1118
		expectedProblemAttributes.put("GenericMethodTypeArgumentMismatch", SKIP);
1120
		expectedProblemAttributes.put("GenericMethodTypeArgumentMismatch", SKIP);
Lines 1216-1222 Link Here
1216
		expectedProblemAttributes.put("InvalidContinue", SKIP);
1218
		expectedProblemAttributes.put("InvalidContinue", SKIP);
1217
		expectedProblemAttributes.put("InvalidDigit", SKIP);
1219
		expectedProblemAttributes.put("InvalidDigit", SKIP);
1218
		expectedProblemAttributes.put("InvalidDisjunctiveTypeReferenceSequence", SKIP);
1220
		expectedProblemAttributes.put("InvalidDisjunctiveTypeReferenceSequence", SKIP);
1219
		expectedProblemAttributes.put("InvalidEmptyExoticIdentifier", SKIP);
1220
		expectedProblemAttributes.put("InvalidEncoding", SKIP);
1221
		expectedProblemAttributes.put("InvalidEncoding", SKIP);
1221
		expectedProblemAttributes.put("InvalidEscape", SKIP);
1222
		expectedProblemAttributes.put("InvalidEscape", SKIP);
1222
		expectedProblemAttributes.put("InvalidExplicitConstructorCall", SKIP);
1223
		expectedProblemAttributes.put("InvalidExplicitConstructorCall", SKIP);
Lines 1242-1247 Link Here
1242
		expectedProblemAttributes.put("InvalidUnicodeEscape", SKIP);
1243
		expectedProblemAttributes.put("InvalidUnicodeEscape", SKIP);
1243
		expectedProblemAttributes.put("InvalidUsageOfAnnotationDeclarations", SKIP);
1244
		expectedProblemAttributes.put("InvalidUsageOfAnnotationDeclarations", SKIP);
1244
		expectedProblemAttributes.put("InvalidUsageOfAnnotations", SKIP);
1245
		expectedProblemAttributes.put("InvalidUsageOfAnnotations", SKIP);
1246
		expectedProblemAttributes.put("InvalidUsageOfDiamondConstruct", SKIP);
1245
		expectedProblemAttributes.put("InvalidUsageOfEnumDeclarations", SKIP);
1247
		expectedProblemAttributes.put("InvalidUsageOfEnumDeclarations", SKIP);
1246
		expectedProblemAttributes.put("InvalidUsageOfForeachStatements", SKIP);
1248
		expectedProblemAttributes.put("InvalidUsageOfForeachStatements", SKIP);
1247
		expectedProblemAttributes.put("InvalidUsageOfStaticImports", SKIP);
1249
		expectedProblemAttributes.put("InvalidUsageOfStaticImports", SKIP);
Lines 1305-1313 Link Here
1305
		expectedProblemAttributes.put("JavadocNotVisibleField", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1307
		expectedProblemAttributes.put("JavadocNotVisibleField", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1306
		expectedProblemAttributes.put("JavadocNotVisibleMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1308
		expectedProblemAttributes.put("JavadocNotVisibleMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1307
		expectedProblemAttributes.put("JavadocNotVisibleType", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1309
		expectedProblemAttributes.put("JavadocNotVisibleType", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1310
		expectedProblemAttributes.put("JavadocParameterMismatch", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1308
		expectedProblemAttributes.put("JavadocParameterizedConstructorArgumentTypeMismatch", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1311
		expectedProblemAttributes.put("JavadocParameterizedConstructorArgumentTypeMismatch", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1309
		expectedProblemAttributes.put("JavadocParameterizedMethodArgumentTypeMismatch", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1312
		expectedProblemAttributes.put("JavadocParameterizedMethodArgumentTypeMismatch", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1310
		expectedProblemAttributes.put("JavadocParameterMismatch", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1311
		expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1313
		expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1312
		expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1314
		expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1313
		expectedProblemAttributes.put("JavadocUndefinedConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1315
		expectedProblemAttributes.put("JavadocUndefinedConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
Lines 1321-1336 Link Here
1321
		expectedProblemAttributes.put("JavadocUsingDeprecatedField", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1323
		expectedProblemAttributes.put("JavadocUsingDeprecatedField", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1322
		expectedProblemAttributes.put("JavadocUsingDeprecatedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1324
		expectedProblemAttributes.put("JavadocUsingDeprecatedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1323
		expectedProblemAttributes.put("JavadocUsingDeprecatedType", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1325
		expectedProblemAttributes.put("JavadocUsingDeprecatedType", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
1324
		expectedProblemAttributes.put("LocalVariableCannotBeNull", SKIP);
1325
		expectedProblemAttributes.put("LocalVariableCanOnlyBeNull", SKIP);
1326
		expectedProblemAttributes.put("LocalVariableCanOnlyBeNull", SKIP);
1327
		expectedProblemAttributes.put("LocalVariableCannotBeNull", SKIP);
1326
		expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING));
1328
		expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING));
1327
		expectedProblemAttributes.put("LocalVariableHidingLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING));
1329
		expectedProblemAttributes.put("LocalVariableHidingLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING));
1328
		expectedProblemAttributes.put("LocalVariableIsNeverUsed", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_LOCAL));
1330
		expectedProblemAttributes.put("LocalVariableIsNeverUsed", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_LOCAL));
1329
		expectedProblemAttributes.put("LocalVariableMayBeNull", SKIP);
1331
		expectedProblemAttributes.put("LocalVariableMayBeNull", SKIP);
1330
		expectedProblemAttributes.put("MaskedCatch", new ProblemAttributes(JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK));
1332
		expectedProblemAttributes.put("MaskedCatch", new ProblemAttributes(JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK));
1331
		expectedProblemAttributes.put("MethodButWithConstructorName", new ProblemAttributes(JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME));
1333
		expectedProblemAttributes.put("MethodButWithConstructorName", new ProblemAttributes(JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME));
1332
		expectedProblemAttributes.put("MethodCanBeStatic", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_STATIC_ON_METHOD));
1333
		expectedProblemAttributes.put("MethodCanBePotentiallyStatic", new ProblemAttributes(JavaCore.COMPILER_PB_POTENTIALLY_MISSING_STATIC_ON_METHOD));
1334
		expectedProblemAttributes.put("MethodCanBePotentiallyStatic", new ProblemAttributes(JavaCore.COMPILER_PB_POTENTIALLY_MISSING_STATIC_ON_METHOD));
1335
		expectedProblemAttributes.put("MethodCanBeStatic", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_STATIC_ON_METHOD));
1334
		expectedProblemAttributes.put("MethodMissingDeprecatedAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_DEPRECATED_ANNOTATION));
1336
		expectedProblemAttributes.put("MethodMissingDeprecatedAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_DEPRECATED_ANNOTATION));
1335
		expectedProblemAttributes.put("MethodMustOverride", SKIP);
1337
		expectedProblemAttributes.put("MethodMustOverride", SKIP);
1336
		expectedProblemAttributes.put("MethodMustOverrideOrImplement", SKIP);
1338
		expectedProblemAttributes.put("MethodMustOverrideOrImplement", SKIP);
Lines 1344-1350 Link Here
1344
		expectedProblemAttributes.put("MissingEnclosingInstanceForConstructorCall", SKIP);
1346
		expectedProblemAttributes.put("MissingEnclosingInstanceForConstructorCall", SKIP);
1345
		expectedProblemAttributes.put("MissingEnumConstantCase", new ProblemAttributes(JavaCore.COMPILER_PB_INCOMPLETE_ENUM_SWITCH));
1347
		expectedProblemAttributes.put("MissingEnumConstantCase", new ProblemAttributes(JavaCore.COMPILER_PB_INCOMPLETE_ENUM_SWITCH));
1346
		expectedProblemAttributes.put("MissingOverrideAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION));
1348
		expectedProblemAttributes.put("MissingOverrideAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION));
1347
		expectedProblemAttributes.put("MissingOverrideAnnotationForInterfaceMethodImplementation", SKIP);
1349
		expectedProblemAttributes.put("MissingOverrideAnnotationForInterfaceMethodImplementation", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION));
1348
		expectedProblemAttributes.put("MissingReturnType", SKIP);
1350
		expectedProblemAttributes.put("MissingReturnType", SKIP);
1349
		expectedProblemAttributes.put("MissingSemiColon", SKIP);
1351
		expectedProblemAttributes.put("MissingSemiColon", SKIP);
1350
		expectedProblemAttributes.put("MissingSerialVersion", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_SERIAL_VERSION));
1352
		expectedProblemAttributes.put("MissingSerialVersion", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_SERIAL_VERSION));
Lines 1399-1407 Link Here
1399
		expectedProblemAttributes.put("PackageCollidesWithType", SKIP);
1401
		expectedProblemAttributes.put("PackageCollidesWithType", SKIP);
1400
		expectedProblemAttributes.put("PackageIsNotExpectedPackage", SKIP);
1402
		expectedProblemAttributes.put("PackageIsNotExpectedPackage", SKIP);
1401
		expectedProblemAttributes.put("ParameterAssignment", new ProblemAttributes(JavaCore.COMPILER_PB_PARAMETER_ASSIGNMENT));
1403
		expectedProblemAttributes.put("ParameterAssignment", new ProblemAttributes(JavaCore.COMPILER_PB_PARAMETER_ASSIGNMENT));
1404
		expectedProblemAttributes.put("ParameterMismatch", SKIP);
1402
		expectedProblemAttributes.put("ParameterizedConstructorArgumentTypeMismatch", SKIP);
1405
		expectedProblemAttributes.put("ParameterizedConstructorArgumentTypeMismatch", SKIP);
1403
		expectedProblemAttributes.put("ParameterizedMethodArgumentTypeMismatch", SKIP);
1406
		expectedProblemAttributes.put("ParameterizedMethodArgumentTypeMismatch", SKIP);
1404
		expectedProblemAttributes.put("ParameterMismatch", SKIP);
1405
		expectedProblemAttributes.put("ParsingError", SKIP);
1407
		expectedProblemAttributes.put("ParsingError", SKIP);
1406
		expectedProblemAttributes.put("ParsingErrorDeleteToken", SKIP);
1408
		expectedProblemAttributes.put("ParsingErrorDeleteToken", SKIP);
1407
		expectedProblemAttributes.put("ParsingErrorDeleteTokens", SKIP);
1409
		expectedProblemAttributes.put("ParsingErrorDeleteTokens", SKIP);
Lines 1450-1465 Link Here
1450
		expectedProblemAttributes.put("StaticMemberOfParameterizedType", SKIP);
1452
		expectedProblemAttributes.put("StaticMemberOfParameterizedType", SKIP);
1451
		expectedProblemAttributes.put("StaticMethodRequested", SKIP);
1453
		expectedProblemAttributes.put("StaticMethodRequested", SKIP);
1452
		expectedProblemAttributes.put("StringConstantIsExceedingUtf8Limit", SKIP);
1454
		expectedProblemAttributes.put("StringConstantIsExceedingUtf8Limit", SKIP);
1453
		expectedProblemAttributes.put("SuperclassAmbiguous", SKIP);
1455
		expectedProblemAttributes.put("SuperInterfaceMustBeAnInterface", SKIP);
1456
		expectedProblemAttributes.put("SuperInterfacesCollide", SKIP);
1457
		expectedProblemAttributes.put("SuperTypeUsingWildcard", SKIP);
1458
		expectedProblemAttributes.put("SuperclassAmbiguous", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD));
1454
		expectedProblemAttributes.put("SuperclassInheritedNameHidesEnclosingName", SKIP);
1459
		expectedProblemAttributes.put("SuperclassInheritedNameHidesEnclosingName", SKIP);
1455
		expectedProblemAttributes.put("SuperclassInternalNameProvided", SKIP);
1460
		expectedProblemAttributes.put("SuperclassInternalNameProvided", SKIP);
1456
		expectedProblemAttributes.put("SuperclassMustBeAClass", SKIP);
1461
		expectedProblemAttributes.put("SuperclassMustBeAClass", SKIP);
1457
		expectedProblemAttributes.put("SuperclassNotFound", SKIP);
1462
		expectedProblemAttributes.put("SuperclassNotFound", SKIP);
1458
		expectedProblemAttributes.put("SuperclassNotVisible", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_SUPERINTERFACE));
1463
		expectedProblemAttributes.put("SuperclassNotVisible", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_SUPERINTERFACE));
1459
		expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT));
1464
		expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT));
1460
		expectedProblemAttributes.put("SuperInterfaceMustBeAnInterface", SKIP);
1461
		expectedProblemAttributes.put("SuperInterfacesCollide", SKIP);
1462
		expectedProblemAttributes.put("SuperTypeUsingWildcard", SKIP);
1463
		expectedProblemAttributes.put("Task", SKIP);
1465
		expectedProblemAttributes.put("Task", SKIP);
1464
		expectedProblemAttributes.put("ThisInStaticContext", SKIP);
1466
		expectedProblemAttributes.put("ThisInStaticContext", SKIP);
1465
		expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", SKIP);
1467
		expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", SKIP);
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java (+44 lines)
Lines 1740-1743 Link Here
1740
		compilerOptions15,
1740
		compilerOptions15,
1741
		null);
1741
		null);
1742
}
1742
}
1743
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=339478
1744
// To verify that diamond construct is not allowed in source level 1.6 or below
1745
public void test339478a() {
1746
	if (this.complianceLevel >= ClassFileConstants.JDK1_7)
1747
		return;
1748
	this.runNegativeTest(
1749
		new String[] {
1750
			"X.java",
1751
			"public class X<T> {\n" + 
1752
			"	public static void main(String[] args) {\n" + 
1753
			"		X<String> x = new X<>();\n" + 
1754
			"		x.testFunction(\"SUCCESS\");\n" + 
1755
			"	}\n" +
1756
			"	public void testFunction(T param){\n" +
1757
			"		System.out.println(param);\n" +
1758
			"	}\n" + 
1759
			"}",
1760
		},
1761
		"----------\n" + 
1762
		"1. ERROR in X.java (at line 3)\n" + 
1763
		"	X<String> x = new X<>();\n" + 
1764
		"	                  ^\n" + 
1765
		"Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>\n" + 
1766
		"----------\n");
1767
}
1768
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=339478
1769
// To verify that diamond construct is not allowed in source level 1.6 or below
1770
public void test339478b() {
1771
	this.runNegativeTest(
1772
		new String[] {
1773
			"X.java",
1774
			"public class X<T> {\n" +
1775
			"	public static void main(String[] args) {\n" + 
1776
			"		X<> x1 = null;\n" +
1777
			"	}\n" +
1778
			"}",
1779
		},
1780
		"----------\n" + 
1781
		"1. ERROR in X.java (at line 3)\n" + 
1782
		"	X<> x1 = null;\n" + 
1783
		"	^\n" + 
1784
		"Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>\n" + 
1785
		"----------\n");
1786
}
1743
}
1787
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java (+888 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 * 
12
 * Contributors:
13
 *     IBM Corporation - initial API and implementation
14
 *******************************************************************************/
15
package org.eclipse.jdt.core.tests.compiler.regression;
16
17
import java.util.Map;
18
19
import junit.framework.Test;
20
public class GenericsRegressionTest_1_7 extends AbstractRegressionTest {
21
22
static {
23
//	TESTS_NAMES = new String[] { "test0014" };
24
//	TESTS_NUMBERS = new int[] { 40, 41, 43, 45, 63, 64 };
25
//	TESTS_RANGE = new int[] { 11, -1 };
26
}
27
public GenericsRegressionTest_1_7(String name) {
28
	super(name);
29
}
30
public static Test suite() {
31
	return buildMinimalComplianceTestSuite(testClass(), F_1_7);
32
}
33
public void test001() {
34
	this.runConformTest(
35
		new String[] {
36
			"X.java",
37
			"public class X<T> {\n" + 
38
			"	public static void main(String[] args) {\n" + 
39
			"		X<String> x = new X<>();\n" + 
40
			"		x.testFunction(\"SUCCESS\");\n" + 
41
			"	}\n" +
42
			"	public void testFunction(T param){\n" +
43
			"		System.out.println(param);\n" +
44
			"	}\n" + 
45
			"}",
46
		},
47
		"SUCCESS");
48
}
49
public void test001a() {
50
	this.runNegativeTest(
51
		new String[] {
52
			"X.java",
53
			"public class X<T> {\n" + 
54
			"	public static void main(String[] args) {\n" + 
55
			"		X<String> x = new X<>();\n" + 
56
			"		x.testFunction(1);\n" + 
57
			"	}\n" +
58
			"	public void testFunction(T param){\n" +
59
			"		System.out.println(param);\n" +
60
			"	}\n" + 
61
			"}",
62
		},
63
		"----------\n" + 
64
		"1. ERROR in X.java (at line 4)\n" + 
65
		"	x.testFunction(1);\n" + 
66
		"	  ^^^^^^^^^^^^\n" + 
67
		"The method testFunction(String) in the type X<String> is not applicable for the arguments (int)\n" + 
68
		"----------\n");
69
}
70
public void test001b() {
71
	this.runConformTest(
72
		new String[] {
73
			"X.java",
74
			"public class X<T> {\n" + 
75
			"	public static void main(String[] args) {\n" + 
76
			"		java.util.ArrayList<String> x = new java.util.ArrayList<>();\n" + 
77
			"		x.add(\"\");\n" +
78
			"		System.out.println(\"SUCCESS\");\n" + 
79
			"	}\n" +
80
			"}",
81
		},
82
		"SUCCESS");
83
}
84
// fields
85
public void test001b_1() {
86
	this.runConformTest(
87
		new String[] {
88
			"X.java",
89
			"public class X<T> {\n" +
90
			"	static java.util.ArrayList<String> x = new java.util.ArrayList<>();\n" + 
91
			"	public static void main(String[] args) {\n" + 
92
			"		X.x.add(\"\");\n" +
93
			"		System.out.println(\"SUCCESS\");\n" + 
94
			"	}\n" +
95
			"}",
96
		},
97
		"SUCCESS");
98
}
99
public void test001c() {
100
	this.runNegativeTest(
101
		new String[] {
102
			"X.java",
103
			"public class X<T> {\n" + 
104
			"	public static void main(String[] args) {\n" + 
105
			"		java.util.ArrayList<String> x = new java.util.ArrayList<>();\n" + 
106
			"		x.add(1);\n" +
107
			"		System.out.println(\"SUCCESS\");\n" + 
108
			"	}\n" +
109
			"}",
110
		},
111
		"----------\n" + 
112
		"1. ERROR in X.java (at line 4)\n" + 
113
		"	x.add(1);\n" + 
114
		"	  ^^^\n" + 
115
		"The method add(int, String) in the type ArrayList<String> is not applicable for the arguments (int)\n" + 
116
		"----------\n");
117
}
118
// fields
119
public void test001c_1() {
120
	this.runNegativeTest(
121
		new String[] {
122
			"X.java",
123
			"public class X<T> {\n" +
124
			"	static java.util.ArrayList<String> x = new java.util.ArrayList<>();\n" + 
125
			"	public static void main(String[] args) {\n" + 
126
			"		X.x.add(1);\n" +
127
			"		System.out.println(\"SUCCESS\");\n" + 
128
			"	}\n" +
129
			"}",
130
		},
131
		"----------\n" + 
132
		"1. ERROR in X.java (at line 4)\n" + 
133
		"	X.x.add(1);\n" + 
134
		"	    ^^^\n" + 
135
		"The method add(int, String) in the type ArrayList<String> is not applicable for the arguments (int)\n" + 
136
		"----------\n");
137
}
138
public void _test001d() {
139
	this.runConformTest(
140
		new String[] {
141
			"X.java",
142
			"import java.util.ArrayList;\n" +
143
			"public class X<T> {" +
144
			"	public void ab(ArrayList<String> al){\n" + 
145
			"		System.out.println(\"SUCCESS\");\n" +
146
			"	}\n" + 
147
			"	public static void main(String[] args) {\n" + 
148
			"		X<String> x = new X<>();\n" + 
149
			"		x.ab(new ArrayList<>());\n" + 
150
			"	}\n" +
151
			"}",
152
		},
153
		"SUCCESS");
154
}
155
public void _test001e() {
156
	this.runNegativeTest(
157
		new String[] {
158
			"X.java",
159
			"import java.util.ArrayList;\n" +
160
			"public class X<T> {" +
161
			"	public void ab(ArrayList<T> al){\n" + 
162
			"		System.out.println(\"SUCCESS\");\n" +
163
			"	}\n" + 
164
			"	public static void main(String[] args) {\n" + 
165
			"		X<String> x = new X<>();\n" + 
166
			"		x.ab(new ArrayList<>());\n" + 
167
			"	}\n" +
168
			"}",
169
		},
170
		"----------\n" + 
171
		"1. ERROR in X.java (at line 7)\n" + 
172
		"	x.ab(new ArrayList<Integer>());\n" + 
173
		"	  ^^\n" + 
174
		"The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Integer>)\n" + 
175
		"----------\n");
176
}
177
public void test001f() {
178
	this.runConformTest(
179
		new String[] {
180
			"X.java",
181
			"public class X<T> {\n" +
182
			"	class X2<T>{\n" +
183
			"		void methodx(T param){\n" +
184
			"			System.out.println(param);\n" +
185
			"		}\n" +
186
			"	}\n" + 
187
			"	public static void main(String[] args) {\n" + 
188
			"		X<String>.X2<String> x = new X<>().new X2<>();\n" + 
189
			"		x.methodx(\"SUCCESS\");\n" + 
190
			"	}\n" +
191
			"}",
192
		},
193
		"SUCCESS");
194
}
195
// fields
196
public void test001f_1() {
197
	this.runConformTest(
198
		new String[] {
199
			"X.java",
200
			"public class X<T> {\n" +
201
			"	class X2<T>{\n" +
202
			"		void methodx(T param){\n" +
203
			"			System.out.println(param);\n" +
204
			"		}\n" +
205
			"	}\n" +
206
			"	X<String>.X2<String> x;\n" + 
207
			"	public static void main(String[] args) {\n" +
208
			"		X test = new X();\n" + 
209
			"		test.x = new X<>().new X2<>();\n" + 
210
			"		test.x.methodx(\"SUCCESS\");\n" + 
211
			"	}\n" +
212
			"}",
213
		},
214
		"SUCCESS");
215
}
216
public void test001g() {
217
	this.runConformTest(
218
		new String[] {
219
			"X.java",
220
			"public class X<T> {\n" +
221
			"	class X2<K>{\n" +
222
			"		void methodx(T param, K param2){\n" +
223
			"			System.out.println(param);\n" +
224
			"			System.out.println(param2);\n" +
225
			"		}\n" +
226
			"	}\n" + 
227
			"	public static void main(String[] args) {\n" + 
228
			"		X<String>.X2<Integer> x = new X<>().new X2<>();\n" + 
229
			"		x.methodx(\"SUCCESS\",1);\n" + 
230
			"	}\n" +
231
			"}",
232
		},
233
		"SUCCESS\n1");
234
}
235
public void test001g_1() {
236
	this.runConformTest(
237
		new String[] {
238
			"X.java",
239
			"public class X<T> {\n" +
240
			"	class X2<K>{\n" +
241
			"		void methodx(T param, K param2){\n" +
242
			"			System.out.println(param);\n" +
243
			"			System.out.println(param2);\n" +
244
			"		}\n" +
245
			"	}\n" +
246
			"	X<String>.X2<Integer> x;\n" + 
247
			"	public static void main(String[] args) {\n" +
248
			"		X test = new X();" + 
249
			"		test.x = new X<>().new X2<>();\n" + 
250
			"		test.x.methodx(\"SUCCESS\",1);\n" + 
251
			"	}\n" +
252
			"}",
253
		},
254
		"SUCCESS\n1");
255
}
256
public void test001h() {
257
	this.runNegativeTest(
258
		new String[] {
259
			"X.java",
260
			"public class X<T> {\n" +
261
			"	class X2<T>{\n" +
262
			"		void methodx(T param){\n" +
263
			"			System.out.println(param);\n" +
264
			"		}\n" +
265
			"	}\n" + 
266
			"	public static void main(String[] args) {\n" + 
267
			"		X<String>.X2<String> x = new X<>().new X2<>();\n" + 
268
			"		x.methodx(1);\n" + 
269
			"	}\n" +
270
			"}",
271
		},
272
		"----------\n" + 
273
		"1. WARNING in X.java (at line 2)\n" + 
274
		"	class X2<T>{\n" + 
275
		"	         ^\n" + 
276
		"The type parameter T is hiding the type T\n" + 
277
		"----------\n" + 
278
		"2. ERROR in X.java (at line 9)\n" + 
279
		"	x.methodx(1);\n" + 
280
		"	  ^^^^^^^\n" + 
281
		"The method methodx(String) in the type X<String>.X2<String> is not applicable for the arguments (int)\n" + 
282
		"----------\n");
283
}
284
public void test001h_1() {
285
	this.runNegativeTest(
286
		new String[] {
287
			"X.java",
288
			"public class X<T> {\n" +
289
			"	class X2<T>{\n" +
290
			"		void methodx(T param){\n" +
291
			"			System.out.println(param);\n" +
292
			"		}\n" +
293
			"	}\n" +
294
			"	X<String>.X2<String> x;\n" + 
295
			"	public static void main(String[] args) {\n" +
296
			"		X test = new X();\n" + 
297
			"		test.x = new X<>().new X2<>();\n" + 
298
			"		test.x.methodx(1);\n" + 
299
			"	}\n" +
300
			"}",
301
		},
302
		"----------\n" + 
303
		"1. WARNING in X.java (at line 2)\n" + 
304
		"	class X2<T>{\n" + 
305
		"	         ^\n" + 
306
		"The type parameter T is hiding the type T\n" + 
307
		"----------\n" + 
308
		"2. WARNING in X.java (at line 9)\n" + 
309
		"	X test = new X();\n" + 
310
		"	^\n" + 
311
		"X is a raw type. References to generic type X<T> should be parameterized\n" + 
312
		"----------\n" + 
313
		"3. WARNING in X.java (at line 9)\n" + 
314
		"	X test = new X();\n" + 
315
		"	             ^\n" + 
316
		"X is a raw type. References to generic type X<T> should be parameterized\n" + 
317
		"----------\n" + 
318
		"4. WARNING in X.java (at line 10)\n" + 
319
		"	test.x = new X<>().new X2<>();\n" + 
320
		"	     ^\n" + 
321
		"Type safety: The field x from the raw type X is assigned a value of type X<>.X2. References to generic type X<T> should be parameterized\n" + 
322
		"----------\n" + 
323
		"5. WARNING in X.java (at line 11)\n" + 
324
		"	test.x.methodx(1);\n" + 
325
		"	^^^^^^^^^^^^^^^^^\n" + 
326
		"Type safety: The method methodx(Object) belongs to the raw type X.X2. References to generic type X<T>.X2<T> should be parameterized\n" + 
327
		"----------\n");
328
}
329
public void test001i() {
330
	this.runConformTest(
331
		new String[] {
332
			"X.java",
333
			"public class X<T> {\n" +
334
			"	class X2<K>{\n" +
335
			"		class X22<I>{\n" +
336
			"			void methodx(T param, K param2, I param3){\n" +
337
			"				System.out.println(param);\n" +
338
			"			}\n" +
339
			"		}\n" +
340
			"	}\n" + 
341
			"	public static void main(String[] args) {\n" +
342
			"		X<String> test = new X<>();" + 
343
			"		X<String>.X2<Integer>.X22<X<String>> x = new X<>().new X2<>().new X22<>();\n" + 
344
			"		x.methodx(\"SUCCESS\", 1, test);\n" + 
345
			"	}\n" +
346
			"}",
347
		},
348
		"SUCCESS");
349
}
350
public void test002() {
351
	this.runNegativeTest(
352
		new String[] {
353
			"X.java",
354
			"public class X<T> {\n" + 
355
			"	public static void main(String[] args) {\n" + 
356
			"		X x = new X<>();\n" + 
357
			"		x.testFunction(\"SUCCESS\");\n" + 
358
			"	}\n" +
359
			"	public void testFunction(T param){\n" +
360
			"		System.out.println(param);\n" +
361
			"	}\n" + 
362
			"}",
363
		},
364
		"----------\n" + 
365
		"1. WARNING in X.java (at line 3)\n" + 
366
		"	X x = new X<>();\n" + 
367
		"	^\n" + 
368
		"X is a raw type. References to generic type X<T> should be parameterized\n" + 
369
		"----------\n" + 
370
		"2. WARNING in X.java (at line 4)\n" + 
371
		"	x.testFunction(\"SUCCESS\");\n" + 
372
		"	^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
373
		"Type safety: The method testFunction(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" + 
374
		"----------\n");
375
}
376
public void _test003() {
377
	this.runNegativeTest(
378
		new String[] {
379
			"X.java",
380
			"public class X<T> {\n" + 
381
			"	public static void main(String[] args) {\n" + 
382
			"		new X<>().testFunction(\"SUCCESS\");\n" + 
383
			"	}\n" +
384
			"	public void testFunction(T param){\n" +
385
			"		System.out.println(param);\n" +
386
			"	}\n" + 
387
			"}",
388
		},
389
		"SUCCESS");
390
}
391
public void test004() {
392
	this.runNegativeTest(
393
		new String[] {
394
			"X.java",
395
			"public class X<T> {\n" + 
396
			"	public static void main(String[] args) {\n" + 
397
			"		new X<>(){\n" +
398
			"			void newMethod(){\n" +
399
			"			}\n" +
400
			"		}.testFunction(\"SUCCESS\");\n" + 
401
			"	}\n" +
402
			"	public void testFunction(T param){\n" +
403
			"		System.out.println(param);\n" +
404
			"	}\n" + 
405
			"}",
406
		},
407
		"----------\n" + 
408
		"1. ERROR in X.java (at line 3)\n" + 
409
		"	new X<>(){\n" + 
410
		"	    ^\n" + 
411
		"Empty type argument list cannot be used in anonymous class declaration\n" + 
412
		"----------\n");
413
}
414
public void test004b() {
415
	this.runNegativeTest(
416
		new String[] {
417
			"X.java",
418
			"public class X<T> {\n" +
419
			"	class X2<U> {\n" +
420
			"	}\n" + 
421
			"	public static void main(String[] args) {\n" + 
422
			"		new X<>().new X2<>(){\n" +
423
			"			void newMethod(){\n" +
424
			"			}\n" +
425
			"		};\n" + 
426
			"	}\n" +
427
			"}",
428
		},
429
		"----------\n" + 
430
		"1. ERROR in X.java (at line 5)\n" + 
431
		"	new X<>().new X2<>(){\n" + 
432
		"	              ^^\n" + 
433
		"Empty type argument list cannot be used in anonymous class declaration\n" + 
434
		"----------\n");
435
}
436
public void test004c() {
437
	this.runConformTest(
438
		new String[] {
439
			"X.java",
440
			"public class X<T> {\n" +
441
			"	class X2<U> {\n" +
442
			"		U f1;" +
443
			"		public void setF(U a){\n" +
444
			"			this.f1 = a;" +
445
			"			System.out.println(this.f1);\n" +
446
			"		}\n" +
447
			"	}\n" + 
448
			"	public static void main(String[] args) {\n" + 
449
			"		new X<>().new X2<Integer>(){\n" +
450
			"			void newMethod(){\n" +
451
			"			}\n" +
452
			"		}.setF(1);\n" + 
453
			"	}\n" +
454
			"}",
455
		},
456
		"1");
457
}
458
public void test005() {
459
	this.runNegativeTest(
460
		new String[] {
461
			"X.java",
462
			"public class X<T> {\n" + 
463
			"	public static void main(String[] args) {\n" + 
464
			"		X Test = new X<>(){\n" +
465
			"			void newMethod(){\n" +
466
			"			}\n" +
467
			"		}.testFunction(\"SUCCESS\");\n" + 
468
			"	}\n" +
469
			"	public void testFunction(T param){\n" +
470
			"		System.out.println(param);\n" +
471
			"	}\n" + 
472
			"}",
473
		},
474
		"----------\n" + 
475
		"1. WARNING in X.java (at line 3)\n" + 
476
		"	X Test = new X<>(){\n" + 
477
		"	^\n" + 
478
		"X is a raw type. References to generic type X<T> should be parameterized\n" + 
479
		"----------\n" + 
480
		"2. ERROR in X.java (at line 3)\n" + 
481
		"	X Test = new X<>(){\n" + 
482
		"	             ^\n" + 
483
		"Empty type argument list cannot be used in anonymous class declaration\n" + 
484
		"----------\n");
485
}
486
public void test006() {
487
	this.runConformTest(
488
		new String[] {
489
			"X.java",
490
			"class X1<T> {\n" +
491
			"	int abc = 1;\n" +
492
			"	public void testFunction(T param){\n" +
493
			"		System.out.println(param + \"X1\");\n" +
494
			"	}\n" + 
495
			"}\n" +
496
			"public class X<T> extends X1<T> {\n" + 
497
			"	public static void main(String[] args) {\n" + 
498
			"		X1<String> x = new X<>();\n" + 
499
			"		x.testFunction(\"SUCCESS\");\n" + 
500
			"	}\n" +
501
			"	public void testFunction(T param){\n" +
502
			"		System.out.println(param);\n" +
503
			"	}\n" + 
504
			"}",
505
		},
506
		"SUCCESS");
507
}
508
// shows the difference between using <> and the raw type - different semantics
509
public void _test007() {
510
	this.runConformTest(
511
		new String[] {
512
			"X.java",
513
			"public class X<T> {\n" +
514
			"	T field1;" +
515
			"	public X(T param){\n" +
516
			"		field1 = param;\n" +
517
			"	}\n" +
518
			"	public static void main(String[] args) {\n" + 
519
			"		X.testFunction(new X<>(\"hello\").getField());\n" + // prints 1
520
			"		X.testFunction(new X(\"hello\").getField());\n" + //prints 2
521
			"	}\n" +
522
			"	public static void testFunction(String param){\n" +
523
			"		System.out.println(1);\n" +
524
			"	}\n" +
525
			"	public static void testFunction(Object param){\n" +
526
			"		System.out.println(2);\n" +
527
			"	}\n" +
528
			"	public T getField(){\n" +
529
			"		return field1;" +
530
			"	}\n" + 
531
			"}",
532
		},
533
		"1\n" + 
534
		"2");
535
}
536
// to verify if diamond works inside an allocation expression in a method invocation
537
public void _test007a() {
538
	this.runConformTest(
539
		new String[] {
540
			"X.java",
541
			"public class X<T> {\n" +
542
			"	public X(){\n" +
543
			"	}\n" +
544
			"	public X(T param){\n" +
545
			"		System.out.println(param);\n" +
546
			"	}\n" +
547
			"	public static void testFunction(X<String> param){\n" +
548
			"		System.out.println(\"SUCCESS\");\n" +
549
			"	}\n" +
550
			"	public static void main(String[] args) {\n" + 
551
			"		X.testFunction(new X<>());\n" + 
552
			"		X.testFunction(new X(\"hello\"));\n" +
553
			"	}\n" +
554
			"}",
555
		},
556
		"1\n" + 
557
		"2");
558
}
559
//shows the difference between using <> and the raw type - different semantics
560
public void _test008() {
561
	this.runConformTest(
562
		new String[] {
563
			"X.java",
564
			"public class X<T> {\n" +
565
			"	T field1;" +
566
			"	public X(T param){\n" +
567
			"		field1 = param;\n" +
568
			"	}\n" +
569
			"	public static void main(String[] args) {\n" + 
570
			"		X<?> x1 = new X(1).get(\"\");\n" + // ok - passing String where Object is expected
571
			"		X<?> x2 = new X<>(1).get(\"\");\n" + // bad - passing String where Integer is expected
572
			"	}\n" +
573
			"	public X<T> get(T t){\n" +
574
			"		return this;" +
575
			"	}\n" + 
576
			"}",
577
		},
578
		"1\n" + 
579
		"2");
580
}
581
public void test009() {
582
	this.runNegativeTest(
583
		new String[] {
584
			"X.java",
585
			"public class X<T> {\n" +
586
			"	public static void main(String[] args) {\n" + 
587
			"		X<>[] x1 = null;\n" +
588
			"	}\n" +
589
			"}",
590
		},
591
		"----------\n" + 
592
		"1. ERROR in X.java (at line 3)\n" + 
593
		"	X<>[] x1 = null;\n" + 
594
		"	^\n" + 
595
		"Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>\n" + 
596
		"----------\n");
597
}
598
public void test009a() {
599
	this.runNegativeTest(
600
		new String[] {
601
			"X.java",
602
			"public class X<T> {\n" +
603
			"	X<>[] x1 = null;\n" +
604
			"}",
605
		},
606
		"----------\n" + 
607
		"1. ERROR in X.java (at line 2)\n" + 
608
		"	X<>[] x1 = null;\n" + 
609
		"	^\n" + 
610
		"Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>\n" + 
611
		"----------\n");
612
}
613
public void test010() {
614
	this.runNegativeTest(
615
		new String[] {
616
			"X.java",
617
			"public class X<T> {\n" +
618
			"	public static void main(String[] args) {\n" + 
619
			"		X<> x1 = null;\n" + 
620
			"	}\n" +
621
			"}",
622
		},
623
		"----------\n" + 
624
		"1. ERROR in X.java (at line 3)\n" + 
625
		"	X<> x1 = null;\n" + 
626
		"	^\n" + 
627
		"Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>\n" + 
628
		"----------\n");
629
}
630
public void test010a() {
631
	this.runNegativeTest(
632
		new String[] {
633
			"X.java",
634
			"public class X<T> {\n" +
635
			"	X<> f1 = null;\n" + 
636
			"}",
637
		},
638
		"----------\n" + 
639
		"1. ERROR in X.java (at line 2)\n" + 
640
		"	X<> f1 = null;\n" + 
641
		"	^\n" + 
642
		"Incorrect number of arguments for type X<>; it cannot be parameterized with arguments <>\n" + 
643
		"----------\n");
644
}
645
public void test011() {
646
	this.runNegativeTest(
647
		new String[] {
648
			"X.java",
649
			"public class X<T> {\n" +
650
			"	public void foo(X<> args) {\n" + 
651
			"	}\n" +
652
			"}",
653
		},
654
		"----------\n" + 
655
		"1. ERROR in X.java (at line 2)\n" + 
656
		"	public void foo(X<> args) {\n" + 
657
		"	                ^\n" + 
658
		"Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>\n" + 
659
		"----------\n");
660
}
661
// To be activated if we introduce a warning to be raised when <> can be used but is not used.
662
public void _test012() {
663
	Map options = getCompilerOptions();
664
	//options.put(CompilerOptions.OPTION_ReportRedundantDeclarationOfTypeArguments, CompilerOptions.ERROR);
665
	this.runNegativeTest(
666
		new String[] {
667
			"X.java",
668
			"public class X<T> {\n" +
669
			"	X<String> f1 = new X<String>();\n" +
670
			"	public void foo() {\n" +
671
			"		X<Integer> i1 = new X<Integer>();\n" +
672
			"	}\n" +
673
			"}",
674
		},
675
		"----------\n" + 
676
		"1. ERROR in X.java (at line 2)\n" + 
677
		"	X<String> f1 = new X<String>();\n" + 
678
		"	               ^^^^^^^^^^^^^^^\n" + 
679
		"Redundant declaration of type arguments <String>\n" + 
680
		"----------\n" + 
681
		"2. ERROR in X.java (at line 4)\n" + 
682
		"	X<Integer> i1 = new X<Integer>();\n" + 
683
		"	                ^^^^^^^^^^^^^^^^\n" + 
684
		"Redundant declaration of type arguments <Integer>\n" + 
685
		"----------\n",
686
		null,
687
		true,
688
		options);
689
}
690
// To be activated if we introduce a warning to be raised when <> can be used but is not used.
691
public void _test013a() {
692
	Map options = getCompilerOptions();
693
	//options.put(CompilerOptions.OPTION_ReportRedundantDeclarationOfTypeArguments, CompilerOptions.ERROR);
694
	this.runConformTest(
695
		new String[] {
696
			"X.java",
697
			"public class X<T> {\n" +
698
			"	class Y<U>{}\n" +
699
			"	Y<String> f1 = new Y();\n" +
700
			"	public static void main(String[] args) {\n" +
701
			"		X<Integer> i1 = new X<>();\n" +
702
			"		System.out.println(\"SUCCESS\");\n" +
703
			"	}\n" +
704
			"}",
705
		},
706
		"SUCCESS",
707
		null,
708
		true,
709
		null,
710
		options,
711
		null);
712
}
713
public void test0014() {
714
	this.runConformTest(
715
		new String[] {
716
			"X.java",
717
			"public class X<J,K> {\n" + 
718
			"	public static void main(String[] args) {\n" + 
719
			"		X<String,Integer> x = new X<>();\n" + 
720
			"		x.testFunction(\"SUCCESS\", 123);\n" + 
721
			"	}\n" +
722
			"	public void testFunction(J param, K param2){\n" +
723
			"		System.out.println(param);\n" +
724
			"		System.out.println(param2);\n" +
725
			"	}\n" + 
726
			"}",
727
		},
728
		"SUCCESS\n" +
729
		"123");
730
}
731
public void test0014a() {
732
	this.runNegativeTest(
733
		new String[] {
734
			"X.java",
735
			"public class X<J,K> {\n" + 
736
			"	public static void main(String[] args) {\n" + 
737
			"		X<String,Integer> x = new X<>();\n" + 
738
			"		x.testFunction(123, \"SUCCESS\");\n" + 
739
			"	}\n" +
740
			"	public void testFunction(J param, K param2){\n" +
741
			"		System.out.println(param);\n" +
742
			"		System.out.println(param2);\n" +
743
			"	}\n" + 
744
			"}",
745
		},
746
		"----------\n" + 
747
		"1. ERROR in X.java (at line 4)\n" + 
748
		"	x.testFunction(123, \"SUCCESS\");\n" + 
749
		"	  ^^^^^^^^^^^^\n" + 
750
		"The method testFunction(String, Integer) in the type X<String,Integer> is not applicable for the arguments (int, String)\n" + 
751
		"----------\n");
752
}
753
public void test0015() {
754
	this.runConformTest(
755
		new String[] {
756
			"X.java",
757
			"public class X<T> {\n" +
758
			"	X(){\n" +
759
			"		System.out.println(\"const.1\");\n" +
760
			"	}\n" +
761
			"	X (T t) {\n" +
762
			"		System.out.println(\"const.2\");\n" +
763
			"	}\n" + 
764
			"	public static void main(String[] args) {\n" + 
765
			"		X<String> x = new X<>();\n" + 
766
			"		X<String> x2 = new X<>(\"\");\n" + 
767
			"	}\n" +
768
			"}",
769
		},
770
		"const.1\nconst.2");
771
}
772
// To verify that a parameterized invocation of a generic constructor works even if <> is used
773
// to elide class type parameters.
774
public void test0016() {
775
	this.runConformTest(
776
		new String[] {
777
			"X.java",
778
			"public class X<T> {\n" +
779
			"	<E> X(){\n" +
780
			"		System.out.println(\"const.1\");\n" +
781
			"	}\n" +
782
			"	<K,J> X (Integer i) {\n" +
783
			"		System.out.println(\"const.2\");\n" +
784
			"	}\n" + 
785
			"	public static void main(String[] args) {\n" + 
786
			"		X<String> x = new <String>X<>();\n" + 
787
			"		X<String> x2 = new <String, Integer>X<>(1);\n" + 
788
			"	}\n" +
789
			"}",
790
		},
791
		"const.1\nconst.2");
792
}
793
// To verify that a parameterized invocation of a generic constructor works even if <> is used
794
// to elide class type parameters. This test handles fields
795
public void test0016b() {
796
	this.runConformTest(
797
		new String[] {
798
			"X.java",
799
			"public class X<T> {\n" +
800
			"	X<String> x;\n" +
801
			"	X<String> x2;\n" +
802
			"	<E> X(){\n" +
803
			"		System.out.println(\"const.1\");\n" +
804
			"	}\n" +
805
			"	<K,J> X (Integer i) {\n" +
806
			"		System.out.println(\"const.2\");\n" +
807
			"	}\n" + 
808
			"	public static void main(String[] args) {\n" +
809
			"		X<Integer> test = new <String>X<>();\n" + 
810
			"		test.x = new <String>X<>();\n" + 
811
			"		test.x2 = new <String, Integer>X<>(1);\n" + 
812
			"	}\n" +
813
			"}",
814
		},
815
		"const.1\nconst.1\nconst.2");
816
}
817
// To verify that a parameterized invocation of a non-generic constructor works even if <> is used
818
// to elide class type parameters.
819
// This was not allowed in java 1.6 and 1.5 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=168230)
820
public void test0017() {
821
	this.runConformTest(
822
		new String[] {
823
			"X.java",
824
			"public class X<T> {\n" +
825
			"	X(int i){\n" +
826
			"		System.out.println(\"const.1\");\n" +
827
			"	}\n" +
828
			"	<K,J> X (Integer i) {\n" +
829
			"		System.out.println(\"const.2\");\n" +
830
			"	}\n" + 
831
			"	public static void main(String[] args) {\n" + 
832
			"		X<String> x = new X<>(1);\n" + 
833
			"		X<String> x2 = new <String, Integer>X<>(1);\n" +
834
			"		Integer i = 1;\n" + 
835
			"		X<String> x3 = new <String, Integer>X<>(i);\n" + 
836
			"	}\n" +
837
			"}",
838
		},
839
		"const.1\nconst.1\nconst.2");
840
}
841
// To verify that the correct constructor is found by parameter substitution in the diamond case
842
public void test0018() {
843
	this.runConformTest(
844
		new String[] {
845
			"X.java",
846
			"public class X<T> {\n" +
847
			"	X(T t){\n" +
848
			"		System.out.println(\"const.1\");\n" +
849
			"	}\n" +
850
			"	X (T t, Integer i) {\n" +
851
			"		System.out.println(\"const.2\");\n" +
852
			"	}\n" + 
853
			"	public static void main(String[] args) {\n" + 
854
			"		X x = new X<>(\"\");\n" + 
855
			"		X x2 = new X<>(\"\",1);\n" +
856
			"	}\n" +
857
			"}",
858
		},
859
		"const.1\nconst.2");
860
}
861
// To verify that the correct constructor is found by parameter substitution 
862
// in the diamond case -- fields
863
public void test0018b() {
864
	this.runConformTest(
865
		new String[] {
866
			"X.java",
867
			"public class X<T> {\n" +
868
			"	X f1;\n" + 
869
			"	X f2;\n" +
870
			"	X(T t){\n" +
871
			"		System.out.println(\"const.1\");\n" +
872
			"	}\n" +
873
			"	X (T t, Integer i) {\n" +
874
			"		System.out.println(\"const.2\");\n" +
875
			"	}\n" + 
876
			"	public static void main(String[] args) {\n" +
877
			"		X x = new X<>(\"\");\n" + 
878
			"		x.f1 = new X<>(\"\");\n" +
879
			"		x.f2 = new X<>(\"\",1);\n" + 
880
			"	}\n" +
881
			"}",
882
		},
883
		"const.1\nconst.1\nconst.2");
884
}
885
public static Class testClass() {
886
	return GenericsRegressionTest_1_7.class;
887
}
888
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java (+1 lines)
Lines 172-177 Link Here
172
		tests_1_7.add(UnderscoresInLiteralsTest.class);
172
		tests_1_7.add(UnderscoresInLiteralsTest.class);
173
		tests_1_7.add(TryStatement17Test.class);
173
		tests_1_7.add(TryStatement17Test.class);
174
		tests_1_7.add(TryWithResourcesStatementTest.class);
174
		tests_1_7.add(TryWithResourcesStatementTest.class);
175
		tests_1_7.add(GenericsRegressionTest_1_7.class);
175
		// Reset forgotten subsets tests
176
		// Reset forgotten subsets tests
176
		TestCase.TESTS_PREFIX = null;
177
		TestCase.TESTS_PREFIX = null;
177
		TestCase.TESTS_NAMES = null;
178
		TestCase.TESTS_NAMES = null;

Return to bug 339478