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

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+51 lines)
Lines 13-18 Link Here
13
 *     							bug 295551 - Add option to automatically promote all warnings to errors
13
 *     							bug 295551 - Add option to automatically promote all warnings to errors
14
 *     							bug 185682 - Increment/decrement operators mark local variables as read
14
 *     							bug 185682 - Increment/decrement operators mark local variables as read
15
 *     							bug 349326 - [1.7] new warning for missing try-with-resources
15
 *     							bug 349326 - [1.7] new warning for missing try-with-resources
16
 *     							bug 359721 - [options] add command line option for new warning token "resource"
16
 *******************************************************************************/
17
 *******************************************************************************/
17
package org.eclipse.jdt.core.tests.compiler.regression;
18
package org.eclipse.jdt.core.tests.compiler.regression;
18
19
Lines 1705-1710 Link Here
1705
        "      paramAssign          assignment to a parameter\n" + 
1706
        "      paramAssign          assignment to a parameter\n" + 
1706
        "      pkgDefaultMethod   + attempt to override package-default method\n" + 
1707
        "      pkgDefaultMethod   + attempt to override package-default method\n" + 
1707
        "      raw                + usage of raw type\n" + 
1708
        "      raw                + usage of raw type\n" + 
1709
        "      resource           + (potential) leaks of resources of type Closeable\n" + 
1708
        "      semicolon            unnecessary semicolon, empty statement\n" + 
1710
        "      semicolon            unnecessary semicolon, empty statement\n" + 
1709
        "      serial             + missing serialVersionUID\n" + 
1711
        "      serial             + missing serialVersionUID\n" + 
1710
        "      specialParamHiding   constructor or setter parameter hiding a field\n" + 
1712
        "      specialParamHiding   constructor or setter parameter hiding a field\n" + 
Lines 12241-12244 Link Here
12241
		"3 problems (1 error, 2 warnings)",
12243
		"3 problems (1 error, 2 warnings)",
12242
		true);
12244
		true);
12243
}
12245
}
12246
//-warn option - regression tests
12247
public void test0308_warn_options() {
12248
	// check the option introduced in bug 359721
12249
	this.runConformTest(
12250
		new String[] {
12251
			"X.java",
12252
			"import java.io.FileReader;\n" +
12253
			"public class X {\n" +
12254
			"  void foo() throws java.io.IOException {\n" +
12255
			"      FileReader r = new FileReader(\"f1\");\n" +
12256
			"      char[] cs = new char[1024];\n" +
12257
			"	   r.read(cs);\n" +
12258
			"  }\n" +
12259
			"}\n"
12260
		},
12261
		"\"" + OUTPUT_DIR +  File.separator + "X.java\""
12262
		+ " -warn:-resource -1.7 -d \"" + OUTPUT_DIR + "\"",
12263
		"",
12264
		"",
12265
		true);
12266
}
12267
//-warn option - regression tests
12268
public void test0309_warn_options() {
12269
	// check the option introduced in bug 359721
12270
	this.runConformTest(
12271
		new String[] {
12272
			"X.java",
12273
			"import java.io.FileReader;\n" +
12274
			"public class X {\n" +
12275
			"  void foo(boolean b) throws java.io.IOException {\n" +
12276
			"      FileReader r = new FileReader(\"f1\");\n" +
12277
			"      char[] cs = new char[1024];\n" +
12278
			"	   r.read(cs);\n" +
12279
			"      if (b) r.close();\n" +
12280
			"  }\n" +
12281
			"}\n"
12282
		},
12283
		"\"" + OUTPUT_DIR +  File.separator + "X.java\""
12284
		+ " -warn:+resource -1.7 -d \"" + OUTPUT_DIR + "\"",
12285
		"",
12286
		"----------\n" + 
12287
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + 
12288
		"	FileReader r = new FileReader(\"f1\");\n" + 
12289
		"	           ^\n" + 
12290
		"Potential resource leak: \'r\' may not be closed\n" + 
12291
		"----------\n" + 
12292
		"1 problem (1 warning)",
12293
		true);
12294
}
12244
}
12295
}
(-)a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-2 / +9 lines)
Lines 10-17 Link Here
10
 *     Tom Tromey - Contribution for bug 125961
10
 *     Tom Tromey - Contribution for bug 125961
11
 *     Tom Tromey - Contribution for bug 159641
11
 *     Tom Tromey - Contribution for bug 159641
12
 *     Benjamin Muskalla - Contribution for bug 239066
12
 *     Benjamin Muskalla - Contribution for bug 239066
13
 *     Stephan Herrmann  - Contribution for bug 236385
13
 *     Stephan Herrmann  - Contributions for 
14
 *     Stephan Herrmann  - Contribution for bug 295551
14
 *     							bug 236385 - [compiler] Warn for potential programming problem if an object is created but not used
15
 *     							bug 295551 - Add option to automatically promote all warnings to errors
16
 *     							bug 359721 - [options] add command line option for new warning token "resource"
15
 *******************************************************************************/
17
 *******************************************************************************/
16
package org.eclipse.jdt.internal.compiler.batch;
18
package org.eclipse.jdt.internal.compiler.batch;
17
19
Lines 3432-3437 Link Here
3432
			} else if (/*token.equals("intfRedundant") ||*/ token.equals("redundantSuperinterface")) { //$NON-NLS-1$
3434
			} else if (/*token.equals("intfRedundant") ||*/ token.equals("redundantSuperinterface")) { //$NON-NLS-1$
3433
				setSeverity(CompilerOptions.OPTION_ReportRedundantSuperinterface, severity, isEnabling);
3435
				setSeverity(CompilerOptions.OPTION_ReportRedundantSuperinterface, severity, isEnabling);
3434
				return;
3436
				return;
3437
			} else if (token.equals("resource")) { //$NON-NLS-1$
3438
				setSeverity(CompilerOptions.OPTION_ReportUnclosedCloseable, severity, isEnabling);
3439
				setSeverity(CompilerOptions.OPTION_ReportPotentiallyUnclosedCloseable, severity, isEnabling);
3440
				setSeverity(CompilerOptions.OPTION_ReportExplicitlyClosedAutoCloseable, severity, isEnabling);
3441
				return;
3435
			}
3442
			}
3436
			break;
3443
			break;
3437
		case 's' :
3444
		case 's' :
(-)a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (+5 lines)
Lines 8-13 Link Here
8
# Contributors:
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
#		Benjamin Muskalla - Contribution for bug 239066
10
#		Benjamin Muskalla - Contribution for bug 239066
11
#		Stephan Herrmann - Contributions for
12
#								bug 236385 - [compiler] Warn for potential programming problem if an object is created but not used
13
#								bug 295551 - Add option to automatically promote all warnings to errors
14
#								bug 359721 - [options] add command line option for new warning token "resource"
11
###############################################################################
15
###############################################################################
12
### JavaBatchCompiler messages.
16
### JavaBatchCompiler messages.
13
17
Lines 307-312 Link Here
307
\      paramAssign          assignment to a parameter\n\
311
\      paramAssign          assignment to a parameter\n\
308
\      pkgDefaultMethod   + attempt to override package-default method\n\
312
\      pkgDefaultMethod   + attempt to override package-default method\n\
309
\      raw                + usage of raw type\n\
313
\      raw                + usage of raw type\n\
314
\      resource           + (potential) leaks of resources of type Closeable\n\
310
\      semicolon            unnecessary semicolon, empty statement\n\
315
\      semicolon            unnecessary semicolon, empty statement\n\
311
\      serial             + missing serialVersionUID\n\
316
\      serial             + missing serialVersionUID\n\
312
\      specialParamHiding   constructor or setter parameter hiding a field\n\
317
\      specialParamHiding   constructor or setter parameter hiding a field\n\

Return to bug 359721