View | Details | Raw Unified | Return to bug 295260
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java (-8 / +2 lines)
Lines 131-140 Link Here
131
							addPotentialInitializationsFrom(
131
							addPotentialInitializationsFrom(
132
								handlingContext.initsOnException(
132
								handlingContext.initsOnException(
133
									this.caughtExceptionTypes[i]))
133
									this.caughtExceptionTypes[i]))
134
							.addPotentialInitializationsFrom(
134
							.addPotentialInitializationsFrom(tryInfo.unconditionalCopy())
135
								tryInfo.nullInfoLessUnconditionalCopy())
136
								// remove null info to protect point of
137
								// exception null info
138
							.addPotentialInitializationsFrom(
135
							.addPotentialInitializationsFrom(
139
								handlingContext.initsOnReturn.
136
								handlingContext.initsOnReturn.
140
									nullInfoLessUnconditionalCopy());
137
									nullInfoLessUnconditionalCopy());
Lines 243-252 Link Here
243
							.addPotentialInitializationsFrom(
240
							.addPotentialInitializationsFrom(
244
								handlingContext.initsOnException(
241
								handlingContext.initsOnException(
245
									this.caughtExceptionTypes[i]))
242
									this.caughtExceptionTypes[i]))
246
									.addPotentialInitializationsFrom(
243
									.addPotentialInitializationsFrom(tryInfo.unconditionalCopy())
247
								tryInfo.nullInfoLessUnconditionalCopy())
248
								// remove null info to protect point of
249
								// exception null info
250
							.addPotentialInitializationsFrom(
244
							.addPotentialInitializationsFrom(
251
									handlingContext.initsOnReturn.
245
									handlingContext.initsOnReturn.
252
									nullInfoLessUnconditionalCopy());
246
									nullInfoLessUnconditionalCopy());
(-)compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java (-1 / +1 lines)
Lines 192-198 Link Here
192
						if (flowInfo.cannotBeNull(local)) {
192
						if (flowInfo.cannotBeNull(local)) {
193
							if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
193
							if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
194
								scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
194
								scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
195
							} else {
195
							} else if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) {
196
								scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
196
								scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
197
							}
197
							}
198
							return;
198
							return;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java (+76 lines)
Lines 5347-5352 Link Here
5347
		false /* skipJavac */);
5347
		false /* skipJavac */);
5348
}
5348
}
5349
5349
5350
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=295260
5351
public void test0535_try_finally() {
5352
	this.runConformTest(
5353
			new String[] {
5354
				"X.java",
5355
				"public class X {\n" +
5356
				"	public void test3(String[] args) {\n" +
5357
				"		while (true) {\n" +
5358
				"			Object a = null;\n" +
5359
				"			try {\n" +
5360
				"				a = new Object();\n" +
5361
				"			} catch (Exception e) {\n" +
5362
				"			} finally {\n" +
5363
				"				if (a != null)\n" +
5364
				"					a = null;\n" +	// quiet
5365
				"			}\n" +
5366
				"		}\n" +
5367
				"	}\n"+
5368
				"}",
5369
			},
5370
			"");
5371
}
5372
5350
// null analysis -- try/catch
5373
// null analysis -- try/catch
5351
public void test0550_try_catch() {
5374
public void test0550_try_catch() {
5352
	this.runConformTest(
5375
	this.runConformTest(
Lines 5859-5864 Link Here
5859
		"");
5882
		"");
5860
}
5883
}
5861
5884
5885
// null analysis - try/catch for checked exceptions
5886
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=295260
5887
public void test0567_try_catch_checked_exception() {
5888
	this.runConformTest(
5889
			new String[] {
5890
				"X.java",
5891
				"import java.net.MalformedURLException;\n" +
5892
				"import java.net.URL;\n" +
5893
				"public class X {\n" +
5894
				"	public void test1(String[] args) {\n" +
5895
				"		URL[] urls = null;\n" +
5896
				"		try	{\n" +
5897
				"			urls = new URL[args.length];\n" +
5898
				"			for (int i = 0; i < args.length; i++)\n" +
5899
				"				urls[i] = new URL(\"http\", \"\", -1, args[i]);\n" +
5900
				"		}\n" +
5901
				"		catch (MalformedURLException mfex) {\n" +
5902
				"			urls = null;\n" +	// quiet
5903
				"		}\n" +
5904
				"	}\n" +
5905
				"}",
5906
			},
5907
			"");
5908
}
5909
5910
// null analysis - try/catch for checked exceptions with finally block
5911
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=295260
5912
public void test0568_try_catch_checked_exception() {
5913
	this.runConformTest(
5914
			new String[] {
5915
				"X.java",
5916
				"import java.net.MalformedURLException;\n" +
5917
				"import java.net.URL;\n" +
5918
				"public class X {\n" +
5919
				"	public void test1(String[] args) {\n" +
5920
				"		URL[] urls = null;\n" +
5921
				"		try	{\n" +
5922
				"			urls = new URL[args.length];\n" +
5923
				"			for (int i = 0; i < args.length; i++)\n" +
5924
				"				urls[i] = new URL(\"http\", \"\", -1, args[i]);\n" +
5925
				"		}\n" +
5926
				"		catch (MalformedURLException mfex) {\n" +
5927
				"			urls = null;\n" +	// quiet
5928
				"		}\n" +
5929
				" 		finally{\n"+
5930
				"			System.out.println(\"complete\");\n" +
5931
				"		}\n" +
5932
				"	}\n" +
5933
				"}",
5934
			},
5935
			"");
5936
}
5937
5862
// null analysis - throw
5938
// null analysis - throw
5863
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=201182
5939
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=201182
5864
public void test0595_throw() {
5940
public void test0595_throw() {

Return to bug 295260