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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (+3 lines)
Lines 79-84 Link Here
79
}
79
}
80
80
81
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
81
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
82
	if (!valueRequired && this.resolvedType.isCompatibleWith(currentScope.getJavaLangThrowable()))
83
		currentScope.problemReporter().unusedThrowableAllocation(this);
84
82
	int pc = codeStream.position;
85
	int pc = codeStream.position;
83
	ReferenceBinding allocatedType = this.codegenBinding.declaringClass;
86
	ReferenceBinding allocatedType = this.codegenBinding.declaringClass;
84
87
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (+2 lines)
Lines 601-606 Link Here
601
858 = The parameterized constructor <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4})
601
858 = The parameterized constructor <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4})
602
859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}>
602
859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}>
603
603
604
888 = Allocating an instance of a throwable type, which is never used. Perhaps you meant to throw it?
605
604
### ELABORATIONS
606
### ELABORATIONS
605
## Access restrictions
607
## Access restrictions
606
78592 = The type {1} is not accessible due to restriction on classpath entry {0}
608
78592 = The type {1} is not accessible due to restriction on classpath entry {0}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (+12 lines)
Lines 318-323 Link Here
318
318
319
		case IProblem.ComparingIdentical:
319
		case IProblem.ComparingIdentical:
320
			return CompilerOptions.ComparingIdentical;
320
			return CompilerOptions.ComparingIdentical;
321
			
322
		case IProblem.UnusedThrowableAllocation:
323
			return CompilerOptions.UnusedThrowableAllocation;
321
	}
324
	}
322
	return 0;
325
	return 0;
323
}
326
}
Lines 410-415 Link Here
410
				case (int)(CompilerOptions.FallthroughCase >>> 32):
413
				case (int)(CompilerOptions.FallthroughCase >>> 32):
411
				case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32):
414
				case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32):
412
				case (int)(CompilerOptions.ComparingIdentical >>> 32):
415
				case (int)(CompilerOptions.ComparingIdentical >>> 32):
416
				case (int)(CompilerOptions.UnusedThrowableAllocation >>> 32):
413
					return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
417
					return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
414
418
415
				case (int)(CompilerOptions.TypeHiding >>> 32):
419
				case (int)(CompilerOptions.TypeHiding >>> 32):
Lines 7058-7063 Link Here
7058
		typeDecl.sourceStart,
7062
		typeDecl.sourceStart,
7059
		typeDecl.sourceEnd);
7063
		typeDecl.sourceEnd);
7060
}
7064
}
7065
public void unusedThrowableAllocation(AllocationExpression allocationExpression) {
7066
	this.handle(
7067
		IProblem.UnusedThrowableAllocation, 
7068
		NoArgument, 
7069
		NoArgument, 
7070
		allocationExpression.sourceStart, 
7071
		allocationExpression.sourceEnd);
7072
}
7061
public void unusedWarningToken(Expression token) {
7073
public void unusedWarningToken(Expression token) {
7062
	String[] arguments = new String[] { token.constant.stringValue() };
7074
	String[] arguments = new String[] { token.constant.stringValue() };
7063
	this.handle(
7075
	this.handle(
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (-2 / +13 lines)
Lines 120-125 Link Here
120
	public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
120
	public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
121
	public static final String OPTION_ReportRedundantSuperinterface =  "org.eclipse.jdt.core.compiler.problem.redundantSuperinterface"; //$NON-NLS-1$
121
	public static final String OPTION_ReportRedundantSuperinterface =  "org.eclipse.jdt.core.compiler.problem.redundantSuperinterface"; //$NON-NLS-1$
122
	public static final String OPTION_ReportComparingIdentical =  "org.eclipse.jdt.core.compiler.problem.comparingIdentical"; //$NON-NLS-1$
122
	public static final String OPTION_ReportComparingIdentical =  "org.eclipse.jdt.core.compiler.problem.comparingIdentical"; //$NON-NLS-1$
123
	public static final String OPTION_ReportUnusedThrowableAllocation = "org.eclipse.jdt.core.compiler.problem.unusedThrowableAllocation";  //$NON-NLS-1$
123
124
124
	// Backward compatibility
125
	// Backward compatibility
125
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
126
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
Lines 215-220 Link Here
215
	public static final long UnusedWarningToken = ASTNode.Bit55L;
216
	public static final long UnusedWarningToken = ASTNode.Bit55L;
216
	public static final long RedundantSuperinterface = ASTNode.Bit56L;
217
	public static final long RedundantSuperinterface = ASTNode.Bit56L;
217
	public static final long ComparingIdentical = ASTNode.Bit57L;
218
	public static final long ComparingIdentical = ASTNode.Bit57L;
219
	public static final long UnusedThrowableAllocation = ASTNode.Bit58L;
218
220
219
	// Map: String optionKey --> Long irritant>
221
	// Map: String optionKey --> Long irritant>
220
	private static Map OptionToIrritants;
222
	private static Map OptionToIrritants;
Lines 251-257 Link Here
251
		| UnusedTypeArguments
253
		| UnusedTypeArguments
252
		| NullReference
254
		| NullReference
253
		| UnusedWarningToken
255
		| UnusedWarningToken
254
		| ComparingIdentical;
256
		| ComparingIdentical
257
		| UnusedThrowableAllocation;
255
258
256
	// By default only lines and source attributes are generated.
259
	// By default only lines and source attributes are generated.
257
	public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
260
	public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
Lines 463-468 Link Here
463
		optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED);
466
		optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED);
464
		optionsMap.put(OPTION_ReportRedundantSuperinterface, getSeverityString(RedundantSuperinterface));
467
		optionsMap.put(OPTION_ReportRedundantSuperinterface, getSeverityString(RedundantSuperinterface));
465
		optionsMap.put(OPTION_ReportComparingIdentical, getSeverityString(ComparingIdentical));
468
		optionsMap.put(OPTION_ReportComparingIdentical, getSeverityString(ComparingIdentical));
469
		optionsMap.put(OPTION_ReportUnusedThrowableAllocation, getSeverityString(UnusedThrowableAllocation));
466
		return optionsMap;
470
		return optionsMap;
467
	}
471
	}
468
472
Lines 595-600 Link Here
595
					return OPTION_ReportRedundantSuperinterface;
599
					return OPTION_ReportRedundantSuperinterface;
596
				case (int)(ComparingIdentical >>> 32) :
600
				case (int)(ComparingIdentical >>> 32) :
597
					return OPTION_ReportComparingIdentical;
601
					return OPTION_ReportComparingIdentical;
602
				case (int)(UnusedThrowableAllocation >>> 32) :
603
					return OPTION_ReportUnusedThrowableAllocation;
598
			}
604
			}
599
		}
605
		}
600
		return null;
606
		return null;
Lines 884-889 Link Here
884
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedTypeArgumentsForMethodInvocation)) != null) updateSeverity(UnusedTypeArguments, optionValue);
890
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedTypeArgumentsForMethodInvocation)) != null) updateSeverity(UnusedTypeArguments, optionValue);
885
		if ((optionValue = optionsMap.get(OPTION_ReportRedundantSuperinterface)) != null) updateSeverity(RedundantSuperinterface, optionValue);
891
		if ((optionValue = optionsMap.get(OPTION_ReportRedundantSuperinterface)) != null) updateSeverity(RedundantSuperinterface, optionValue);
886
		if ((optionValue = optionsMap.get(OPTION_ReportComparingIdentical)) != null) updateSeverity(ComparingIdentical, optionValue);
892
		if ((optionValue = optionsMap.get(OPTION_ReportComparingIdentical)) != null) updateSeverity(ComparingIdentical, optionValue);
893
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedThrowableAllocation)) != null) updateSeverity(UnusedThrowableAllocation, optionValue);
894
887
895
888
		// Javadoc options
896
		// Javadoc options
889
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
897
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
Lines 1081-1086 Link Here
1081
		buf.append("\n\t- unused type arguments for method/constructor invocation: ").append(getSeverityString(UnusedTypeArguments)); //$NON-NLS-1$
1089
		buf.append("\n\t- unused type arguments for method/constructor invocation: ").append(getSeverityString(UnusedTypeArguments)); //$NON-NLS-1$
1082
		buf.append("\n\t- redundant superinterface: ").append(getSeverityString(RedundantSuperinterface)); //$NON-NLS-1$
1090
		buf.append("\n\t- redundant superinterface: ").append(getSeverityString(RedundantSuperinterface)); //$NON-NLS-1$
1083
		buf.append("\n\t- comparing identical expr: ").append(getSeverityString(ComparingIdentical)); //$NON-NLS-1$
1091
		buf.append("\n\t- comparing identical expr: ").append(getSeverityString(ComparingIdentical)); //$NON-NLS-1$
1092
		buf.append("\n\t- unused instantiation of throwable: ").append(getSeverityString(UnusedThrowableAllocation)); //$NON-NLS-1$
1093
		
1084
		return buf.toString();
1094
		return buf.toString();
1085
	}
1095
	}
1086
1096
Lines 1283-1288 Link Here
1283
				case (int) (UnusedLabel >>> 32):
1293
				case (int) (UnusedLabel >>> 32):
1284
				case (int) (UnusedTypeArguments >>> 32) :
1294
				case (int) (UnusedTypeArguments >>> 32) :
1285
				case (int) (RedundantSuperinterface >>> 32) :
1295
				case (int) (RedundantSuperinterface >>> 32) :
1296
				case (int) (UnusedThrowableAllocation >>> 32):
1286
					return "unused"; //$NON-NLS-1$
1297
					return "unused"; //$NON-NLS-1$
1287
				case (int) (DiscouragedReference >>> 32) :
1298
				case (int) (DiscouragedReference >>> 32) :
1288
				case (int) (ForbiddenReference >>> 32) :
1299
				case (int) (ForbiddenReference >>> 32) :
Lines 1379-1385 Link Here
1379
				break;
1390
				break;
1380
			case 'u' :
1391
			case 'u' :
1381
				if ("unused".equals(warningToken)) //$NON-NLS-1$
1392
				if ("unused".equals(warningToken)) //$NON-NLS-1$
1382
					return UnusedLocalVariable | UnusedArgument | UnusedPrivateMember | UnusedDeclaredThrownException | UnusedLabel | UnusedImport | UnusedTypeArguments | RedundantSuperinterface;
1393
					return UnusedLocalVariable | UnusedArgument | UnusedPrivateMember | UnusedDeclaredThrownException | UnusedLabel | UnusedImport | UnusedTypeArguments | RedundantSuperinterface | UnusedThrowableAllocation;
1383
				if ("unchecked".equals(warningToken)) //$NON-NLS-1$
1394
				if ("unchecked".equals(warningToken)) //$NON-NLS-1$
1384
					return UncheckedTypeOperation | RawTypeReference;
1395
					return UncheckedTypeOperation | RawTypeReference;
1385
				if ("unqualified-field-access".equals(warningToken)) //$NON-NLS-1$
1396
				if ("unqualified-field-access".equals(warningToken)) //$NON-NLS-1$
(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+3 lines)
Lines 1303-1308 Link Here
1303
	/** @since 3.1 */
1303
	/** @since 3.1 */
1304
	int JavadocTypeArgumentsForRawGenericConstructor = Javadoc + Internal + 859;
1304
	int JavadocTypeArgumentsForRawGenericConstructor = Javadoc + Internal + 859;
1305
1305
1306
	/** @since 3.5 */
1307
	int UnusedThrowableAllocation = Internal + 888;
1308
	
1306
	/**
1309
	/**
1307
	 * External problems -- These are problems defined by other plugins
1310
	 * External problems -- These are problems defined by other plugins
1308
	 */
1311
	 */

Return to bug 236385