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

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java (+40 lines)
Lines 10-15 Link Here
10
 *     Stephan Herrmann - Contributions for
10
 *     Stephan Herrmann - Contributions for
11
 *     							bug 358827 - [1.7] exception analysis for t-w-r spoils null analysis
11
 *     							bug 358827 - [1.7] exception analysis for t-w-r spoils null analysis
12
 *     							bug 349326 - [1.7] new warning for missing try-with-resources
12
 *     							bug 349326 - [1.7] new warning for missing try-with-resources
13
 *     							bug 359334 - Analysis for resource leak warnings does not consider exceptions as method exit points
13
 *******************************************************************************/
14
 *******************************************************************************/
14
package org.eclipse.jdt.core.tests.compiler.regression;
15
package org.eclipse.jdt.core.tests.compiler.regression;
15
16
Lines 4942-4947 Link Here
4942
		true,
4943
		true,
4943
		options);
4944
		options);
4944
}
4945
}
4946
// Bug 359334 - Analysis for resource leak warnings does not consider exceptions as method exit points
4947
public void test056throw1() {
4948
	Map options = getCompilerOptions();
4949
	options.put(JavaCore.COMPILER_PB_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR);
4950
	options.put(JavaCore.COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR);
4951
	options.put(JavaCore.COMPILER_PB_EXPLICITLY_CLOSED_AUTOCLOSEABLE, CompilerOptions.ERROR);
4952
	options.put(JavaCore.COMPILER_PB_DEAD_CODE, CompilerOptions.ERROR);
4953
	this.runNegativeTest(
4954
		new String[] {
4955
			"X.java",
4956
			"import java.io.FileReader;\n" +
4957
			"public class X {\n" +
4958
			"    void foo2(boolean a, boolean b, boolean c) throws Exception {\n" +
4959
			"        FileReader reader = new FileReader(\"file\");\n" +
4960
			"        if(a)\n" +
4961
			"            throw new Exception();    //warning 1\n" +
4962
			"        else if (b)\n" +
4963
			"            reader.close();\n" +
4964
			"        else if(c)\n" +
4965
			"            throw new Exception();    //warning 2\n" +
4966
			"        reader.close();\n" +
4967
			"    }\n" +
4968
			"}\n"
4969
		},
4970
		"----------\n" + 
4971
		"1. ERROR in X.java (at line 6)\n" +
4972
		"	throw new Exception();    //warning 1\n" +
4973
		"	^^^^^^^^^^^^^^^^^^^^^^\n" +
4974
		"Resource leak: \'reader\' is not closed at this location\n" +
4975
		"----------\n" +
4976
		"2. ERROR in X.java (at line 10)\n" +
4977
		"	throw new Exception();    //warning 2\n" +
4978
		"	^^^^^^^^^^^^^^^^^^^^^^\n" +
4979
		"Resource leak: \'reader\' is not closed at this location\n" +
4980
		"----------\n",
4981
		null,
4982
		true,
4983
		options);	
4984
}
4945
public static Class testClass() {
4985
public static Class testClass() {
4946
	return TryWithResourcesStatementTest.class;
4986
	return TryWithResourcesStatementTest.class;
4947
}
4987
}
(-)a/org.eclipse.jdt.core/buildnotes_jdt-core.html (-1 / +3 lines)
Lines 52-58 Link Here
52
<h2>What's new in this drop</h2>
52
<h2>What's new in this drop</h2>
53
53
54
<h3>Problem Reports Fixed</h3>
54
<h3>Problem Reports Fixed</h3>
55
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=359362">359362</a>
55
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=359334">359334</a>
56
Analysis for resource leak warnings does not consider exceptions as method exit points
57
<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=359362">359362</a>
56
FUP of bug 349326: Resource leak on non-Closeable resource.
58
FUP of bug 349326: Resource leak on non-Closeable resource.
57
<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=348186">348186</a>
59
<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=348186">348186</a>
58
[compiler] Improve wording for the warning for masked/hidden catch block
60
[compiler] Improve wording for the warning for masked/hidden catch block
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java (-2 / +2 lines)
Lines 33-44 Link Here
33
	int complaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED;
33
	int complaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED;
34
	for (int i = 0, max = this.statements.length; i < max; i++) {
34
	for (int i = 0, max = this.statements.length; i < max; i++) {
35
		Statement stat = this.statements[i];
35
		Statement stat = this.statements[i];
36
		if ((complaintLevel = stat.complainIfUnreachable(flowInfo, flowContext, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
36
		if ((complaintLevel = stat.complainIfUnreachable(flowInfo, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
37
			flowInfo = stat.analyseCode(this.scope, flowContext, flowInfo);
37
			flowInfo = stat.analyseCode(this.scope, flowContext, flowInfo);
38
		}
38
		}
39
	}
39
	}
40
	if (this.explicitDeclarations > 0) // if block has its own scope analyze tracking vars now:
40
	if (this.explicitDeclarations > 0) // if block has its own scope analyze tracking vars now:
41
		this.scope.checkUnclosedCloseables(flowInfo, flowContext, null);
41
		this.scope.checkUnclosedCloseables(flowInfo, null);
42
	return flowInfo;
42
	return flowInfo;
43
}
43
}
44
/**
44
/**
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java (-2 / +2 lines)
Lines 66-72 Link Here
66
				trueFlowInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD);
66
				trueFlowInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD);
67
			}
67
			}
68
			if (!isKnowDeadCodePattern(this.condition) || currentScope.compilerOptions().reportDeadCodeInTrivialIfStatement) {
68
			if (!isKnowDeadCodePattern(this.condition) || currentScope.compilerOptions().reportDeadCodeInTrivialIfStatement) {
69
				this.valueIfTrue.complainIfUnreachable(trueFlowInfo, flowContext, currentScope, initialComplaintLevel, false);
69
				this.valueIfTrue.complainIfUnreachable(trueFlowInfo, currentScope, initialComplaintLevel, false);
70
			}
70
			}
71
		}
71
		}
72
		this.trueInitStateIndex = currentScope.methodScope().recordInitializationStates(trueFlowInfo);
72
		this.trueInitStateIndex = currentScope.methodScope().recordInitializationStates(trueFlowInfo);
Lines 79-85 Link Here
79
				falseFlowInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD);
79
				falseFlowInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD);
80
			}
80
			}
81
			if (!isKnowDeadCodePattern(this.condition) || currentScope.compilerOptions().reportDeadCodeInTrivialIfStatement) {
81
			if (!isKnowDeadCodePattern(this.condition) || currentScope.compilerOptions().reportDeadCodeInTrivialIfStatement) {
82
				this.valueIfFalse.complainIfUnreachable(falseFlowInfo, flowContext, currentScope, initialComplaintLevel, true);
82
				this.valueIfFalse.complainIfUnreachable(falseFlowInfo, currentScope, initialComplaintLevel, true);
83
			}
83
			}
84
		}
84
		}
85
		this.falseInitStateIndex = currentScope.methodScope().recordInitializationStates(falseFlowInfo);
85
		this.falseInitStateIndex = currentScope.methodScope().recordInitializationStates(falseFlowInfo);
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java (-1 / +1 lines)
Lines 153-159 Link Here
153
			int complaintLevel = (nonStaticFieldInfoReachMode & FlowInfo.UNREACHABLE) == 0 ? Statement.NOT_COMPLAINED : Statement.COMPLAINED_FAKE_REACHABLE;
153
			int complaintLevel = (nonStaticFieldInfoReachMode & FlowInfo.UNREACHABLE) == 0 ? Statement.NOT_COMPLAINED : Statement.COMPLAINED_FAKE_REACHABLE;
154
			for (int i = 0, count = this.statements.length; i < count; i++) {
154
			for (int i = 0, count = this.statements.length; i < count; i++) {
155
				Statement stat = this.statements[i];
155
				Statement stat = this.statements[i];
156
				if ((complaintLevel = stat.complainIfUnreachable(flowInfo, constructorContext, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
156
				if ((complaintLevel = stat.complainIfUnreachable(flowInfo, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
157
					flowInfo = stat.analyseCode(this.scope, constructorContext, flowInfo);
157
					flowInfo = stat.analyseCode(this.scope, constructorContext, flowInfo);
158
				}
158
				}
159
			}
159
			}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EmptyStatement.java (-2 / +2 lines)
Lines 30-41 Link Here
30
	}
30
	}
31
31
32
	// Report an error if necessary
32
	// Report an error if necessary
33
	public int complainIfUnreachable(FlowInfo flowInfo, FlowContext flowContext, BlockScope scope, int complaintLevel, boolean endOfBlock) {
33
	public int complainIfUnreachable(FlowInfo flowInfo, BlockScope scope, int complaintLevel, boolean endOfBlock) {
34
		// before 1.4, empty statements are tolerated anywhere
34
		// before 1.4, empty statements are tolerated anywhere
35
		if (scope.compilerOptions().complianceLevel < ClassFileConstants.JDK1_4) {
35
		if (scope.compilerOptions().complianceLevel < ClassFileConstants.JDK1_4) {
36
			return complaintLevel;
36
			return complaintLevel;
37
		}
37
		}
38
		return super.complainIfUnreachable(flowInfo, flowContext, scope, complaintLevel, endOfBlock);
38
		return super.complainIfUnreachable(flowInfo, scope, complaintLevel, endOfBlock);
39
	}
39
	}
40
40
41
	public void generateCode(BlockScope currentScope, CodeStream codeStream){
41
	public void generateCode(BlockScope currentScope, CodeStream codeStream){
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java (-1 / +1 lines)
Lines 140-146 Link Here
140
						actionInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD);
140
						actionInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD);
141
					}
141
					}
142
				}
142
				}
143
			if (this.action.complainIfUnreachable(actionInfo, flowContext, this.scope, initialComplaintLevel, true) < Statement.COMPLAINED_UNREACHABLE) {
143
			if (this.action.complainIfUnreachable(actionInfo, this.scope, initialComplaintLevel, true) < Statement.COMPLAINED_UNREACHABLE) {
144
				actionInfo = this.action.analyseCode(this.scope, loopingContext, actionInfo).unconditionalInits();
144
				actionInfo = this.action.analyseCode(this.scope, loopingContext, actionInfo).unconditionalInits();
145
			}
145
			}
146
146
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java (-1 / +1 lines)
Lines 100-106 Link Here
100
		if (!(this.action == null || (this.action.isEmptyBlock()
100
		if (!(this.action == null || (this.action.isEmptyBlock()
101
				&& currentScope.compilerOptions().complianceLevel <= ClassFileConstants.JDK1_3))) {
101
				&& currentScope.compilerOptions().complianceLevel <= ClassFileConstants.JDK1_3))) {
102
102
103
			if (this.action.complainIfUnreachable(actionInfo, flowContext, this.scope, initialComplaintLevel, true) < Statement.COMPLAINED_UNREACHABLE) {
103
			if (this.action.complainIfUnreachable(actionInfo, this.scope, initialComplaintLevel, true) < Statement.COMPLAINED_UNREACHABLE) {
104
				actionInfo = this.action.analyseCode(this.scope, loopingContext, actionInfo).unconditionalCopy();
104
				actionInfo = this.action.analyseCode(this.scope, loopingContext, actionInfo).unconditionalCopy();
105
			}
105
			}
106
106
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java (-2 / +2 lines)
Lines 91-97 Link Here
91
		this.thenInitStateIndex = currentScope.methodScope().recordInitializationStates(thenFlowInfo);
91
		this.thenInitStateIndex = currentScope.methodScope().recordInitializationStates(thenFlowInfo);
92
		if (isConditionOptimizedFalse || ((this.bits & ASTNode.IsThenStatementUnreachable) != 0)) {
92
		if (isConditionOptimizedFalse || ((this.bits & ASTNode.IsThenStatementUnreachable) != 0)) {
93
			if (!isKnowDeadCodePattern(this.condition) || currentScope.compilerOptions().reportDeadCodeInTrivialIfStatement) {
93
			if (!isKnowDeadCodePattern(this.condition) || currentScope.compilerOptions().reportDeadCodeInTrivialIfStatement) {
94
				this.thenStatement.complainIfUnreachable(thenFlowInfo, flowContext, currentScope, initialComplaintLevel, false);
94
				this.thenStatement.complainIfUnreachable(thenFlowInfo, currentScope, initialComplaintLevel, false);
95
			} else {
95
			} else {
96
				// its a known coding pattern which should be tolerated by dead code analysis
96
				// its a known coding pattern which should be tolerated by dead code analysis
97
				// according to isKnowDeadCodePattern()
97
				// according to isKnowDeadCodePattern()
Lines 117-123 Link Here
117
		this.elseInitStateIndex = currentScope.methodScope().recordInitializationStates(elseFlowInfo);
117
		this.elseInitStateIndex = currentScope.methodScope().recordInitializationStates(elseFlowInfo);
118
		if (isConditionOptimizedTrue || ((this.bits & ASTNode.IsElseStatementUnreachable) != 0)) {
118
		if (isConditionOptimizedTrue || ((this.bits & ASTNode.IsElseStatementUnreachable) != 0)) {
119
			if (!isKnowDeadCodePattern(this.condition) || currentScope.compilerOptions().reportDeadCodeInTrivialIfStatement) {
119
			if (!isKnowDeadCodePattern(this.condition) || currentScope.compilerOptions().reportDeadCodeInTrivialIfStatement) {
120
				this.elseStatement.complainIfUnreachable(elseFlowInfo, flowContext, currentScope, initialComplaintLevel, false);
120
				this.elseStatement.complainIfUnreachable(elseFlowInfo, currentScope, initialComplaintLevel, false);
121
			} else {
121
			} else {
122
				// its a known coding pattern which should be tolerated by dead code analysis
122
				// its a known coding pattern which should be tolerated by dead code analysis
123
				// according to isKnowDeadCodePattern()
123
				// according to isKnowDeadCodePattern()
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java (-2 / +2 lines)
Lines 101-107 Link Here
101
				int complaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) == 0 ? Statement.NOT_COMPLAINED : Statement.COMPLAINED_FAKE_REACHABLE;
101
				int complaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) == 0 ? Statement.NOT_COMPLAINED : Statement.COMPLAINED_FAKE_REACHABLE;
102
				for (int i = 0, count = this.statements.length; i < count; i++) {
102
				for (int i = 0, count = this.statements.length; i < count; i++) {
103
					Statement stat = this.statements[i];
103
					Statement stat = this.statements[i];
104
					if ((complaintLevel = stat.complainIfUnreachable(flowInfo, methodContext, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
104
					if ((complaintLevel = stat.complainIfUnreachable(flowInfo, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
105
						flowInfo = stat.analyseCode(this.scope, methodContext, flowInfo);
105
						flowInfo = stat.analyseCode(this.scope, methodContext, flowInfo);
106
					}
106
					}
107
				}
107
				}
Lines 135-141 Link Here
135
				}
135
				}
136
					
136
					
137
			}
137
			}
138
			this.scope.checkUnclosedCloseables(flowInfo, methodContext, null/*don't report against a specific location*/);
138
			this.scope.checkUnclosedCloseables(flowInfo, null/*don't report against a specific location*/);
139
		} catch (AbortMethod e) {
139
		} catch (AbortMethod e) {
140
			this.ignoreFurtherInvestigation = true;
140
			this.ignoreFurtherInvestigation = true;
141
		}
141
		}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java (-1 / +1 lines)
Lines 114-120 Link Here
114
			this.expression.bits |= ASTNode.IsReturnedValue;
114
			this.expression.bits |= ASTNode.IsReturnedValue;
115
		}
115
		}
116
	}
116
	}
117
	currentScope.checkUnclosedCloseables(flowInfo, null/*ignore exception exits from flowContext*/, this);
117
	currentScope.checkUnclosedCloseables(flowInfo, this);
118
	return FlowInfo.DEAD_END;
118
	return FlowInfo.DEAD_END;
119
}
119
}
120
120
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java (-3 / +3 lines)
Lines 72-78 Link Here
72
72
73
// Report an error if necessary (if even more unreachable than previously reported
73
// Report an error if necessary (if even more unreachable than previously reported
74
// complaintLevel = 0 if was reachable up until now, 1 if fake reachable (deadcode), 2 if fatal unreachable (error)
74
// complaintLevel = 0 if was reachable up until now, 1 if fake reachable (deadcode), 2 if fatal unreachable (error)
75
public int complainIfUnreachable(FlowInfo flowInfo, FlowContext flowContext, BlockScope scope, int previousComplaintLevel, boolean endOfBlock) {
75
public int complainIfUnreachable(FlowInfo flowInfo, BlockScope scope, int previousComplaintLevel, boolean endOfBlock) {
76
	if ((flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0) {
76
	if ((flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0) {
77
		if ((flowInfo.reachMode() & FlowInfo.UNREACHABLE_OR_DEAD) != 0)
77
		if ((flowInfo.reachMode() & FlowInfo.UNREACHABLE_OR_DEAD) != 0)
78
			this.bits &= ~ASTNode.IsReachable;
78
			this.bits &= ~ASTNode.IsReachable;
Lines 80-93 Link Here
80
			if (previousComplaintLevel < COMPLAINED_UNREACHABLE) {
80
			if (previousComplaintLevel < COMPLAINED_UNREACHABLE) {
81
				scope.problemReporter().unreachableCode(this);
81
				scope.problemReporter().unreachableCode(this);
82
				if (endOfBlock)
82
				if (endOfBlock)
83
					scope.checkUnclosedCloseables(flowInfo, flowContext, null);
83
					scope.checkUnclosedCloseables(flowInfo, null);
84
			}
84
			}
85
			return COMPLAINED_UNREACHABLE;
85
			return COMPLAINED_UNREACHABLE;
86
		} else {
86
		} else {
87
			if (previousComplaintLevel < COMPLAINED_FAKE_REACHABLE) {
87
			if (previousComplaintLevel < COMPLAINED_FAKE_REACHABLE) {
88
				scope.problemReporter().fakeReachable(this);
88
				scope.problemReporter().fakeReachable(this);
89
				if (endOfBlock)
89
				if (endOfBlock)
90
					scope.checkUnclosedCloseables(flowInfo, flowContext, null);
90
					scope.checkUnclosedCloseables(flowInfo, null);
91
			}
91
			}
92
			return COMPLAINED_FAKE_REACHABLE;
92
			return COMPLAINED_FAKE_REACHABLE;
93
		}
93
		}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java (-1 / +1 lines)
Lines 101-107 Link Here
101
					} else {
101
					} else {
102
						fallThroughState = FALLTHROUGH; // reset below if needed
102
						fallThroughState = FALLTHROUGH; // reset below if needed
103
					}
103
					}
104
					if ((complaintLevel = statement.complainIfUnreachable(caseInits, flowContext, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
104
					if ((complaintLevel = statement.complainIfUnreachable(caseInits, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
105
						caseInits = statement.analyseCode(this.scope, switchContext, caseInits);
105
						caseInits = statement.analyseCode(this.scope, switchContext, caseInits);
106
						if (caseInits == FlowInfo.DEAD_END) {
106
						if (caseInits == FlowInfo.DEAD_END) {
107
							fallThroughState = ESCAPING;
107
							fallThroughState = ESCAPING;
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann - Contribution for bug 359334 - Analysis for resource leak warnings does not consider exceptions as method exit points
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.ast;
12
package org.eclipse.jdt.internal.compiler.ast;
12
13
Lines 35-40 Link Here
35
	this.exception.checkNPE(currentScope, flowContext, flowInfo);
36
	this.exception.checkNPE(currentScope, flowContext, flowInfo);
36
	// need to check that exception thrown is actually caught somewhere
37
	// need to check that exception thrown is actually caught somewhere
37
	flowContext.checkExceptionHandlers(this.exceptionType, this, flowInfo, currentScope);
38
	flowContext.checkExceptionHandlers(this.exceptionType, this, flowInfo, currentScope);
39
	currentScope.checkUnclosedCloseables(flowInfo, this);
38
	return FlowInfo.DEAD_END;
40
	return FlowInfo.DEAD_END;
39
}
41
}
40
42
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java (-1 / +1 lines)
Lines 115-121 Link Here
115
				currentScope.methodScope().recordInitializationStates(
115
				currentScope.methodScope().recordInitializationStates(
116
					condInfo.initsWhenTrue());
116
					condInfo.initsWhenTrue());
117
117
118
			if (this.action.complainIfUnreachable(actionInfo, flowContext, currentScope, initialComplaintLevel, true) < Statement.COMPLAINED_UNREACHABLE) {
118
			if (this.action.complainIfUnreachable(actionInfo, currentScope, initialComplaintLevel, true) < Statement.COMPLAINED_UNREACHABLE) {
119
				actionInfo = this.action.analyseCode(currentScope, loopingContext, actionInfo);
119
				actionInfo = this.action.analyseCode(currentScope, loopingContext, actionInfo);
120
			}
120
			}
121
121
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java (-3 / +2 lines)
Lines 18-24 Link Here
18
import org.eclipse.jdt.internal.compiler.ast.*;
18
import org.eclipse.jdt.internal.compiler.ast.*;
19
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
20
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
20
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
21
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
22
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
21
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
23
import org.eclipse.jdt.internal.compiler.impl.Constant;
22
import org.eclipse.jdt.internal.compiler.impl.Constant;
24
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
23
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
Lines 988-998 Link Here
988
 * At the end of a block check the closing-status of all tracked closeables that are declared in this block.
987
 * At the end of a block check the closing-status of all tracked closeables that are declared in this block.
989
 * Also invoked when entering unreachable code.
988
 * Also invoked when entering unreachable code.
990
 */
989
 */
991
public void checkUnclosedCloseables(FlowInfo flowInfo, FlowContext flowContext, ASTNode location) {
990
public void checkUnclosedCloseables(FlowInfo flowInfo, ASTNode location) {
992
	if (this.trackingVariables == null) {
991
	if (this.trackingVariables == null) {
993
		// at a method return we also consider enclosing scopes
992
		// at a method return we also consider enclosing scopes
994
		if (location != null && this.parent instanceof BlockScope)
993
		if (location != null && this.parent instanceof BlockScope)
995
			((BlockScope) this.parent).checkUnclosedCloseables(flowInfo, flowContext, location);
994
			((BlockScope) this.parent).checkUnclosedCloseables(flowInfo, location);
996
		return;
995
		return;
997
	}
996
	}
998
	if (location != null && flowInfo.reachMode() != 0) return;
997
	if (location != null && flowInfo.reachMode() != 0) return;

Return to bug 359334