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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-2 / +48 lines)
Lines 1121-1127 Link Here
1121
        "      nls                  string literal lacking non-nls tag //$NON-NLS-<n>$\n" +
1121
        "      nls                  string literal lacking non-nls tag //$NON-NLS-<n>$\n" +
1122
        "      noEffectAssign     + assignment without effect\n" +
1122
        "      noEffectAssign     + assignment without effect\n" +
1123
        "      null                 potential missing or redundant null check\n" +
1123
        "      null                 potential missing or redundant null check\n" +
1124
        "      nullDereference      missing null check\n" +
1124
        "      nullDereference    + missing null check\n" +
1125
        "      over-ann             missing @Override annotation\n" +
1125
        "      over-ann             missing @Override annotation\n" +
1126
        "      paramAssign          assignment to a parameter\n" +
1126
        "      paramAssign          assignment to a parameter\n" +
1127
        "      pkgDefaultMethod   + attempt to override package-default method\n" +
1127
        "      pkgDefaultMethod   + attempt to override package-default method\n" +
Lines 1265-1271 Link Here
1265
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.noEffectAssignment\" value=\"warning\"/>\n" + 
1265
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.noEffectAssignment\" value=\"warning\"/>\n" + 
1266
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion\" value=\"warning\"/>\n" + 
1266
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion\" value=\"warning\"/>\n" + 
1267
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral\" value=\"ignore\"/>\n" + 
1267
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral\" value=\"ignore\"/>\n" + 
1268
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.nullReference\" value=\"ignore\"/>\n" + 
1268
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.nullReference\" value=\"warning\"/>\n" + 
1269
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation\" value=\"ignore\"/>\n" + 
1269
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation\" value=\"ignore\"/>\n" + 
1270
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod\" value=\"warning\"/>\n" + 
1270
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod\" value=\"warning\"/>\n" + 
1271
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" + 
1271
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" + 
Lines 5436-5441 Link Here
5436
		"",
5436
		"",
5437
		true);
5437
		true);
5438
}
5438
}
5439
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=192875
5440
// default in now on for nullDereference
5441
public void test150_null_ref_options() {
5442
	this.runConformTest(
5443
		new String[] {
5444
			"X.java",
5445
			"public class X {\n" + 
5446
			"	public static void foo() {\n" +
5447
			"     String s = null;\n" +
5448
			"     s.toString();\n" +
5449
			"   }\n" + 
5450
			"	// Zork z;\n" + 
5451
			"}",
5452
		},
5453
		"\"" + OUTPUT_DIR +  File.separator + "X.java\""
5454
		+ " -proc:none -d \"" + OUTPUT_DIR + "\"",
5455
		"",
5456
		"----------\n" + 
5457
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + 
5458
		"	s.toString();\n" + 
5459
		"	^\n" + 
5460
		"Null pointer access: The variable s can only be null at this location\n" + 
5461
		"----------\n" + 
5462
		"1 problem (1 warning)",
5463
		true);
5464
}
5465
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=192875
5466
// default in now on for nullDereference
5467
public void test151_null_ref_options() {
5468
	this.runConformTest(
5469
		new String[] {
5470
			"X.java",
5471
			"public class X {\n" + 
5472
			"	public static void foo() {\n" +
5473
			"     String s = null;\n" +
5474
			"     s.toString();\n" +
5475
			"   }\n" + 
5476
			"	// Zork z;\n" + 
5477
			"}",
5478
		},
5479
		"\"" + OUTPUT_DIR +  File.separator + "X.java\""
5480
		+ " -warn:-nullDereference -proc:none -d \"" + OUTPUT_DIR + "\"",
5481
		"",
5482
		"",
5483
		true);
5484
}
5439
public static Class testClass() {
5485
public static Class testClass() {
5440
	return BatchCompilerTest.class;
5486
	return BatchCompilerTest.class;
5441
}
5487
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java (-3 / +21 lines)
Lines 77-83 Link Here
77
		"Null pointer access: The variable o can only be null at this location\n" + 
77
		"Null pointer access: The variable o can only be null at this location\n" + 
78
	    "----------\n");
78
	    "----------\n");
79
}
79
}
80
  
80
81
// null analysis -- simple case for field
81
// null analysis -- simple case for field
82
// the current design leaves fields out of the analysis altogether
82
// the current design leaves fields out of the analysis altogether
83
public void test0002_simple_field() {
83
public void test0002_simple_field() {
Lines 8627-8636 Link Here
8627
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=170704
8627
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=170704
8628
// adding distinct options to control null checks in more detail
8628
// adding distinct options to control null checks in more detail
8629
// default for null options is Ignore
8629
// default for null options is Ignore
8630
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=192875
8631
// changed default for null access to warning
8630
public void test1050_options_all_default() {
8632
public void test1050_options_all_default() {
8631
	try {
8633
	try {
8632
		setNullRelatedOptions = false;
8634
		setNullRelatedOptions = false;
8633
		this.runConformTest(
8635
		runTest(
8634
			new String[] {
8636
			new String[] {
8635
				"X.java",
8637
				"X.java",
8636
				  "public class X {\n" + 
8638
				  "public class X {\n" + 
Lines 8643-8649 Link Here
8643
				  "    o.toString();\n" +
8645
				  "    o.toString();\n" +
8644
				  "    p.toString();\n" + 
8646
				  "    p.toString();\n" + 
8645
				  "  }\n" + 
8647
				  "  }\n" + 
8646
				  "}\n"});
8648
				  "}\n"
8649
				  } /* testFiles */,
8650
			false /* expectingCompilerErrors */,
8651
			"----------\n" + 
8652
			"1. WARNING in X.java (at line 8)\n" + 
8653
			"	o.toString();\n" + 
8654
			"	^\n" + 
8655
			"Null pointer access: The variable o can only be null at this location\n" + 
8656
			"----------\n" /* expectedCompilerLog */,
8657
			"" /* expectedOutputString */,
8658
			false /* forceExecution */,
8659
			null /* classLib */,
8660
			true /* shouldFlushOutputDirectory */, 
8661
			null /* vmArguments */, 
8662
			null /* customOptions */,
8663
			null /* clientRequestor */,
8664
			false /* skipJavac */);
8647
	}
8665
	}
8648
	finally {
8666
	finally {
8649
		setNullRelatedOptions = true;
8667
		setNullRelatedOptions = true;
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (-1 / +1 lines)
Lines 256-262 Link Here
256
\      nls                  string literal lacking non-nls tag //$NON-NLS-<n>$\n\
256
\      nls                  string literal lacking non-nls tag //$NON-NLS-<n>$\n\
257
\      noEffectAssign     + assignment without effect\n\
257
\      noEffectAssign     + assignment without effect\n\
258
\      null                 potential missing or redundant null check\n\
258
\      null                 potential missing or redundant null check\n\
259
\      nullDereference      missing null check\n\
259
\      nullDereference    + missing null check\n\
260
\      over-ann             missing @Override annotation\n\
260
\      over-ann             missing @Override annotation\n\
261
\      paramAssign          assignment to a parameter\n\
261
\      paramAssign          assignment to a parameter\n\
262
\      pkgDefaultMethod   + attempt to override package-default method\n\
262
\      pkgDefaultMethod   + attempt to override package-default method\n\
(-)model/org/eclipse/jdt/core/JavaCore.java (-1 / +1 lines)
Lines 2345-2351 Link Here
2345
	 *
2345
	 *
2346
	 *     - option id:         "org.eclipse.jdt.core.compiler.problem.potentialNullReference"
2346
	 *     - option id:         "org.eclipse.jdt.core.compiler.problem.potentialNullReference"
2347
	 *     - possible values:   { "error", "warning", "ignore" }
2347
	 *     - possible values:   { "error", "warning", "ignore" }
2348
	 *     - default:           "ignore"
2348
	 *     - default:           "warning"
2349
	 *
2349
	 *
2350
	 * COMPILER / Reporting Redundant Null Check
2350
	 * COMPILER / Reporting Redundant Null Check
2351
	 *    When enabled, the compiler will issue an error or a warning whenever a
2351
	 *    When enabled, the compiler will issue an error or a warning whenever a
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (-1 / +1 lines)
Lines 242-248 Link Here
242
		| UnusedPrivateMember
242
		| UnusedPrivateMember
243
		| UnusedLabel
243
		| UnusedLabel
244
		| UnusedTypeArgumentsForMethodInvocation
244
		| UnusedTypeArgumentsForMethodInvocation
245
		/*| NullReference -- keep JavaCore#getDefaultOptions comment in sync */;
245
		| NullReference;
246
246
247
	// By default only lines and source attributes are generated.
247
	// By default only lines and source attributes are generated.
248
	public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
248
	public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
(-)workspace/Converter/src/test0605/X.java (-1 / +1 lines)
Lines 3-9 Link Here
3
public class X {
3
public class X {
4
4
5
	void foo() {
5
	void foo() {
6
        int[] a= null;
6
        int[] a= {1};
7
        int lenA= a.length;
7
        int lenA= a.length;
8
        int lenB = this.a.length;
8
        int lenB = this.a.length;
9
        C c = new C();
9
        C c = new C();
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-1 / +1 lines)
Lines 4393-4399 Link Here
4393
    		"\n" +
4393
    		"\n" +
4394
    		"class Use {\n" +
4394
    		"class Use {\n" +
4395
    		"	public static void main(String[] args) {\n" +
4395
    		"	public static void main(String[] args) {\n" +
4396
    		"		X<String> i= null;\n" +
4396
    		"		X<String> i= new X<String>();\n" +
4397
    		"		i.foo(\"Eclipse\");\n" +
4397
    		"		i.foo(\"Eclipse\");\n" +
4398
    		"	}\n" +
4398
    		"	}\n" +
4399
    		"}";
4399
    		"}";

Return to bug 192875