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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java (+23 lines)
Lines 57-76 Link Here
57
			int caseIndex = 0;
57
			int caseIndex = 0;
58
			if (statements != null) {
58
			if (statements != null) {
59
				boolean didAlreadyComplain = false;
59
				boolean didAlreadyComplain = false;
60
				byte fallThroughState = 0;
61
					// 0: start or reset
62
					// 1: previous statement is a case
63
				    // 2: previous statement is a non fall-through statement
64
				    // 9: previous statement is a non case, fall-through statement
60
				for (int i = 0, max = statements.length; i < max; i++) {
65
				for (int i = 0, max = statements.length; i < max; i++) {
61
					Statement statement = statements[i];
66
					Statement statement = statements[i];
62
					if ((caseIndex < caseCount) && (statement == cases[caseIndex])) { // statement is a case
67
					if ((caseIndex < caseCount) && (statement == cases[caseIndex])) { // statement is a case
63
						this.scope.enclosingCase = cases[caseIndex]; // record entering in a switch case block
68
						this.scope.enclosingCase = cases[caseIndex]; // record entering in a switch case block
64
						caseIndex++;
69
						caseIndex++;
70
						if (fallThroughState == 9
71
								&& (statement.bits & ASTNode.Bit19) == 0) { // the case is not fall-through protected by a line comment
72
							scope.problemReporter().possibleFallThroughCase(this.scope.enclosingCase);
73
						}
65
						caseInits = caseInits.mergedWith(flowInfo.unconditionalInits());
74
						caseInits = caseInits.mergedWith(flowInfo.unconditionalInits());
66
						didAlreadyComplain = false; // reset complaint
75
						didAlreadyComplain = false; // reset complaint
76
						fallThroughState = 1;
67
					} else if (statement == defaultCase) { // statement is the default case
77
					} else if (statement == defaultCase) { // statement is the default case
68
						this.scope.enclosingCase = defaultCase; // record entering in a switch case block
78
						this.scope.enclosingCase = defaultCase; // record entering in a switch case block
79
						if (fallThroughState == 9 && (statement.bits & ASTNode.Bit19) == 0) {
80
							scope.problemReporter().possibleFallThroughCase(this.scope.enclosingCase);
81
						}
69
						caseInits = caseInits.mergedWith(flowInfo.unconditionalInits());
82
						caseInits = caseInits.mergedWith(flowInfo.unconditionalInits());
70
						didAlreadyComplain = false; // reset complaint
83
						didAlreadyComplain = false; // reset complaint
84
						fallThroughState = 1;
85
					}
86
					else {
87
						fallThroughState = 0; // reset
71
					}
88
					}
72
					if (!statement.complainIfUnreachable(caseInits, scope, didAlreadyComplain)) {
89
					if (!statement.complainIfUnreachable(caseInits, scope, didAlreadyComplain)) {
73
						caseInits = statement.analyseCode(scope, switchContext, caseInits);
90
						caseInits = statement.analyseCode(scope, switchContext, caseInits);
91
						if ((caseInits.tagBits & FlowInfo.UNREACHABLE) != 0) {
92
							fallThroughState = 2;
93
						}
94
						else if (fallThroughState != 1) {
95
							fallThroughState = 9; // non case, fall-through statement
96
						}
74
					} else {
97
					} else {
75
						didAlreadyComplain = true;
98
						didAlreadyComplain = true;
76
					}
99
					}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-1 / +1 lines)
Lines 40-46 Link Here
40
	public final static int Bit16 = 0x8000; 				// in javadoc comment (name ref, type ref, msg)
40
	public final static int Bit16 = 0x8000; 				// in javadoc comment (name ref, type ref, msg)
41
	public final static int Bit17 = 0x10000; 				// compound assigned (reference lhs)
41
	public final static int Bit17 = 0x10000; 				// compound assigned (reference lhs)
42
	public final static int Bit18 = 0x20000;				// non null (expression)				
42
	public final static int Bit18 = 0x20000;				// non null (expression)				
43
	public final static int Bit19 = 0x40000; 
43
	public final static int Bit19 = 0x40000; 				// fall-through protected (case statement)
44
	public final static int Bit20 = 0x80000; 
44
	public final static int Bit20 = 0x80000; 
45
	public final static int Bit21 = 0x100000; 		
45
	public final static int Bit21 = 0x100000; 		
46
	public final static int Bit22 = 0x200000; 			// parenthesis count (expression)
46
	public final static int Bit22 = 0x200000; 			// parenthesis count (expression)
(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+3 lines)
Lines 74-79 Link Here
74
 *								   InvalidDigit
74
 *								   InvalidDigit
75
 *     IBM Corporation - added the following constants
75
 *     IBM Corporation - added the following constants
76
 *								   ParameterAssignment
76
 *								   ParameterAssignment
77
 *								   PossibleFallThroughCase
77
 *******************************************************************************/
78
 *******************************************************************************/
78
package org.eclipse.jdt.core.compiler;
79
package org.eclipse.jdt.core.compiler;
79
 
80
 
Lines 406-411 Link Here
406
	// switch       
407
	// switch       
407
	int IncorrectSwitchType = TypeRelated + 169;
408
	int IncorrectSwitchType = TypeRelated + 169;
408
	int DuplicateCase = FieldRelated + 170;
409
	int DuplicateCase = FieldRelated + 170;
410
	/** @since 3.2 */
411
	int PossibleFallThroughCase = Internal + 861;
409
	// labelled
412
	// labelled
410
	int DuplicateLabel = Internal + 171;
413
	int DuplicateLabel = Internal + 171;
411
	int InvalidBreak = Internal + 172;
414
	int InvalidBreak = Internal + 172;
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (+1 lines)
Lines 143-148 Link Here
143
\      discouraged        + use of types matching a discouraged access rule\n\
143
\      discouraged        + use of types matching a discouraged access rule\n\
144
\      emptyBlock           undocumented empty block\n\
144
\      emptyBlock           undocumented empty block\n\
145
\      enumSwitch           incomplete enum switch\n\
145
\      enumSwitch           incomplete enum switch\n\
146
\      fallThrough          possible fall-through case\n\
146
\      fieldHiding          field hiding another variable\n\
147
\      fieldHiding          field hiding another variable\n\
147
\      finalBound           type parameter with final bound\n\
148
\      finalBound           type parameter with final bound\n\
148
\      finally            + finally block not completing normally\n\
149
\      finally            + finally block not completing normally\n\
(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (+4 lines)
Lines 1962-1967 Link Here
1962
						this.options.put(
1962
						this.options.put(
1963
							CompilerOptions.OPTION_ReportForbiddenReference,
1963
							CompilerOptions.OPTION_ReportForbiddenReference,
1964
							isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
1964
							isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
1965
					} else if (token.equals("fallThrough")) { //$NON-NLS-1$
1966
						this.options.put(
1967
							CompilerOptions.OPTION_ReportPossibleFallThroughCase,
1968
							isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
1965
					} else {
1969
					} else {
1966
						throw new InvalidInputException(Main.bind("configure.invalidWarning", token)); //$NON-NLS-1$
1970
						throw new InvalidInputException(Main.bind("configure.invalidWarning", token)); //$NON-NLS-1$
1967
					}
1971
					}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (+1 lines)
Lines 562-564 Link Here
562
859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}>
562
859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}>
563
563
564
860 = The parameter {0} should not be assigned
564
860 = The parameter {0} should not be assigned
565
861 = Possible fall-through case
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (+11 lines)
Lines 1535-1540 Link Here
1535
1535
1536
		case IProblem.ParameterAssignment:
1536
		case IProblem.ParameterAssignment:
1537
			return CompilerOptions.ParameterAssignment;
1537
			return CompilerOptions.ParameterAssignment;
1538
1539
		case IProblem.PossibleFallThroughCase:
1540
			return CompilerOptions.PossibleFallThroughCase;
1538
	}
1541
	}
1539
	return 0;
1542
	return 0;
1540
}
1543
}
Lines 4927-4932 Link Here
4927
		start,
4930
		start,
4928
		end);
4931
		end);
4929
}
4932
}
4933
public void possibleFallThroughCase(CaseStatement caseStatement) {
4934
	this.handle(
4935
		IProblem.PossibleFallThroughCase,
4936
		NoArgument,
4937
		NoArgument,
4938
		caseStatement.sourceStart,
4939
		caseStatement.sourceEnd);
4940
}
4930
public void possibleAccidentalBooleanAssignment(Assignment assignment) {
4941
public void possibleAccidentalBooleanAssignment(Assignment assignment) {
4931
	this.handle(
4942
	this.handle(
4932
		IProblem.PossibleAccidentalBooleanAssignment,
4943
		IProblem.PossibleAccidentalBooleanAssignment,
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-2 / +14 lines)
Lines 1722-1728 Link Here
1722
	// SwitchLabel ::= 'case' ConstantExpression ':'
1722
	// SwitchLabel ::= 'case' ConstantExpression ':'
1723
	this.expressionLengthPtr--;
1723
	this.expressionLengthPtr--;
1724
	Expression expression = this.expressionStack[this.expressionPtr--];
1724
	Expression expression = this.expressionStack[this.expressionPtr--];
1725
	pushOnAstStack(new CaseStatement(expression, expression.sourceEnd, this.intStack[this.intPtr--]));
1725
	CaseStatement caseStatement =
1726
		new CaseStatement(expression, expression.sourceEnd, this.intStack[this.intPtr--]);
1727
	if (this.scanner.protectedFallThroughCase) {
1728
		caseStatement.bits |= ASTNode.Bit19;
1729
		this.scanner.protectedFallThroughCase = false;
1730
	}
1731
	pushOnAstStack(caseStatement);
1726
}
1732
}
1727
protected void consumeCastExpressionLL1() {
1733
protected void consumeCastExpressionLL1() {
1728
	//CastExpression ::= '(' Expression ')' InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
1734
	//CastExpression ::= '(' Expression ')' InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
Lines 2528-2534 Link Here
2528
}
2534
}
2529
protected void consumeDefaultLabel() {
2535
protected void consumeDefaultLabel() {
2530
	// SwitchLabel ::= 'default' ':'
2536
	// SwitchLabel ::= 'default' ':'
2531
	pushOnAstStack(new CaseStatement(null, this.intStack[this.intPtr--], this.intStack[this.intPtr--]));
2537
	CaseStatement defaultStatement = 
2538
		new CaseStatement(null, this.intStack[this.intPtr--], this.intStack[this.intPtr--]);
2539
	if (this.scanner.protectedFallThroughCase) {
2540
		defaultStatement.bits |= ASTNode.Bit19;
2541
		this.scanner.protectedFallThroughCase = false;
2542
	}
2543
	pushOnAstStack(defaultStatement);
2532
}
2544
}
2533
protected void consumeDefaultModifiers() {
2545
protected void consumeDefaultModifiers() {
2534
	checkComment(); // might update modifiers with AccDeprecated
2546
	checkComment(); // might update modifiers with AccDeprecated
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java (-3 / +32 lines)
Lines 92-97 Link Here
92
	public int[] lineEnds = new int[250];
92
	public int[] lineEnds = new int[250];
93
	public int linePtr = -1;
93
	public int linePtr = -1;
94
	public boolean wasAcr = false;
94
	public boolean wasAcr = false;
95
	
96
	// support for line comments/case statement interaction
97
	byte fallThroughCaseProtectionState = 0;
98
		// -1: just passed a protection comment
99
		// 0: starting a case/default with protection on OR just passed an end of line
100
		// >0: passed multiple tokens since the last protection comment or end of line
101
	public boolean protectedFallThroughCase = false;
102
		// true iff the current case/default token is protected against fall-through
95
103
96
	public static final String END_OF_SOURCE = "End_Of_Source"; //$NON-NLS-1$
104
	public static final String END_OF_SOURCE = "End_Of_Source"; //$NON-NLS-1$
97
105
Lines 970-975 Link Here
970
						if (this.recordLineSeparator) {
978
						if (this.recordLineSeparator) {
971
							pushLineSeparator();
979
							pushLineSeparator();
972
						}
980
						}
981
						else {
982
							this.fallThroughCaseProtectionState = 0;
983
							// because the pass which records line separators is disjoint
984
							// from the pass which reduces rules involving case/default
985
						}
973
					}
986
					}
974
					// inline version of:
987
					// inline version of:
975
					//isWhiteSpace = 
988
					//isWhiteSpace = 
Lines 1007-1012 Link Here
1007
				}
1020
				}
1008
			}
1021
			}
1009
			// ---------Identify the next token-------------
1022
			// ---------Identify the next token-------------
1023
			this.fallThroughCaseProtectionState++; // all non white space count
1010
			switch (this.currentCharacter) {
1024
			switch (this.currentCharacter) {
1011
				case '@' :
1025
				case '@' :
1012
/*					if (this.sourceLevel >= ClassFileConstants.JDK1_5) {
1026
/*					if (this.sourceLevel >= ClassFileConstants.JDK1_5) {
Lines 1331-1337 Link Here
1331
				case '/' :
1345
				case '/' :
1332
					{
1346
					{
1333
						int test;
1347
						int test;
1334
						if ((test = getNextChar('/', '*')) == 0) { //line comment 
1348
						if ((test = getNextChar('/', '*')) == 0) { //line comment
1349
							if (this.fallThroughCaseProtectionState == 1) {
1350
								this.fallThroughCaseProtectionState = -1;
1351
							}
1352
							else {
1353
								this.fallThroughCaseProtectionState = 0;
1354
							}
1335
							this.lastCommentLinePosition = this.currentPosition;
1355
							this.lastCommentLinePosition = this.currentPosition;
1336
							try { //get the next char 
1356
							try { //get the next char 
1337
								if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
1357
								if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
Lines 1415-1420 Link Here
1415
							break;
1435
							break;
1416
						}
1436
						}
1417
						if (test > 0) { //traditional and javadoc comment
1437
						if (test > 0) { //traditional and javadoc comment
1438
							this.fallThroughCaseProtectionState = 0;
1418
							try { //get the next char
1439
							try { //get the next char
1419
								boolean isJavadoc = false, star = false;
1440
								boolean isJavadoc = false, star = false;
1420
								boolean isUnicode = false;
1441
								boolean isUnicode = false;
Lines 2695-2702 Link Here
2695
			switch (length) {
2716
			switch (length) {
2696
				case 4 :
2717
				case 4 :
2697
					if (data[++index] == 'a')
2718
					if (data[++index] == 'a')
2698
						if ((data[++index] == 's') && (data[++index] == 'e'))
2719
						if ((data[++index] == 's') && (data[++index] == 'e')) {
2720
							if (this.fallThroughCaseProtectionState == 0) {
2721
								this.protectedFallThroughCase = true; // parser resets it
2722
							}
2699
							return TokenNamecase;
2723
							return TokenNamecase;
2724
						}
2700
						else
2725
						else
2701
							return TokenNameIdentifier;
2726
							return TokenNameIdentifier;
2702
					else
2727
					else
Lines 2762-2769 Link Here
2762
						&& (data[++index] == 'a')
2787
						&& (data[++index] == 'a')
2763
						&& (data[++index] == 'u')
2788
						&& (data[++index] == 'u')
2764
						&& (data[++index] == 'l')
2789
						&& (data[++index] == 'l')
2765
						&& (data[++index] == 't'))
2790
						&& (data[++index] == 't')) {
2791
						if (this.fallThroughCaseProtectionState == 0) {
2792
							this.protectedFallThroughCase = true; // parser resets it
2793
						}
2766
						return TokenNamedefault;
2794
						return TokenNamedefault;
2795
					}
2767
					else
2796
					else
2768
						return TokenNameIdentifier;
2797
						return TokenNameIdentifier;
2769
				default :
2798
				default :
(-)model/org/eclipse/jdt/internal/core/util/PublicScanner.java (-3 / +32 lines)
Lines 90-95 Link Here
90
	public int[] lineEnds = new int[250];
90
	public int[] lineEnds = new int[250];
91
	public int linePtr = -1;
91
	public int linePtr = -1;
92
	public boolean wasAcr = false;
92
	public boolean wasAcr = false;
93
	
94
	// support for line comments/case statement interaction
95
	byte fallThroughCaseProtectionState = 0;
96
		// -1: just passed a protection comment
97
		// 0: starting a case/default with protection on OR just passed an end of line
98
		// >0: passed multiple tokens since the last protection comment or end of line
99
	public boolean protectedFallThroughCase = false;
100
		// true iff the current case/default token is protected against fall-through
93
101
94
	public static final String END_OF_SOURCE = "End_Of_Source"; //$NON-NLS-1$
102
	public static final String END_OF_SOURCE = "End_Of_Source"; //$NON-NLS-1$
95
103
Lines 968-973 Link Here
968
						if (this.recordLineSeparator) {
976
						if (this.recordLineSeparator) {
969
							pushLineSeparator();
977
							pushLineSeparator();
970
						}
978
						}
979
						else {
980
							this.fallThroughCaseProtectionState = 0;
981
							// because the pass which records line separators is disjoint
982
							// from the pass which reduces rules involving case/default
983
						}
971
					}
984
					}
972
					// inline version of:
985
					// inline version of:
973
					//isWhiteSpace = 
986
					//isWhiteSpace = 
Lines 1005-1010 Link Here
1005
				}
1018
				}
1006
			}
1019
			}
1007
			// ---------Identify the next token-------------
1020
			// ---------Identify the next token-------------
1021
			this.fallThroughCaseProtectionState++; // all non white space count
1008
			switch (this.currentCharacter) {
1022
			switch (this.currentCharacter) {
1009
				case '@' :
1023
				case '@' :
1010
/*					if (this.sourceLevel >= ClassFileConstants.JDK1_5) {
1024
/*					if (this.sourceLevel >= ClassFileConstants.JDK1_5) {
Lines 1329-1335 Link Here
1329
				case '/' :
1343
				case '/' :
1330
					{
1344
					{
1331
						int test;
1345
						int test;
1332
						if ((test = getNextChar('/', '*')) == 0) { //line comment 
1346
						if ((test = getNextChar('/', '*')) == 0) { //line comment
1347
							if (this.fallThroughCaseProtectionState == 1) {
1348
								this.fallThroughCaseProtectionState = -1;
1349
							}
1350
							else {
1351
								this.fallThroughCaseProtectionState = 0;
1352
							}
1333
							this.lastCommentLinePosition = this.currentPosition;
1353
							this.lastCommentLinePosition = this.currentPosition;
1334
							try { //get the next char 
1354
							try { //get the next char 
1335
								if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
1355
								if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
Lines 1413-1418 Link Here
1413
							break;
1433
							break;
1414
						}
1434
						}
1415
						if (test > 0) { //traditional and javadoc comment
1435
						if (test > 0) { //traditional and javadoc comment
1436
							this.fallThroughCaseProtectionState = 0;
1416
							try { //get the next char
1437
							try { //get the next char
1417
								boolean isJavadoc = false, star = false;
1438
								boolean isJavadoc = false, star = false;
1418
								boolean isUnicode = false;
1439
								boolean isUnicode = false;
Lines 2693-2700 Link Here
2693
			switch (length) {
2714
			switch (length) {
2694
				case 4 :
2715
				case 4 :
2695
					if (data[++index] == 'a')
2716
					if (data[++index] == 'a')
2696
						if ((data[++index] == 's') && (data[++index] == 'e'))
2717
						if ((data[++index] == 's') && (data[++index] == 'e')) {
2718
							if (this.fallThroughCaseProtectionState == 0) {
2719
								this.protectedFallThroughCase = true; // parser resets it
2720
							}
2697
							return TokenNamecase;
2721
							return TokenNamecase;
2722
						}
2698
						else
2723
						else
2699
							return TokenNameIdentifier;
2724
							return TokenNameIdentifier;
2700
					else
2725
					else
Lines 2760-2767 Link Here
2760
						&& (data[++index] == 'a')
2785
						&& (data[++index] == 'a')
2761
						&& (data[++index] == 'u')
2786
						&& (data[++index] == 'u')
2762
						&& (data[++index] == 'l')
2787
						&& (data[++index] == 'l')
2763
						&& (data[++index] == 't'))
2788
						&& (data[++index] == 't')) {
2789
						if (this.fallThroughCaseProtectionState == 0) {
2790
							this.protectedFallThroughCase = true; // parser resets it
2791
						}
2764
						return TokenNamedefault;
2792
						return TokenNamedefault;
2793
					}
2765
					else
2794
					else
2766
						return TokenNameIdentifier;
2795
						return TokenNameIdentifier;
2767
				default :
2796
				default :
(-)model/org/eclipse/jdt/core/JavaCore.java (+8 lines)
Lines 2263-2268 Link Here
2263
	 *     - possible values:   { "error", "warning", "ignore" }
2263
	 *     - possible values:   { "error", "warning", "ignore" }
2264
	 *     - default:           "ignore"
2264
	 *     - default:           "ignore"
2265
	 * 
2265
	 * 
2266
	 *
2267
	 * COMPILER / Reporting Possible Fall-Through Case
2268
	 *    When enabled, the compiler will issue an error or a warning if a case may be
2269
	 *    reached in sequence from the preceeding, non empty case.
2270
	 *     - option id:         "org.eclipse.jdt.core.compiler.problem.possibleFallThroughCase"
2271
	 *     - possible values:   { "error", "warning", "ignore" }
2272
	 *     - default:           "ignore"
2273
	 * 
2266
	 * BUILDER / Specifying Filters for Resource Copying Control
2274
	 * BUILDER / Specifying Filters for Resource Copying Control
2267
	 *    Allow to specify some filters to control the resource copy process.
2275
	 *    Allow to specify some filters to control the resource copy process.
2268
	 *     - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
2276
	 *     - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (-1 / +10 lines)
Lines 104-109 Link Here
104
	public static final String OPTION_ReportUnusedLabel =  "org.eclipse.jdt.core.compiler.problem.unusedLabel"; //$NON-NLS-1$
104
	public static final String OPTION_ReportUnusedLabel =  "org.eclipse.jdt.core.compiler.problem.unusedLabel"; //$NON-NLS-1$
105
	public static final String OPTION_FatalOptionalError =  "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; //$NON-NLS-1$
105
	public static final String OPTION_FatalOptionalError =  "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; //$NON-NLS-1$
106
	public static final String OPTION_ReportParameterAssignment =  "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$
106
	public static final String OPTION_ReportParameterAssignment =  "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$
107
	public static final String OPTION_ReportPossibleFallThroughCase =  "org.eclipse.jdt.core.compiler.problem.possibleFallThroughCase"; //$NON-NLS-1$
107
	
108
	
108
	// Backward compatibility
109
	// Backward compatibility
109
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
110
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
Lines 187-192 Link Here
187
	public static final long RawTypeReference = ASTNode.Bit46L;
188
	public static final long RawTypeReference = ASTNode.Bit46L;
188
	public static final long UnusedLabel = ASTNode.Bit47L;
189
	public static final long UnusedLabel = ASTNode.Bit47L;
189
	public static final long ParameterAssignment = ASTNode.Bit48L;
190
	public static final long ParameterAssignment = ASTNode.Bit48L;
191
	public static final long PossibleFallThroughCase = ASTNode.Bit49L;
190
	
192
	
191
	// Default severity level for handlers
193
	// Default severity level for handlers
192
	public long errorThreshold = 0;
194
	public long errorThreshold = 0;
Lines 381-387 Link Here
381
		optionsMap.put(OPTION_Source, versionFromJdkLevel(this.sourceLevel)); 
383
		optionsMap.put(OPTION_Source, versionFromJdkLevel(this.sourceLevel)); 
382
		optionsMap.put(OPTION_TargetPlatform, versionFromJdkLevel(this.targetJDK)); 
384
		optionsMap.put(OPTION_TargetPlatform, versionFromJdkLevel(this.targetJDK)); 
383
		optionsMap.put(OPTION_FatalOptionalError, this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); 
385
		optionsMap.put(OPTION_FatalOptionalError, this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); 
384
		
385
		if (this.defaultEncoding != null) {
386
		if (this.defaultEncoding != null) {
386
			optionsMap.put(OPTION_Encoding, this.defaultEncoding); 
387
			optionsMap.put(OPTION_Encoding, this.defaultEncoding); 
387
		}
388
		}
Lines 397-402 Link Here
397
		optionsMap.put(OPTION_SuppressWarnings, this.suppressWarnings ? ENABLED : DISABLED); 
398
		optionsMap.put(OPTION_SuppressWarnings, this.suppressWarnings ? ENABLED : DISABLED); 
398
		optionsMap.put(OPTION_ReportUnhandledWarningToken, getSeverityString(UnhandledWarningToken));
399
		optionsMap.put(OPTION_ReportUnhandledWarningToken, getSeverityString(UnhandledWarningToken));
399
		optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment));
400
		optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment));
401
		optionsMap.put(OPTION_ReportPossibleFallThroughCase, getSeverityString(PossibleFallThroughCase));
400
		return optionsMap;		
402
		return optionsMap;		
401
	}
403
	}
402
	
404
	
Lines 638-643 Link Here
638
		if ((optionValue = optionsMap.get(OPTION_ReportUnhandledWarningToken)) != null) updateSeverity(UnhandledWarningToken, optionValue);
640
		if ((optionValue = optionsMap.get(OPTION_ReportUnhandledWarningToken)) != null) updateSeverity(UnhandledWarningToken, optionValue);
639
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedLabel)) != null) updateSeverity(UnusedLabel, optionValue);
641
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedLabel)) != null) updateSeverity(UnusedLabel, optionValue);
640
		if ((optionValue = optionsMap.get(OPTION_ReportParameterAssignment)) != null) updateSeverity(ParameterAssignment, optionValue);
642
		if ((optionValue = optionsMap.get(OPTION_ReportParameterAssignment)) != null) updateSeverity(ParameterAssignment, optionValue);
643
		if ((optionValue = optionsMap.get(OPTION_ReportPossibleFallThroughCase)) != null) updateSeverity(PossibleFallThroughCase, optionValue);
641
644
642
		// Javadoc options
645
		// Javadoc options
643
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
646
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
Lines 891-896 Link Here
891
			OPTION_ReportOverridingPackageDefaultMethod,
894
			OPTION_ReportOverridingPackageDefaultMethod,
892
			OPTION_ReportParameterAssignment,
895
			OPTION_ReportParameterAssignment,
893
			OPTION_ReportPossibleAccidentalBooleanAssignment,
896
			OPTION_ReportPossibleAccidentalBooleanAssignment,
897
			OPTION_ReportPossibleFallThroughCase,
894
			OPTION_ReportSyntheticAccessEmulation,
898
			OPTION_ReportSyntheticAccessEmulation,
895
			OPTION_ReportTypeParameterHiding,
899
			OPTION_ReportTypeParameterHiding,
896
			OPTION_ReportUncheckedTypeOperation,
900
			OPTION_ReportUncheckedTypeOperation,
Lines 962-967 Link Here
962
					return "restriction"; //$NON-NLS-1$
966
					return "restriction"; //$NON-NLS-1$
963
				case (int) (NullReference >>> 32) :
967
				case (int) (NullReference >>> 32) :
964
					return "null"; //$NON-NLS-1$
968
					return "null"; //$NON-NLS-1$
969
				case (int) (PossibleFallThroughCase >>> 32) :
970
					return "fall-through"; //$NON-NLS-1$
965
			}
971
			}
966
		}
972
		}
967
		return null;
973
		return null;
Lines 972-977 Link Here
972
		"boxing", //$NON-NLS-1$
978
		"boxing", //$NON-NLS-1$
973
		"dep-ann", //$NON-NLS-1$
979
		"dep-ann", //$NON-NLS-1$
974
		"deprecation", //$NON-NLS-1$
980
		"deprecation", //$NON-NLS-1$
981
		"fall-through", //$NON-NLS-1$
975
		"finally", //$NON-NLS-1$
982
		"finally", //$NON-NLS-1$
976
		"hiding", //$NON-NLS-1$
983
		"hiding", //$NON-NLS-1$
977
		"incomplete-switch", //$NON-NLS-1$
984
		"incomplete-switch", //$NON-NLS-1$
Lines 1004-1009 Link Here
1004
					return MissingDeprecatedAnnotation;
1011
					return MissingDeprecatedAnnotation;
1005
				break;
1012
				break;
1006
			case 'f' :
1013
			case 'f' :
1014
				if ("fall-through".equals(warningToken)) //$NON-NLS-1$
1015
					return PossibleFallThroughCase;
1007
				if ("finally".equals(warningToken)) //$NON-NLS-1$
1016
				if ("finally".equals(warningToken)) //$NON-NLS-1$
1008
					return FinallyBlockNotCompleting;
1017
					return FinallyBlockNotCompleting;
1009
				break;
1018
				break;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java (+382 lines)
Lines 160-165 Link Here
160
		null, true, options);
160
		null, true, options);
161
}
161
}
162
162
163
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
164
// [compiler] warning on fall through
165
// basic scenario
166
public void test006() {
167
	Map options = getCompilerOptions();
168
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
169
	this.runNegativeTest(
170
		new String[] {
171
			"X.java",
172
			"public class X {\n" + 
173
			"    public void test(int p) {\n" + 
174
			"        switch (p) {\n" + 
175
			"        case 0:\n" + 
176
			"            System.out.println(0); // silent because first case\n" + 
177
			"        case 1:\n" + 
178
			"            System.out.println(1); // complain: possible fall-through\n" + 
179
			"            break;\n" + 
180
			"        case 2:\n" + 
181
			"            System.out.println(3); // silent because of break\n" + 
182
			"            return;\n" + 
183
			"        case 3:                            // silent because of return\n" + 
184
			"        case 4:                            // silent because grouped cases\n" + 
185
			"        default:\n" + 
186
			"            System.out.println(\"default\"); //$NON-NLS-1$\n" + 
187
			"        }\n" + 
188
			"    }\n" + 
189
			"}"
190
		},
191
		"----------\n" + 
192
		"1. ERROR in X.java (at line 6)\n" + 
193
		"	case 1:\n" + 
194
		"	^^^^^^\n" + 
195
		"Possible fall-through case\n" + 
196
		"----------\n",
197
		null, true, options);
198
}
199
200
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
201
// [compiler] warning on fall through
202
// SuppressWarnings effect - explicit fall-through token
203
public void test007() {
204
	if (COMPLIANCE_1_5.equals(this.complianceLevel)) {
205
		Map options = getCompilerOptions();
206
		options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.WARNING);
207
		this.runNegativeTest(
208
			new String[] {
209
				"X.java",
210
				"public class X {\n" + 
211
				"    @SuppressWarnings(\"fall-through\")\n" + 
212
				"    public void test(int p) {\n" + 
213
				"        switch (p) {\n" + 
214
				"        case 0:\n" + 
215
				"            System.out.println(0); // silent because first case\n" + 
216
				"        case 1:\n" + 
217
				"            System.out.println(1); // silent because of SuppressWarnings\n" + 
218
				"        }\n" + 
219
				"    }\n" +
220
				"	Zork z;\n" + // complain on Zork (unknown type)
221
				"}"
222
			},
223
			"----------\n" + 
224
			"1. ERROR in X.java (at line 11)\n" + 
225
			"	Zork z;\n" + 
226
			"	^^^^\n" + 
227
			"Zork cannot be resolved to a type\n" + 
228
			"----------\n",
229
			null, true, options);
230
	}
231
}
232
233
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
234
// [compiler] warning on fall through
235
// deep return (1)
236
public void test008() {
237
	Map options = getCompilerOptions();
238
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
239
	this.runConformTest(
240
		new String[] {
241
			"X.java",
242
			"public class X {\n" + 
243
			"    public void test(int p) {\n" + 
244
			"        switch (p) {\n" + 
245
			"        case 0:\n" + 
246
			"            System.out.println(0);\n" +
247
			"            if (true) {\n" +
248
			"              return;\n" +
249
			"            }\n" + 
250
			"        case 1:\n" + 
251
			"            System.out.println(1);\n" + 
252
			"        }\n" + 
253
			"    }\n" + 
254
			"}"
255
		},
256
		"",
257
		null, true, null, options, null);
258
}
259
260
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
261
// [compiler] warning on fall through
262
// deep return (2)
263
public void test009() {
264
	Map options = getCompilerOptions();
265
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
266
	this.runConformTest(
267
		new String[] {
268
			"X.java",
269
			"public class X {\n" + 
270
			"    public void test(int p, boolean b) {\n" + 
271
			"        switch (p) {\n" + 
272
			"        case 0:\n" + 
273
			"            System.out.println(0);\n" +
274
			"            if (b) {\n" +
275
			"              return;\n" +
276
			"            }\n" + 
277
			"            else {\n" +
278
			"              return;\n" +
279
			"            }\n" + 
280
			"        case 1:\n" + 
281
			"            System.out.println(1);\n" + 
282
			"        }\n" + 
283
			"    }\n" + 
284
			"}"
285
		},
286
		"",
287
		null, true, null, options, null);
288
}
289
290
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
291
// [compiler] warning on fall through
292
// deep return (3), limit: cannot recognize that we won't return
293
public void test010() {
294
	Map options = getCompilerOptions();
295
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
296
	this.runNegativeTest(
297
		new String[] {
298
			"X.java",
299
			"public class X {\n" + 
300
			"    public void test(int p, boolean b) {\n" + 
301
			"        switch (p) {\n" + 
302
			"        case 0:\n" + 
303
			"            System.exit(0);\n" +
304
			"        case 1:\n" + // complain 
305
			"            System.out.println(1);\n" + 
306
			"        }\n" + 
307
			"    }\n" + 
308
			"}"
309
		},
310
		"----------\n" + 
311
		"1. ERROR in X.java (at line 6)\n" + 
312
		"	case 1:\n" + 
313
		"	^^^^^^\n" + 
314
		"Possible fall-through case\n" + 
315
		"----------\n",
316
		null, true, options);
317
}
318
319
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
320
// [compiler] warning on fall through
321
// SuppressWarnings effect - implicit, using all token
322
public void test011() {
323
	if (COMPLIANCE_1_5.equals(this.complianceLevel)) {
324
		Map options = getCompilerOptions();
325
		options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.WARNING);
326
		this.runNegativeTest(
327
			new String[] {
328
				"X.java",
329
				"public class X {\n" + 
330
				"    @SuppressWarnings(\"all\")\n" + 
331
				"    public void test(int p) {\n" + 
332
				"        switch (p) {\n" + 
333
				"        case 0:\n" + 
334
				"            System.out.println(0); // silent because first case\n" + 
335
				"        case 1:\n" + 
336
				"            System.out.println(1); // silent because of SuppressWarnings\n" + 
337
				"        }\n" + 
338
				"    }\n" +
339
				"	Zork z;\n" + // complain on Zork (unknown type)
340
				"}"
341
			},
342
			"----------\n" + 
343
			"1. ERROR in X.java (at line 11)\n" + 
344
			"	Zork z;\n" + 
345
			"	^^^^\n" + 
346
			"Zork cannot be resolved to a type\n" + 
347
			"----------\n",
348
			null, true, options);
349
	}
350
}
351
352
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
353
// [compiler] warning on fall through
354
// skip because of comment
355
public void test012() {
356
	Map options = getCompilerOptions();
357
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
358
	this.runConformTest(
359
		new String[] {
360
			"X.java",
361
			"public class X {\n" + 
362
			"    public void test(int p) {\n" + 
363
			"        switch (p) {\n" + 
364
			"        case 0:\n" + 
365
			"            System.out.println(0); // silent because first case\n" + 
366
			"            // on purpose fall-through\n" + 
367
			"        case 1:\n" + 
368
			"            System.out.println(1); // silent because of comment alone on its line above \n" + 
369
			"        }\n" + 
370
			"    }\n" + 
371
			"}"
372
		},
373
		"",
374
		null, true, null, options, null);
375
}
376
377
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
378
// [compiler] warning on fall through
379
// skip because of comment - default label
380
public void test013() {
381
	Map options = getCompilerOptions();
382
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
383
	this.runConformTest(
384
		new String[] {
385
			"X.java",
386
			"public class X {\n" + 
387
			"    public void test(int p) {\n" + 
388
			"        switch (p) {\n" + 
389
			"        case 0:\n" + 
390
			"            System.out.println(0); // silent because first case\n" + 
391
			"            // on purpose fall-through\n" + 
392
			"        default:\n" + 
393
			"            System.out.println(1); // silent because of comment alone on its line above \n" + 
394
			"        }\n" + 
395
			"    }\n" + 
396
			"}"
397
		},
398
		"",
399
		null, true, null, options, null);
400
}
401
402
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
403
// [compiler] warning on fall through
404
// basic scenario: default label
405
public void test014() {
406
	Map options = getCompilerOptions();
407
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
408
	this.runNegativeTest(
409
		new String[] {
410
			"X.java",
411
			"public class X {\n" + 
412
			"    public void test(int p) {\n" + 
413
			"        switch (p) {\n" + 
414
			"        case 0:\n" + 
415
			"            System.out.println(0); // silent because first case\n" +
416
						// note: the comment above is not alone on its line, hence it does not
417
						// protect against fall-through diagnostic
418
			"        default:\n" + 
419
			"            System.out.println(1); // complain: possible fall-through\n" + 
420
			"        }\n" + 
421
			"    }\n" + 
422
			"}"
423
		},
424
		"----------\n" + 
425
		"1. ERROR in X.java (at line 6)\n" + 
426
		"	default:\n" + 
427
		"	^^^^^^^\n" + 
428
		"Possible fall-through case\n" + 
429
		"----------\n",
430
		null, true, options);
431
}
432
433
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
434
// [compiler] warning on fall through
435
// skip because of comment - variants
436
public void test015() {
437
	Map options = getCompilerOptions();
438
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
439
	this.runNegativeTest(
440
		new String[] {
441
			"X.java",
442
			"public class X {\n" + 
443
			"    public void test(int p) {\n" + 
444
			"        switch (p) {\n" + 
445
			"        case 0:\n" + 
446
			"            System.out.println(0); // silent because first case\n" + 
447
			"            // on purpose fall-through\n" +
448
			"\n" + // extraneous line breaks fall-through protection 
449
			"        case 1:\n" + 
450
			"            System.out.println(1); // silent because of comment alone on its line above \n" + 
451
			"        }\n" + 
452
			"    }\n" + 
453
			"}"
454
		},
455
		"----------\n" + 
456
		"1. ERROR in X.java (at line 8)\n" + 
457
		"	case 1:\n" + 
458
		"	^^^^^^\n" + 
459
		"Possible fall-through case\n" + 
460
		"----------\n",
461
		null, true, options);
462
}
463
464
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
465
// [compiler] warning on fall through
466
// skip because of comment - variants
467
public void test016() {
468
	Map options = getCompilerOptions();
469
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
470
	this.runNegativeTest(
471
		new String[] {
472
			"X.java",
473
			"public class X {\n" + 
474
			"    public void test(int p) {\n" + 
475
			"        switch (p) {\n" + 
476
			"        case 0:\n" + 
477
			"            System.out.println(0); // silent because first case\n" + 
478
			"            // on purpose fall-through\n" +
479
			"            /* other comment */\n" + // non-single line comment breaks fall-through protection 
480
			"        case 1:\n" + 
481
			"            System.out.println(1); // silent because of comment alone on its line above \n" + 
482
			"        }\n" + 
483
			"    }\n" + 
484
			"}"
485
		},
486
		"----------\n" + 
487
		"1. ERROR in X.java (at line 8)\n" + 
488
		"	case 1:\n" + 
489
		"	^^^^^^\n" + 
490
		"Possible fall-through case\n" + 
491
		"----------\n",
492
		null, true, options);
493
}
494
495
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
496
// [compiler] warning on fall through
497
// skip because of comment - variants
498
public void test017() {
499
	Map options = getCompilerOptions();
500
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
501
	this.runConformTest(
502
		new String[] {
503
			"X.java",
504
			"public class X {\n" + 
505
			"    public void test(int p) {\n" + 
506
			"        switch (p) {\n" + 
507
			"        case 0:\n" + 
508
			"            System.out.println(0);\n" + 
509
			"// on purpose fall-through\n" + // very beginning of line
510
			"        case 1:\n" + 
511
			"            System.out.println(1); // silent because of comment alone on its line above \n" + 
512
			"        }\n" + 
513
			"    }\n" + 
514
			"}"
515
		},
516
		"",
517
		null, true, null, options, null);
518
}
519
520
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
521
// [compiler] warning on fall through
522
// skip because of comment - variants
523
public void test018() {
524
	Map options = getCompilerOptions();
525
	options.put(CompilerOptions.OPTION_ReportPossibleFallThroughCase, CompilerOptions.ERROR);
526
	this.runConformTest(
527
		new String[] {
528
			"X.java",
529
			"public class X {\n" + 
530
			"    public void test(int p) {\n" + 
531
			"        switch (p) {\n" + 
532
			"        case 0:\n" + 
533
			"            System.out.println(0);\n" + 
534
			"            //\n" + // empty line comment alone upon its line
535
			"        case 1:\n" + 
536
			"            System.out.println(1); // silent because of comment alone on its line above \n" + 
537
			"        }\n" + 
538
			"    }\n" + 
539
			"}"
540
		},
541
		"",
542
		null, true, null, options, null);
543
}
544
163
public static Class testClass() {
545
public static Class testClass() {
164
	return FlowAnalysisTest.class;
546
	return FlowAnalysisTest.class;
165
}
547
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+93 lines)
Lines 883-888 Link Here
883
		"      discouraged        + use of types matching a discouraged access rule\n" + 
883
		"      discouraged        + use of types matching a discouraged access rule\n" + 
884
		"      emptyBlock           undocumented empty block\n" + 
884
		"      emptyBlock           undocumented empty block\n" + 
885
		"      enumSwitch           incomplete enum switch\n" + 
885
		"      enumSwitch           incomplete enum switch\n" + 
886
		"      fallThrough          possible fall-through case\n" + 
886
		"      fieldHiding          field hiding another variable\n" + 
887
		"      fieldHiding          field hiding another variable\n" + 
887
		"      finalBound           type parameter with final bound\n" + 
888
		"      finalBound           type parameter with final bound\n" + 
888
		"      finally            + finally block not completing normally\n" + 
889
		"      finally            + finally block not completing normally\n" + 
Lines 1063-1068 Link Here
1063
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod\" value=\"warning\"/>\n" + 
1064
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod\" value=\"warning\"/>\n" + 
1064
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" + 
1065
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" + 
1065
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\n" + 
1066
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\n" + 
1067
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.possibleFallThroughCase\" value=\"ignore\"/>\n" + 
1066
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.rawTypeReference\" value=\"ignore\"/>\n" + 
1068
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.rawTypeReference\" value=\"ignore\"/>\n" + 
1067
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\n" + 
1069
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\n" + 
1068
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\n" + 
1070
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\n" + 
Lines 2716-2721 Link Here
2716
        false);
2718
        false);
2717
}
2719
}
2718
2720
2721
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
2722
// [compiler] warning on fall through
2723
// disable warning on command line (implicit)
2724
public void test049(){
2725
	this.runConformTest(
2726
		new String[] {
2727
			"X.java",
2728
			"/** */\n" + 
2729
			"public class X {\n" + 
2730
			"    public void test(int p) {\n" + 
2731
			"        switch (p) {\n" + 
2732
			"        case 0:\n" + 
2733
			"            System.out.println(0);\n" + 
2734
			"        case 1:\n" + 
2735
			"            System.out.println(1); // possible fall-through\n" + 
2736
			"        }\n" + 
2737
			"    }\n" + 
2738
			"}",
2739
		},
2740
        "\"" + OUTPUT_DIR +  File.separator + "X.java\""
2741
        + " -1.5 -g -preserveAllLocals"
2742
        + " -nowarn"
2743
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2744
        "", 
2745
        "",
2746
        true);
2747
}
2748
2749
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
2750
// [compiler] warning on fall through
2751
// disable warning on command line (explicit)
2752
public void test050(){
2753
	this.runConformTest(
2754
		new String[] {
2755
			"X.java",
2756
			"/** */\n" + 
2757
			"public class X {\n" + 
2758
			"    public void test(int p) {\n" + 
2759
			"        switch (p) {\n" + 
2760
			"        case 0:\n" + 
2761
			"            System.out.println(0);\n" + 
2762
			"        case 1:\n" + 
2763
			"            System.out.println(1); // possible fall-through\n" + 
2764
			"        }\n" + 
2765
			"    }\n" + 
2766
			"}",
2767
		},
2768
        "\"" + OUTPUT_DIR +  File.separator + "X.java\""
2769
        + " -1.5 -g -preserveAllLocals"
2770
        + " -warn:-fallThrough"
2771
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2772
        "", 
2773
        "",
2774
        true);
2775
}
2776
2777
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=67836
2778
// [compiler] warning on fall through
2779
// enable warning on command line
2780
public void test051(){
2781
	this.runConformTest(
2782
		new String[] {
2783
			"X.java",
2784
			"/** */\n" + 
2785
			"public class X {\n" + 
2786
			"    public void test(int p) {\n" + 
2787
			"        switch (p) {\n" + 
2788
			"        case 0:\n" + 
2789
			"            System.out.println(0);\n" + 
2790
			"        case 1:\n" + 
2791
			"            System.out.println(1); // complain: possible fall-through\n" + 
2792
			"        }\n" + 
2793
			"    }\n" + 
2794
			"}",
2795
		},
2796
        "\"" + OUTPUT_DIR +  File.separator + "X.java\""
2797
        + " -1.5 -g -preserveAllLocals"
2798
        + " -warn:+fallThrough"
2799
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2800
        "", 
2801
		"----------\n" + 
2802
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java\n" + 
2803
		" (at line 7)\n" + 
2804
		"	case 1:\n" + 
2805
		"	^^^^^^\n" + 
2806
		"Possible fall-through case\n" + 
2807
		"----------\n" + 
2808
		"1 problem (1 warning)",
2809
        true);
2810
}
2811
2719
public static Class testClass() {
2812
public static Class testClass() {
2720
	return BatchCompilerTest.class;
2813
	return BatchCompilerTest.class;
2721
}
2814
}

Return to bug 67836