update jdt.core & tests from I20140311-0800 - end of this branch!
replay from commit de91a8b71b6719cd9ae8cd576a92e58e3cdf2536
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index 1c94118..214844f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14066,4 +14066,53 @@
"1 problem (1 warning)\n",
true);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=419351
+public void testBug419351() {
+ String backup = System.getProperty("java.endorsed.dirs");
+ String currentWorkingDirectoryPath = System.getProperty("user.dir");
+ if (currentWorkingDirectoryPath == null) {
+ fail("BatchCompilerTest#testBug419351 could not access the current working directory " + currentWorkingDirectoryPath);
+ } else if (!new File(currentWorkingDirectoryPath).isDirectory()) {
+ fail("BatchCompilerTest#testBug419351 current working directory is not a directory " + currentWorkingDirectoryPath);
+ }
+ String endorsedPath = currentWorkingDirectoryPath + File.separator + "endorsed";
+ new File(endorsedPath).mkdir();
+ String lib1Path = endorsedPath + File.separator + "lib1.jar";
+ try {
+ System.setProperty("java.endorsed.dirs", endorsedPath);
+ Util.createJar(
+ new String[] {
+ "java/lang/String.java",
+ "package java.lang;\n" +
+ "public class String {\n" +
+ " public String(java.lang.Object obj) {}\n" +
+ "}\n"
+ },
+ null,
+ lib1Path,
+ JavaCore.VERSION_1_5);
+ this.runConformTest(
+ new String[] {
+ "src/X.java",
+ "public class X {\n" +
+ " public void foo(Object obj) {\n" +
+ " java.lang.String str = new java.lang.String(obj);\n" +
+ " }\n" +
+ "}\n",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "src/X.java\""
+ + " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\""
+ + " -1.4 -nowarn"
+ + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
+ "",
+ "",
+ true);
+ } catch (IOException e) {
+ System.err.println("BatchCompilerTest#testBug419351 could not write to current working directory " + currentWorkingDirectoryPath);
+ } finally {
+ System.setProperty("java.endorsed.dirs", backup);
+ new File(endorsedPath).delete();
+ new File(lib1Path).delete();
+ }
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java
index 6f58202..2727d45 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 GK Software AG and others.
+ * Copyright (c) 2011, 2014 GK Software AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -4653,6 +4653,35 @@
options
);
}
+// https://bugs.eclipse.org/411098 - [compiler][resource] Invalid Resource Leak Warning using ternary operator inside try-with-resource
+// should report potential leak only.
+public void testBug411098_comment19() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportPotentiallyUnclosedCloseable, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportUnclosedCloseable, CompilerOptions.ERROR);
+ runNegativeTest(
+ new String[] {
+ "A.java",
+ "import java.io.PrintWriter;\n" +
+ "public class A {\n" +
+ " PrintWriter fWriter;\n" +
+ " void bug(boolean useField) {\n" +
+ " PrintWriter bug= useField ? fWriter : null;\n" +
+ " System.out.println(bug);\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in A.java (at line 5)\n" +
+ " PrintWriter bug= useField ? fWriter : null;\n" +
+ " ^^^\n" +
+ "Potential resource leak: \'bug\' may not be closed\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
// normal java.util.stream.Stream doesn't hold on to any resources
public void testStream1() {
if (this.complianceLevel < ClassFileConstants.JDK1_8)
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
index 165b19a..d78c27f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1463,7 +1463,7 @@
"public class testDuplicateHashCode {\n" +
" public static void main(String[] argv) {\n" +
" String dispatcher = \"\u0000\";\n" +
- " for (int i = 0; i < 100; i++) {\n" +
+ " outer: for (int i = 0; i < 100; i++) {\n" +
" switch (dispatcher) {\n" +
" case \"\u0000\":\n" +
" System.out.print(\"1 \");\n" +
@@ -1482,7 +1482,7 @@
" break;\n" +
" default:\n" +
" System.out.println(\"Default\");\n" +
- " System.exit(0);\n" +
+ " break outer;\n" +
" case \"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\":\n" +
" System.out.print(\"8 \");\n" +
" break;\n" +
@@ -1519,7 +1519,7 @@
"public class testDuplicateHashCode {\n" +
" public static void main(String[] argv) {\n" +
" String dispatcher = \"\u0000\";\n" +
- " while(true) {\n" +
+ " outer: while(true) {\n" +
" switch (dispatcher) {\n" +
" case \"\u0000\":\n" +
" System.out.print(\"1 \");\n" +
@@ -1543,7 +1543,7 @@
" break;\n" +
" default:\n" +
" System.out.println(\"Default\");\n" +
- " System.exit(0);\n" +
+ " break outer;\n" +
" case \"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\":\n" +
" System.out.print(\"8 \");\n" +
" dispatcher = \"\u0000\u0000\u0000\u0000\u0000\u0000\";\n" +
@@ -1721,7 +1721,7 @@
" return string.substring(index,index + 1);\n" +
" }\n" +
" public static void main(String [] args) {\n" +
- " while (true) {\n" +
+ " outer: while (true) {\n" +
" String s = null;\n" +
" switch(s = dispatcher()) {\n" +
" case \"2\":\n" +
@@ -1739,7 +1739,7 @@
" System.out.print(s + \"(odd) \");\n" +
" break;\n" +
" default: System.out.print(\"DONE\");\n" +
- " System.exit(0);\n" +
+ " break outer;\n" +
" }\n" +
" }\n" +
" }\n" +
@@ -1771,7 +1771,7 @@
" return string.substring(index,index + 1);\n" +
" }\n" +
" public static void main(String [] args) {\n" +
- " while (true) {\n" +
+ " outer: while (true) {\n" +
" String s = null;\n" +
" switch(s = dispatcher()) {\n" +
" case \"4\": System.out.print(s);\n" +
@@ -1780,7 +1780,7 @@
" case \"1\": System.out.print(s + \" \");\n" +
" case \"0\": break;\n" +
" default: System.out.print(\"DONE\");\n" +
- " System.exit(0);\n" +
+ " break outer;\n" +
" }\n" +
" }\n" +
" }\n" +
@@ -1845,11 +1845,9 @@
" System.out.print(s + \"(odd) \");\n" +
" break;\n" +
" default: System.out.print(\"DONE\");\n" +
- " System.exit(0);\n" +
" break junk;\n" +
" }\n" +
" }\n" +
- " System.out.println(\"Broken\");\n" +
" }\n" +
"}\n",
};
diff --git a/org.eclipse.jdt.core.tests.compiler/test.xml b/org.eclipse.jdt.core.tests.compiler/test.xml
index 2ff4a27..c4e07bb 100644
--- a/org.eclipse.jdt.core.tests.compiler/test.xml
+++ b/org.eclipse.jdt.core.tests.compiler/test.xml
@@ -34,11 +34,6 @@
<!-- This target defines the tests that need to be run. -->
<target name="suite">
- <condition property="onWin32">
- <and>
- <os family="windows" />
- </and>
- </condition>
<!-- Parser tests -->
<property name="jdt-parser-folder"
value="${eclipse-home}/jdt_parser_folder"/>
@@ -64,7 +59,7 @@
<antcall target="evaluation_tests"/>
</target>
- <target name="evaluation_tests" if="onWin32">
+ <target name="evaluation_tests">
<!-- Evaluation tests -->
<property name="jdt-eval-folder"
value="${eclipse-home}/jdt_eval_folder"/>