Merge branch 'master' into integration
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
index d247111..0c6446f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -76,6 +76,7 @@
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=122881
public void test002() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_7) {
this.runConformTest(
new String[] {
"X.java",
@@ -92,8 +93,31 @@
" }\n" +
"}"
},
- "works"
- );
+ "works");
+ } else {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static interface I1<E1> { void method(E1 o); }\n" +
+ " static interface I2<E2> { void method(E2 o); }\n" +
+ " static interface I3<E3, E4> extends I1<E3>, I2<E4> {}\n" +
+ " static class Class1 implements I3<String, String> {\n" +
+ " public void method(String o) { System.out.println(o); }\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I3<String, String> i = new Class1();\n" +
+ " i.method(\"works\");\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " static interface I3<E3, E4> extends I1<E3>, I2<E4> {}\n" +
+ " ^^\n" +
+ "Name clash: The method method(E1) of type X.I1<E1> has the same erasure as method(E2) of type X.I2<E2> but does not override it\n" +
+ "----------\n");
+ }
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=122881
public void test002a() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
index 35de475..6f9c873 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -2330,18 +2330,36 @@
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=83162
public void test036d() { // 2 interface cases
// in these cases, bridge methods are needed once abstract/concrete methods are defiined (either in the abstract class or a concrete subclass)
- this.runConformTest(
- new String[] {
- "Y.java",
- "abstract class Y implements Equivalent<String>, EqualityComparable<Integer> {\n" +
- " public abstract boolean equalTo(Number other);\n" +
- "}\n" +
- "interface Equivalent<T> { boolean equalTo(T other); }\n" +
- "interface EqualityComparable<T> { boolean equalTo(T other); }\n"
- },
- ""
- // no bridge methods are created here since Y does not define an equalTo(?) method which equals an inherited equalTo method
- );
+ if (this.complianceLevel < ClassFileConstants.JDK1_7) {
+ this.runConformTest(
+ new String[] {
+ "Y.java",
+ "abstract class Y implements Equivalent<String>, EqualityComparable<Integer> {\n" +
+ " public abstract boolean equalTo(Number other);\n" +
+ "}\n" +
+ "interface Equivalent<T> { boolean equalTo(T other); }\n" +
+ "interface EqualityComparable<T> { boolean equalTo(T other); }\n"
+ },
+ ""
+ // no bridge methods are created here since Y does not define an equalTo(?) method which equals an inherited equalTo method
+ );
+ } else {
+ this.runNegativeTest(
+ new String[] {
+ "Y.java",
+ "abstract class Y implements Equivalent<String>, EqualityComparable<Integer> {\n" +
+ " public abstract boolean equalTo(Number other);\n" +
+ "}\n" +
+ "interface Equivalent<T> { boolean equalTo(T other); }\n" +
+ "interface EqualityComparable<T> { boolean equalTo(T other); }\n"
+ },
+ "----------\n" +
+ "1. ERROR in Y.java (at line 1)\n" +
+ " abstract class Y implements Equivalent<String>, EqualityComparable<Integer> {\n" +
+ " ^\n" +
+ "Name clash: The method equalTo(T) of type Equivalent<T> has the same erasure as equalTo(T) of type EqualityComparable<T> but does not override it\n" +
+ "----------\n");
+ }
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=83162
public void test036e() { // 2 interface cases
@@ -2354,6 +2372,7 @@
"interface Equivalent<T> { boolean equalTo(T other); }\n" +
"interface EqualityComparable<T> { boolean equalTo(T other); }\n"
},
+ this.complianceLevel < ClassFileConstants.JDK1_7 ?
"----------\n" +
"1. ERROR in Y.java (at line 2)\n" +
" public abstract boolean equalTo(Object other);\n" +
@@ -2364,8 +2383,24 @@
" public abstract boolean equalTo(Object other);\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
"Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type EqualityComparable<T> but does not override it\n" +
- "----------\n"
+ "----------\n" :
// name clash: equalTo(java.lang.Object) in Y and equalTo(T) in Equivalent<java.lang.String> have the same erasure, yet neither overrides the other
+ "----------\n" +
+ "1. ERROR in Y.java (at line 1)\n" +
+ " abstract class Y implements Equivalent<String>, EqualityComparable<Integer> {\n" +
+ " ^\n" +
+ "Name clash: The method equalTo(T) of type Equivalent<T> has the same erasure as equalTo(T) of type EqualityComparable<T> but does not override it\n" +
+ "----------\n" +
+ "2. ERROR in Y.java (at line 2)\n" +
+ " public abstract boolean equalTo(Object other);\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type Equivalent<T> but does not override it\n" +
+ "----------\n" +
+ "3. ERROR in Y.java (at line 2)\n" +
+ " public abstract boolean equalTo(Object other);\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type EqualityComparable<T> but does not override it\n" +
+ "----------\n"
);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=83162
@@ -2428,6 +2463,7 @@
"interface K extends I { void foo(A<String> a); }\n" +
"class A<T> {}"
},
+ this.complianceLevel < ClassFileConstants.JDK1_7 ?
"----------\n" +
"1. WARNING in X.java (at line 4)\n" +
" class YYY implements J, I { public void foo(A a) {} }\n" +
@@ -2453,7 +2489,38 @@
" interface K extends I { void foo(A<String> a); }\n" +
" ^^^^^^^^^^^^^^^^\n" +
"Name clash: The method foo(A<String>) of type K has the same erasure as foo(A) of type I but does not override it\n" +
- "----------\n");
+ "----------\n" :
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " abstract class Y implements J, I { }\n" +
+ " ^\n" +
+ "Name clash: The method foo(A<String>) of type J has the same erasure as foo(A) of type I but does not override it\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 4)\n" +
+ " class YYY implements J, I { public void foo(A a) {} }\n" +
+ " ^\n" +
+ "A is a raw type. References to generic type A<T> should be parameterized\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 5)\n" +
+ " class XXX implements I, J { public void foo(A a) {} }\n" +
+ " ^\n" +
+ "A is a raw type. References to generic type A<T> should be parameterized\n" +
+ "----------\n" +
+ "4. WARNING in X.java (at line 6)\n" +
+ " class ZZZ implements K { public void foo(A a) {} }\n" +
+ " ^\n" +
+ "A is a raw type. References to generic type A<T> should be parameterized\n" +
+ "----------\n" +
+ "5. WARNING in X.java (at line 7)\n" +
+ " interface I { void foo(A a); }\n" +
+ " ^\n" +
+ "A is a raw type. References to generic type A<T> should be parameterized\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 9)\n" +
+ " interface K extends I { void foo(A<String> a); }\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Name clash: The method foo(A<String>) of type K has the same erasure as foo(A) of type I but does not override it\n" +
+ "----------\n");
}
public void test037a() { // test inheritance scenarios
this.runNegativeTest(
@@ -13617,4 +13684,130 @@
},
this.complianceLevel <= ClassFileConstants.JDK1_5 ? "Annotation was found" : "Annotation was not found");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=354229
+public void test354229() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.*;\n" +
+ "interface A {\n" +
+ "int get(List<String> l);\n" +
+ "}\n" +
+ "interface B {\n" +
+ "int get(List<Integer> l);\n" +
+ "}\n" +
+ "interface C extends A, B { \n" +
+ "//int get(List l); // name clash error here\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ this.complianceLevel <= ClassFileConstants.JDK1_6 ?
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n" :
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " interface C extends A, B { \n" +
+ " ^\n" +
+ "Name clash: The method get(List<String>) of type A has the same erasure as get(List<Integer>) of type B but does not override it\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=354229
+public void test354229b() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.*;\n" +
+ "interface A {\n" +
+ "int get(List<String> l);\n" +
+ "}\n" +
+ "interface B {\n" +
+ "int get(List<Integer> l);\n" +
+ "}\n" +
+ "interface C extends A, B { \n" +
+ " int get(List l); // name clash error here\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 9)\n" +
+ " int get(List l); // name clash error here\n" +
+ " ^^^^\n" +
+ "List is a raw type. References to generic type List<E> should be parameterized\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=354229
+public void test354229c() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n" +
+ " <T> T e(Action<T> p);\n" +
+ "}\n" +
+ "interface Y {\n" +
+ " <S, T> S e(Action<S> t);\n" +
+ "}\n" +
+ "interface E extends X, Y {\n" +
+ "}\n" +
+ "class Action<T> {\n" +
+ " Zork z;\n" +
+ "}\n"
+
+ },
+ this.complianceLevel < ClassFileConstants.JDK1_7 ?
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n" :
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " interface E extends X, Y {\n" +
+ " ^\n" +
+ "Name clash: The method e(Action<T>) of type X has the same erasure as e(Action<S>) of type Y but does not override it\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=354229
+public void test354229d() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n" +
+ " <T> T e(Action<T> p);\n" +
+ " <S, T> S e(Action<S> t);\n" +
+ "}\n" +
+ "class Action<T> {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " <T> T e(Action<T> p);\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "Method e(Action<T>) has the same erasure e(Action<T>) as another method in type X\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " <S, T> S e(Action<S> t);\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "Method e(Action<S>) has the same erasure e(Action<T>) as another method in type X\n" +
+ "----------\n");
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
index 1d28367..2db03cf 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -12,6 +12,7 @@
import java.util.Map;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import junit.framework.Test;
@@ -24,7 +25,7 @@
// All specified tests which does not belong to the class are skipped...
static {
// TESTS_NAMES = new String[] { "test127" };
-// TESTS_NUMBERS = new int[] { 5 };
+// TESTS_NUMBERS = new int[] { 7 };
// TESTS_RANGE = new int[] { 169, 180 };
}
@@ -258,4 +259,41 @@
// javac options
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
}
+ public void test007() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) {
+ return;
+ }
+ Map customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_FatalOptionalError,
+ CompilerOptions.ENABLED);
+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal,
+ CompilerOptions.ERROR);
+ customOptions.put(CompilerOptions.OPTION_SuppressWarnings,
+ CompilerOptions.ENABLED);
+ customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors,
+ CompilerOptions.ENABLED);
+ customOptions.put(CompilerOptions.OPTION_ReportUnusedWarningToken,
+ CompilerOptions.ERROR);
+ runConformTest(
+ new String[] { /* test files */
+ "X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"unused\")\n" +
+ " static void foo() {\n" +
+ " String s = null;\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " public static void main(String argv[]) {\n" +
+ " foo();\n" +
+ " }\n" +
+ "}"
+ },
+ "SUCCESS" /* expected output string */,
+ null /* no class libraries */,
+ true,
+ null,
+ customOptions /* custom options */,
+ // compiler results
+ null /* do not check error string */);
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java
index 2349a4b..0c9324c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 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
@@ -21,6 +21,7 @@
* bug 358827 - [1.7] exception analysis for t-w-r spoils null analysis
* bug 349326 - [1.7] new warning for missing try-with-resources
* bug 360328 - [compiler][null] detect null problems in nested code (local class inside a loop)
+ * bug 367879 - Incorrect "Potential null pointer access" warning on statement after try-with-resources within try-finally
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -15008,6 +15009,32 @@
"----------\n");
}
}
+// Bug 367879 - Incorrect "Potential null pointer access" warning on statement after try-with-resources within try-finally
+public void test367879() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_7) {
+ this.runConformTest(
+ new String[] {
+ "Bug367879.java",
+ "import java.io.IOException;\n" +
+ "import java.io.InputStream;\n" +
+ "import java.net.HttpURLConnection;\n" +
+ "import java.net.URL;\n" +
+ "public class Bug367879 {\n" +
+ " public void test() throws IOException {\n" +
+ " HttpURLConnection http = null;\n" +
+ " try {\n" +
+ " http = (HttpURLConnection) new URL(\"http://example.com/\").openConnection();\n" +
+ " try (InputStream in = http.getInputStream()) { /* get input */ }\n" +
+ " http.getURL();\n" + // shouldn't *not* flag as Potential null pointer access
+ " } finally {\n" +
+ " if (http != null) { http.disconnect(); }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "");
+ }
+}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=256796
public void testBug256796() {
Map compilerOptions = getCompilerOptions();
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
index f6543aa..8b83af7 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2012 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
@@ -19,6 +19,7 @@
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
public class StackMapAttributeTest extends AbstractRegressionTest {
public StackMapAttributeTest(String name) {
@@ -7089,4 +7090,530 @@
},
"");
}
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=366999
+ public void test056() throws Exception {
+ if (this.complianceLevel < ClassFileConstants.JDK1_7) return;
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.BufferedReader;\n" +
+ "import java.io.Closeable;\n" +
+ "import java.io.File;\n" +
+ "import java.io.FileReader;\n" +
+ "import java.io.IOException;\n" +
+ "\n" +
+ "public class X {\n" +
+ "\n" +
+ " static class C implements Closeable {\n" +
+ " @Override\n" +
+ " public void close() throws IOException {\n" +
+ " //\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ " int run() throws IOException {\n" +
+ " int lcnt = 0;\n" +
+ " try (C c = new C();) {\n" +
+ " try (final BufferedReader br = new BufferedReader(new FileReader(\n" +
+ " new File(\"logging.properties\")))) {\n" +
+ " String s = null;\n" +
+ " while ((s = br.readLine()) != null)\n" +
+ " lcnt++;\n" +
+ " return lcnt;\n" +
+ " }\n" +
+ " } finally {\n" +
+ " System.out.println(\"read \" + lcnt + \" lines\");\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(final String[] args) throws IOException {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}",
+ },
+ "SUCCESS");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test057() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " for (;;) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n",
+ },
+ "SUCCESS");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test058() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " for (;true;) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "SUCCESS");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test059() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " for (;false;) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "----------\n" +
+ "1. WARNING in X.java (at line 4)\n" +
+ " label1: do {\n" +
+ " ^^^^^^\n" +
+ "The label label1 is never explicitly referenced\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " for (;false;) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Unreachable code\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 10)\n" +
+ " } while (s != null);\n" +
+ " ^\n" +
+ "The local variable s may not have been initialized\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test060() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " for (; 5 < 10;) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "SUCCESS");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test061() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " int five = 5, ten = 10;\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " for (; five < ten;) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "----------\n" +
+ "1. WARNING in X.java (at line 9)\n" +
+ " continue label1;\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Dead code\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 11)\n" +
+ " } while (s != null);\n" +
+ " ^\n" +
+ "The local variable s may not have been initialized\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test062() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " final int five = 5, ten = 10;\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " for (; five < ten;) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "SUCCESS");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test063() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " final int five = 5, ten = 10;\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " for (; five > ten;) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " label1: do {\n" +
+ " ^^^^^^\n" +
+ "The label label1 is never explicitly referenced\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " for (; five > ten;) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Unreachable code\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 11)\n" +
+ " } while (s != null);\n" +
+ " ^\n" +
+ "The local variable s may not have been initialized\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test064() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " while (true) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n",
+ },
+ "SUCCESS");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test065() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " while (false) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "----------\n" +
+ "1. WARNING in X.java (at line 4)\n" +
+ " label1: do {\n" +
+ " ^^^^^^\n" +
+ "The label label1 is never explicitly referenced\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " while (false) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Unreachable code\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 10)\n" +
+ " } while (s != null);\n" +
+ " ^\n" +
+ "The local variable s may not have been initialized\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test066() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " while(5 < 10) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "SUCCESS");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test067() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " int five = 5, ten = 10;\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " while (five < ten) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "----------\n" +
+ "1. WARNING in X.java (at line 9)\n" +
+ " continue label1;\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Dead code\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 11)\n" +
+ " } while (s != null);\n" +
+ " ^\n" +
+ "The local variable s may not have been initialized\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test068() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " final int five = 5, ten = 10;\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " while (five < ten) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "SUCCESS");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test069() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void run() {\n" +
+ " final int five = 5, ten = 10;\n" +
+ " String s;\n" +
+ " label1: do {\n" +
+ " while (five > ten) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " } while (s != null);\n" +
+ "}\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n" },
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " label1: do {\n" +
+ " ^^^^^^\n" +
+ "The label label1 is never explicitly referenced\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " while (five > ten) {\n" +
+ " s = \"\";\n" +
+ " if (s == null) \n" +
+ " continue label1;\n" +
+ " }\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Unreachable code\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 11)\n" +
+ " } while (s != null);\n" +
+ " ^\n" +
+ "The local variable s may not have been initialized\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023
+ public void test070() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.ArrayList;\n" +
+ "import java.util.Arrays;\n" +
+ "import java.util.Iterator;\n" +
+ "import java.util.List;\n" +
+ "import java.util.Properties;\n" +
+ "import org.w3c.dom.*;\n" +
+ "public class X extends Object {\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println (\"SUCCESS\");\n" +
+ " }\n" +
+ " private static class Handler extends Object {\n" +
+ " public int getStuff() {\n" +
+ " return 1;\n" +
+ " }\n" +
+ " public void handle(Element element) {\n" +
+ " Properties properties = new Properties();\n" +
+ " NamedNodeMap atts = element.getAttributes();\n" +
+ " if (atts != null) {\n" +
+ " for (int a = 0; a < atts.getLength(); a++) {\n" +
+ " Node att = atts.item(a);\n" +
+ " String name = att.getNodeName();\n" +
+ " String value = att.getNodeValue();\n" +
+ " if (\"foo\".equals(name)) {\n" +
+ " name = value;\n" +
+ " } else {\n" +
+ " if (!\"bar\".equals(name))\n" +
+ " continue;\n" +
+ " name = value;\n" +
+ " }\n" +
+ " properties.put(name, value);\n" +
+ " }\n" +
+ " }\n" +
+ " label0: do {\n" +
+ " Node node;\n" +
+ " String nodeName;\n" +
+ " label1: do {\n" +
+ " for (Iterator i = (new ArrayList(1)).iterator(); i\n" +
+ " .hasNext(); members.add(equals(node))) {\n" +
+ " node = (Node) i.next();\n" +
+ " nodeName = \"\" + equals(node.getNodeName());\n" +
+ " if (!\"foo\".equals(nodeName))\n" +
+ " continue label1;\n" +
+ " }\n" +
+ " break label0;\n" +
+ " } while (!\"bar\".equals(nodeName));\n" +
+ " Iterator i = (new ArrayList(1)).iterator();\n" +
+ " while (i.hasNext()) {\n" +
+ " Node n = (Node) i.next();\n" +
+ " String name = toString() + n.getNodeName();\n" +
+ " if (\"wtf\".equals(name)) {\n" +
+ " String propertyName = (toString() + n.getAttributes()\n" +
+ " .getNamedItem(\"broken\")).trim();\n" +
+ " String value = toString() + n;\n" +
+ " properties.put(propertyName, value);\n" +
+ " }\n" +
+ " }\n" +
+ " } while (true);\n" +
+ " propertiesBuilder.equals(properties);\n" +
+ " builder.equals(propertiesBuilder.hashCode());\n" +
+ " builder.equals(members);\n" +
+ " }\n" +
+ " private final Object c;\n" +
+ " private Object builder;\n" +
+ " private List members;\n" +
+ " private Object propertiesBuilder;\n" +
+ " public Handler(Object c) {\n" +
+ " this.c = c;\n" +
+ " builder = Arrays.asList(Object.class);\n" +
+ " builder.equals(\"foo\");\n" +
+ " builder.equals(\"bar\");\n" +
+ " members = new ArrayList();\n" +
+ " propertiesBuilder = Arrays.asList(Object.class);\n" +
+ " Object beanDefinition = propertiesBuilder.toString();\n" +
+ " Object holder = new String(\"stirng\");\n" +
+ " Arrays.asList(holder, c.toString());\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " }\n" +
+ " protected Object parseInternal(Element element, Object c) {\n" +
+ " Handler h = new Handler(c);\n" +
+ " h.handle(element);\n" +
+ " return h.getStuff();\n" +
+ " }\n" +
+ "}\n"
+ },
+ "SUCCESS");
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java
index 563cc0b..f21a57f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 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
@@ -5226,6 +5226,135 @@
"}\n"
}, "");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=367566 - In try-with-resources statement close() method of resource is not called
+public void test059() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "\n" +
+ "public class X implements java.lang.AutoCloseable {\n" +
+ " static boolean isOpen = true;\n" +
+ " public static void main(final String[] args) throws IOException {\n" +
+ " foo();\n" +
+ " System.out.println(isOpen);\n" +
+ " }\n" +
+ " static boolean foo() {\n" +
+ " try (final X x = new X()) {\n" +
+ " return x.num() >= 1;\n" +
+ " }\n" +
+ " }\n" +
+ " int num() { return 2; }\n" +
+ " public void close() {\n" +
+ " isOpen = false;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "false");
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=367566 - In try-with-resources statement close() method of resource is not called
+public void test060() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X implements AutoCloseable {\n" +
+ " static int num = 10 ;\n" +
+ " public static void main(String [] args) throws Exception { \n" +
+ " System.out.println(foo(1));\n" +
+ " System.out.println(foo(2));\n" +
+ " System.out.println(foo(3));\n" +
+ " }\n" +
+ " private static boolean foo(int where) throws Exception {\n" +
+ " final boolean getOut = true;\n" +
+ " System.out.println(\"Main\");\n" +
+ " try (X x1 = new X(); X x2 = new X()) {\n" +
+ " if (where == 1) {\n" +
+ " return where == 1;\n" +
+ " }\n" +
+ " System.out.println(\"Outer Try\");\n" +
+ " while (true) {\n" +
+ " try (Y y1 = new Y(); Y y2 = new Y()) { \n" +
+ " if (where == 2) {\n" +
+ " return where == 2;\n" +
+ " } \n" +
+ " System.out.println(\"Middle Try\");\n" +
+ " try (Z z1 = new Z(); Z z2 = new Z()) {\n" +
+ " System.out.println(\"Inner Try\");\n" +
+ " if (getOut) \n" +
+ " return num >= 10;\n" +
+ " else\n" +
+ " break; \n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " System.out.println(\"Out of while\");\n" +
+ " }\n" +
+ " return false;\n" +
+ " }\n" +
+ " public X() {\n" +
+ " System.out.println(\"X::X\");\n" +
+ " }\n" +
+ " @Override\n" +
+ " public void close() throws Exception {\n" +
+ " System.out.println(\"X::~X\");\n" +
+ " }\n" +
+ "}\n" +
+ "class Y implements AutoCloseable {\n" +
+ " public Y() {\n" +
+ " System.out.println(\"Y::Y\");\n" +
+ " }\n" +
+ " @Override\n" +
+ " public void close() throws Exception {\n" +
+ " System.out.println(\"Y::~Y\");\n" +
+ " }\n" +
+ "}\n" +
+ "class Z implements AutoCloseable {\n" +
+ " public Z() {\n" +
+ " System.out.println(\"Z::Z\");\n" +
+ " }\n" +
+ " @Override\n" +
+ " public void close() throws Exception {\n" +
+ " System.out.println(\"Z::~Z\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ "Main\n" +
+ "X::X\n" +
+ "X::X\n" +
+ "X::~X\n" +
+ "X::~X\n" +
+ "true\n" +
+ "Main\n" +
+ "X::X\n" +
+ "X::X\n" +
+ "Outer Try\n" +
+ "Y::Y\n" +
+ "Y::Y\n" +
+ "Y::~Y\n" +
+ "Y::~Y\n" +
+ "X::~X\n" +
+ "X::~X\n" +
+ "true\n" +
+ "Main\n" +
+ "X::X\n" +
+ "X::X\n" +
+ "Outer Try\n" +
+ "Y::Y\n" +
+ "Y::Y\n" +
+ "Middle Try\n" +
+ "Z::Z\n" +
+ "Z::Z\n" +
+ "Inner Try\n" +
+ "Z::~Z\n" +
+ "Z::~Z\n" +
+ "Y::~Y\n" +
+ "Y::~Y\n" +
+ "X::~X\n" +
+ "X::~X\n" +
+ "true");
+}
+
public static Class testClass() {
return TryWithResourcesStatementTest.class;
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
index a616ecd..37eddcd 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -2922,13 +2922,6 @@
return org.eclipse.jdt.core.tests.util.Util.toString(strings, false/*don't add extra new line*/);
}
protected void tearDown() throws Exception {
- if (JavaModelManager.DEBUG_302850) {
- System.out.println(" - Options before tear down:");
- System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS));
- System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES));
- System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
- System.out.println(org.eclipse.jdt.core.tests.util.Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2));
- }
super.tearDown();
if (this.workingCopies != null) {
@@ -2937,17 +2930,6 @@
}
this.wcOwner = null;
- if (JavaModelManager.DEBUG_302850) {
- System.out.println(" - Options before comparison with defaults:");
- System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS));
- System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES));
- System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
- System.out.println(org.eclipse.jdt.core.tests.util.Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2));
- System.out.println(" - Default Options before comparison:");
- System.out.println(org.eclipse.jdt.core.tests.util.Util.indentString(new CompilerOptions(JavaCore.getDefaultOptions()).toString(), 2));
- System.out.println("================================================================================");
- }
-
// ensure workspace options have been restored to their default
Hashtable options = JavaCore.getOptions();
Hashtable defaultOptions = JavaCore.getDefaultOptions();
@@ -2955,8 +2937,6 @@
"Workspace options should be back to their default",
new CompilerOptions(defaultOptions).toString(),
new CompilerOptions(options).toString());
-
- JavaModelManager.DEBUG_302850 = false;
}
/**
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaIndexTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaIndexTests.java
index 89d3a5a..1893d3f 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaIndexTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaIndexTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2012 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
@@ -169,9 +169,10 @@
}
// Test that the same index file is used even after restarting
- public void _testUseIndexInternalJarAfterRestart() throws IOException, CoreException {
+ public void testUseIndexInternalJarAfterRestart() throws IOException, CoreException {
String indexFilePath = getExternalResourcePath("Test.index");
String jarFilePath = "/P/Test.jar";
+ String fullJarPath = getWorkspacePath() + jarFilePath;
try {
IJavaProject p = createJavaProject("P");
createJar(new String[] {
@@ -179,8 +180,9 @@
"package pkg;\n" +
"public class Test {\n" +
" protected Test(int i) {}\n" +
- "}"}, jarFilePath);
- JavaIndexer.generateIndexForJar(jarFilePath, indexFilePath);
+ "}"}, fullJarPath);
+ p.getProject().refreshLocal(1, null);
+ JavaIndexer.generateIndexForJar(fullJarPath, indexFilePath);
long modified = new File(indexFilePath).lastModified();
IPath libPath = new Path(jarFilePath);
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, "file:///"+indexFilePath);
@@ -189,17 +191,18 @@
waitUntilIndexesReady();
search("Test", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p}));
- assertSearchResults("\\P\\Test.jar pkg.Test");
+ assertSearchResults("Test.jar pkg.Test [No source]");
+ java.io.File indexFile = JavaModelManager.getIndexManager().getIndex(libPath, false, false).getIndexFile();
+ assertEquals(indexFilePath,indexFile.toString());
simulateExitRestart();
- getJavaModel().refreshExternalArchives(null, null);
waitUntilIndexesReady();
this.resultCollector = new JavaSearchResultCollector();
search("Test", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p}));
- assertSearchResults("\\P\\Test.jar pkg.Test");
+ assertSearchResults("Test.jar pkg.Test [No source]");
- java.io.File indexFile = JavaModelManager.getIndexManager().getIndex(libPath, false, false).getIndexFile();
+ indexFile = JavaModelManager.getIndexManager().getIndex(libPath, false, false).getIndexFile();
assertEquals(indexFilePath,indexFile.toString());
// Ensure that the file is not modified
assertEquals(modified, new File(indexFilePath).lastModified());
@@ -593,9 +596,10 @@
}
// Test changing the classpath
- public void _testChangeClasspathForInternalJar() throws CoreException, IOException {
+ public void testChangeClasspathForInternalJar() throws CoreException, IOException {
String indexFilePath = getExternalResourcePath("Test.index");
String jarFilePath = "/P/Test.jar";
+ String fullJarPath = getWorkspacePath() + jarFilePath;
try {
IJavaProject p = createJavaProject("P");
createJar(new String[] {
@@ -603,8 +607,8 @@
"package pkg;\n" +
"public class Test {\n" +
" protected Test(int i) {}\n" +
- "}"}, jarFilePath);
- JavaIndexer.generateIndexForJar(jarFilePath, indexFilePath);
+ "}"}, fullJarPath);
+ JavaIndexer.generateIndexForJar(fullJarPath, indexFilePath);
createJar(new String[] {
"pkg/Test.java",
"package pkg;\n" +
@@ -615,14 +619,15 @@
"package pkg;\n" +
"public class NewTest {\n" +
" protected NewTest(int i) {}\n" +
- "}"}, jarFilePath);
+ "}"}, fullJarPath);
+ p.getProject().refreshLocal(1, null);
Path libPath = new Path(jarFilePath);
IClasspathEntry entry = JavaCore.newLibraryEntry(libPath, null, null, null, null, false);
setClasspath(p, new IClasspathEntry[] {entry});
waitUntilIndexesReady();
search("NewTest", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p}));
- assertSearchResults("\\P\\Test.jar pkg.NewTest");
+ assertSearchResults("Test.jar pkg.NewTest [No source]");
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, "file:///"+indexFilePath);
entry = JavaCore.newLibraryEntry(libPath, null, null, null, new IClasspathAttribute[]{attribute}, false);
@@ -637,9 +642,7 @@
waitUntilIndexesReady();
this.resultCollector = new JavaSearchResultCollector();
search("NewTest", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p}));
- assertSearchResults("\\P\\Test.jar pkg.NewTest");
-
-
+ assertSearchResults("Test.jar pkg.NewTest [No source]");
} finally {
deleteProject("P");
new File(indexFilePath).delete();
@@ -766,7 +769,7 @@
}
// Test that it works if the index file is in the jar file
- public void _testIndexInJar() throws IOException, CoreException {
+ public void testIndexInJar() throws IOException, CoreException {
String indexFilePath = getExternalResourcePath("Test.index");
String jarFilePath = getExternalResourcePath("Test.jar");
String indexZipPath = getExternalResourcePath("TestIndex.zip");
@@ -783,7 +786,7 @@
IJavaProject p = createJavaProject("P");
Path libPath = new Path(jarFilePath);
- String url = "jar:file:/"+indexZipPath+"!/Test.index";
+ String url = "jar:file:"+indexZipPath+"!/Test.index";
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, url);
IClasspathEntry entry = JavaCore.newLibraryEntry(libPath, null, null, null, new IClasspathAttribute[]{attribute}, false);
setClasspath(p, new IClasspathEntry[] {entry});
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
index 3b4ba2e..29e67e7 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -69,7 +69,6 @@
import org.eclipse.jdt.core.search.TypeReferenceMatch;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.core.ClassFile;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.SourceMethod;
@@ -11581,9 +11580,9 @@
*/
public void testBug286379c() throws CoreException {
class TestResourceChangeListener implements IResourceChangeListener {
- boolean valid = false;
+ boolean toRemPresent = false;
public void resourceChanged(IResourceChangeEvent event) {
- this.valid = validate(event.getDelta());
+ this.toRemPresent = validate(event.getDelta());
}
/*
* Ensure that the listener receives a delta concerning the resource
@@ -11606,17 +11605,6 @@
return false;
}
}
- // print statement to debug random failures of this test
- JavaModelManager.DEBUG_302850 = true;
- System.out.println("================================================================================");
- System.out.println("Starting test JavaSearchBugTests.testBug286379c()...");
- System.out.println(" - Default Options at test start:");
- System.out.println(Util.indentString(new CompilerOptions(JavaCore.getDefaultOptions()).toString(), 1));
- System.out.println(" - Options at test start:");
- System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS));
- System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES));
- System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
- System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2));
IContentType javaContentType = Platform.getContentTypeManager().getContentType(JavaCore.JAVA_SOURCE_CONTENT_TYPE);
TestResourceChangeListener changeListener = new TestResourceChangeListener();
@@ -11646,7 +11634,7 @@
// fail as we don't get any specific event from the platform to refresh the indexes.
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=118619
int counter = 0;
- while (!changeListener.valid) {
+ while (!changeListener.toRemPresent) {
try {
Thread.sleep(100);
}
@@ -11659,21 +11647,9 @@
// Wait to be sure that indexes are ready after the new resource was added
waitUntilIndexesReady();
- // print statement to debug random failures of this test
- System.out.println(" - Options before first exit:");
- System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS));
- System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES));
- System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
- System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2));
// Restart to let the indexes to be refreshed
simulateExit();
simulateRestart();
- // print statement to debug random failures of this test
- System.out.println(" - Options after first restart:");
- System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS));
- System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES));
- System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
- System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2));
waitUntilIndexesReady();
// Search for the new type with new extension
@@ -11691,22 +11667,23 @@
false /*only assume*/);
// Delete the file specification
+ changeListener.toRemPresent = true;
javaContentType.removeFileSpec("torem", IContentType.FILE_EXTENSION_SPEC);
+ counter = 0;
+ while (changeListener.toRemPresent) {
+ try {
+ Thread.sleep(100);
+ }
+ catch (InterruptedException ie) {
+ // skip
+ }
+ assertTrue("We should have got a resource event within a 10s delay!", counter++ < 100);
+ }
+ waitUntilIndexesReady();
- // print statement to debug random failures of this test
- System.out.println(" - Options before second exit:");
- System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS));
- System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES));
- System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
- System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2));
// Restarting should update the index file to remove the references of any .torem files
simulateExit();
- simulateRestart();
- // print statement to debug random failures of this test
- System.out.println(" - Options after second restart:");
- System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS));
- System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES));
- System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
+ simulateRestart();
waitUntilIndexesReady();
// Search for the new type with new extension
@@ -11719,24 +11696,11 @@
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
null);
assertSearchResults("No search results expected", "", collector);
- System.out.println(" - Options after search:");
- System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS));
- System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES));
- System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
- System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2));
} finally {
getWorkspace().removeResourceChangeListener(changeListener);
if (javaContentType != null)
javaContentType.removeFileSpec("torem", IContentType.FILE_EXTENSION_SPEC);
deleteProject("P");
- System.out.println(" - Options at test end:");
- System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS));
- System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES));
- System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
- System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2));
- System.out.println(" - Default Options at test end:");
- System.out.println(Util.indentString(new CompilerOptions(JavaCore.getDefaultOptions()).toString(), 2));
- JavaModelManager.DEBUG_302850 = false;
}
}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
index b34a543..fc61c7c 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
@@ -19,7 +19,7 @@
#Format: compiler.name = word1 word2 word3
compiler.name = Eclipse Compiler for Java(TM)
#Format: compiler.version = 0.XXX[, other words (don't forget the comma if adding other words)]
-compiler.version = 0.C28, 3.8.0 M4
+compiler.version = 0.C29, 3.8.0 M5
compiler.copyright = Copyright IBM Corp 2000, 2011. All rights reserved.
### progress
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index 2504da0..bcac1a1 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -42,16 +42,41 @@
</td>
</tr>
</table>
+<a name="v_C28"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.8.0 - January 10, 2012 - 3.8.0 M5
+<h2>What's new in this drop</h2>
+
+<h3>Problem Reports Fixed</h3>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023">367023</a>
+Error in JDT Core during AST creation
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=354229">354229</a>
+[compiler][1.7] Name clash error not being reported by ecj.
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=367879">367879</a>
+Incorrect "Potential null pointer access" warning on statement after try-with-resources within try-finally
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=366999">366999</a>
+VerifyError: Inconsistent stackmap frames
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=346175">346175</a>
+@SuppressWarnings should clear all errors including fatal optional errors
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=366544">366544</a>
+[index] Test testUseIndexInternalJarAfterRestart failed on Mac and Linux
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=302850">302850</a>
+13 failures in JavaModel tests for the N20100214-2000 Mac OS X - Cocoa test machine
+
<a name="v_C27"></a>
<hr><h1>
Eclipse Platform Build Notes<br>
Java development tools core</h1>
-Eclipse SDK 3.8.0 - January 3, 2012 - 3.8.1 M5
+Eclipse SDK 3.8.0 - January 3, 2012 - 3.8.0 M5
<br>
<h2>What's new in this drop</h2>
<h3>Problem Reports Fixed</h3>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=364890">364890</a>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=367566">367566</a>
+In try-with-resources statement close() method of resource is not called
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=364890">364890</a>
BinaryTypeBinding should use char constants from Util
<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=365992">365992</a>
[builder] [null] Change of nullness for a parameter doesn't trigger a build for the files that call the method
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
index d9c7ad3..905c0bf 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -362,6 +362,13 @@
}
}
+ public CompilationUnitDeclaration getCompilationUnitDeclaration() {
+ if (this.scope != null) {
+ return this.scope.compilationUnitScope().referenceContext;
+ }
+ return null;
+ }
+
public boolean hasErrors() {
return this.ignoreFurtherInvestigation;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
index eb6f64a..754305e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -364,6 +364,10 @@
}
}
+public CompilationUnitDeclaration getCompilationUnitDeclaration() {
+ return this;
+}
+
public char[] getFileName() {
return this.compilationResult.getFileName();
}
@@ -394,6 +398,24 @@
return CharOperation.equals(getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME);
}
+public boolean isSuppressed(CategorizedProblem problem) {
+ if (this.suppressWarningsCount == 0) return false;
+ int irritant = ProblemReporter.getIrritant(problem.getID());
+ if (irritant == 0) return false;
+ int start = problem.getSourceStart();
+ int end = problem.getSourceEnd();
+ nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
+ long position = this.suppressWarningScopePositions[iSuppress];
+ int startSuppress = (int) (position >>> 32);
+ int endSuppress = (int) position;
+ if (start < startSuppress) continue nextSuppress;
+ if (end > endSuppress) continue nextSuppress;
+ if (this.suppressWarningIrritants[iSuppress].isSet(irritant))
+ return true;
+ }
+ return false;
+}
+
public boolean hasErrors() {
return this.ignoreFurtherInvestigation;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
index 5806ce8..774c7aa 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -101,7 +101,11 @@
(this.action == null
? actionInfo
: (actionInfo.mergedWith(loopingContext.initsOnContinue))).copy());
- this.preConditionInitStateIndex = currentScope.methodScope().recordInitializationStates(actionInfo);
+ /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=367023, we reach the condition at the bottom via two arcs,
+ one by free fall and another by continuing... Merge initializations propagated through the two pathways,
+ cf, while and for loops.
+ */
+ this.preConditionInitStateIndex = currentScope.methodScope().recordInitializationStates(actionInfo.mergedWith(loopingContext.initsOnContinue));
if (!isConditionOptimizedFalse && this.continueLabel != null) {
loopingContext.complainOnDeferredFinalChecks(currentScope, condInfo);
condLoopContext.complainOnDeferredFinalChecks(currentScope, condInfo);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
index 61c67a0..18a1bc1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -64,6 +64,7 @@
int subCount = 0;
boolean saveValueNeeded = false;
boolean hasValueToSave = needValueStore();
+ boolean noAutoCloseables = true;
do {
SubRoutineStatement sub;
if ((sub = traversedContext.subroutine()) != null) {
@@ -79,6 +80,11 @@
this.bits |= ASTNode.IsAnySubRoutineEscaping;
break;
}
+ if (sub instanceof TryStatement) {
+ if (((TryStatement) sub).resources.length > 0) {
+ noAutoCloseables = false;
+ }
+ }
}
traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
@@ -117,7 +123,9 @@
} else {
this.saveValueVariable = null;
if (((this.bits & ASTNode.IsSynchronized) == 0) && this.expression != null && this.expression.resolvedType == TypeBinding.BOOLEAN) {
- this.expression.bits |= ASTNode.IsReturnedValue;
+ if (noAutoCloseables) { // can't abruptly return in the presence of autocloseables. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=367566
+ this.expression.bits |= ASTNode.IsReturnedValue;
+ }
}
}
currentScope.checkUnclosedCloseables(flowInfo, this, currentScope);
@@ -175,11 +183,11 @@
}
}
if (this.saveValueVariable != null) {
- codeStream.addVariable(this.saveValueVariable);
codeStream.load(this.saveValueVariable);
}
if (this.expression != null && !alreadyGeneratedExpression) {
this.expression.generateCode(currentScope, codeStream, true);
+ // hook necessary for Code Snippet
generateStoreSaveValueIfNecessary(codeStream);
}
// output the suitable return bytecode or wrap the value inside a descriptor for doits
@@ -206,6 +214,8 @@
public void generateStoreSaveValueIfNecessary(CodeStream codeStream){
if (this.saveValueVariable != null) {
codeStream.store(this.saveValueVariable, false);
+ // the variable is visible as soon as the local is stored
+ codeStream.addVariable(this.saveValueVariable);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
index af73870..9fae009 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -913,9 +913,6 @@
if (isStackMapFrameCodeStream) {
((StackMapFrameCodeStream) codeStream).pushStateIndex(stateIndex);
}
- if (secretLocal != null) {
- codeStream.addVariable(secretLocal);
- }
// cannot use jsr bytecode, then simply inline the subroutine
// inside try block, ensure to deactivate all catch block exception handlers while inlining finally block
exitAnyExceptionHandler();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
index f5d41ea..4b32c61 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -494,6 +494,13 @@
return null;
}
+public CompilationUnitDeclaration getCompilationUnitDeclaration() {
+ if (this.scope != null) {
+ return this.scope.compilationUnitScope().referenceContext;
+ }
+ return null;
+}
+
/**
* Generic bytecode generation for type
*/
@@ -1464,4 +1471,5 @@
public boolean isSecondary() {
return (this.bits & ASTNode.IsSecondaryType) != 0;
}
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java
index ec3f72b..6c93b26 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -18,6 +18,7 @@
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
public interface ReferenceContext {
@@ -25,7 +26,10 @@
CompilationResult compilationResult();
+ CompilationUnitDeclaration getCompilationUnitDeclaration();
+
boolean hasErrors();
void tagAsHavingErrors();
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java
index a9da269..c7e6932 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -324,7 +324,9 @@
// class Y { <T> void foo(T t) {} }
// abstract class X extends Y implements I {}
- if (inheritedMethod.declaringClass.isInterface() || inheritedMethod.isStatic()) return;
+ if (inheritedMethod.isStatic()) return;
+ if (this.environment.globalOptions.complianceLevel < ClassFileConstants.JDK1_7 && inheritedMethod.declaringClass.isInterface())
+ return; // JDK7 checks for name clashes in interface inheritance, while JDK6 and below don't. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=354229
detectInheritedNameClash(inheritedMethod.original(), otherInheritedMethod.original());
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
index 6baad99..3765f69 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -15,6 +15,7 @@
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
import org.eclipse.jdt.internal.compiler.IProblemFactory;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.util.Util;
@@ -150,6 +151,13 @@
case ProblemSeverities.Error :
record(problem, unitResult, referenceContext);
if ((severity & ProblemSeverities.Fatal) != 0) {
+ // don't abort or tag as error if the error is suppressed
+ if (!referenceContext.hasErrors() && (severity & ProblemSeverities.Optional) != 0 && this.options.suppressOptionalErrors) {
+ CompilationUnitDeclaration unitDecl = referenceContext.getCompilationUnitDeclaration();
+ if (unitDecl != null && unitDecl.isSuppressed(problem)) {
+ return;
+ }
+ }
referenceContext.tagAsHavingErrors();
// should abort ?
int abortLevel;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
index 2bdc7ce..955e856 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -1413,9 +1413,7 @@
public static boolean CP_RESOLVE_VERBOSE_ADVANCED = false;
public static boolean CP_RESOLVE_VERBOSE_FAILURE = false;
public static boolean ZIP_ACCESS_VERBOSE = false;
- // temporary debug flag to track failures of bug 302850
- public static boolean DEBUG_302850 = false;
-
+
/**
* A cache of opened zip files per thread.
* (for a given thread, the object value is a HashMap from IPath to java.io.ZipFile)
@@ -2155,13 +2153,10 @@
// return cached options if already computed
Hashtable cachedOptions; // use a local variable to avoid race condition (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=256329 )
if ((cachedOptions = this.optionsCache) != null) {
- if (DEBUG_302850) checkTaskTags("Retrieving options from optionsCache", this.optionsCache); //$NON-NLS-1$
return new Hashtable(cachedOptions);
}
- if (DEBUG_302850) System.out.println("optionsCache was null"); //$NON-NLS-1$
if (!Platform.isRunning()) {
this.optionsCache = getDefaultOptionsNoInitialization();
- if (DEBUG_302850) checkTaskTags("Platform is not running", this.optionsCache); //$NON-NLS-1$
return new Hashtable(this.optionsCache);
}
// init
@@ -2177,7 +2172,6 @@
options.put(propertyName, propertyValue);
}
}
- if (DEBUG_302850) checkTaskTags("Options initialized from preferences", options); //$NON-NLS-1$
// set deprecated options using preferences service lookup
Iterator deprecatedEntries = this.deprecatedOptions.entrySet().iterator();
@@ -2203,30 +2197,12 @@
addDeprecatedOptions(options);
Util.fixTaskTags(options);
- if (DEBUG_302850) checkTaskTags("Retrieved options from preferences", options); //$NON-NLS-1$
// store built map in cache
this.optionsCache = new Hashtable(options);
- if (DEBUG_302850) checkTaskTags("Stored optionsCache", this.optionsCache); //$NON-NLS-1$
-
// return built map
return options;
}
- // debugging bug 302850:
- private void checkTaskTags(String msg, Hashtable someOptions) {
- System.out.println(msg);
- Object taskTags = someOptions.get(JavaCore.COMPILER_TASK_TAGS);
- System.out.println(" + Task tags: " + taskTags); //$NON-NLS-1$
- if (taskTags == null || "".equals(taskTags)) { //$NON-NLS-1$
- System.out.println(" - option names: "+this.optionNames); //$NON-NLS-1$
- System.out.println(" - Call stack:"); //$NON-NLS-1$
- StackTraceElement[] elements = new Exception().getStackTrace();
- for (int i=0,n=elements.length; i<n; i++) {
- System.out.println(" + "+elements[i]); //$NON-NLS-1$
- }
- }
- }
-
// Do not modify without modifying getDefaultOptions()
private Hashtable getDefaultOptionsNoInitialization() {
Map defaultOptionsMap = new CompilerOptions().getMap(); // compiler defaults
@@ -4836,57 +4812,46 @@
}
public void setOptions(Hashtable newOptions) {
-
- if (DEBUG_302850) {
- System.out.println("Entering in JavaModelManager.setOptions():"); //$NON-NLS-1$
- System.out.println(new CompilerOptions(newOptions).toString());
- System.out.println(" - Call stack:"); //$NON-NLS-1$
- StackTraceElement[] elements = new Exception().getStackTrace();
- for (int i=0,n=elements.length; i<n; i++) {
- System.out.println(" + "+elements[i]); //$NON-NLS-1$
+ Hashtable cachedValue = newOptions == null ? null : new Hashtable(newOptions);
+ IEclipsePreferences defaultPreferences = getDefaultPreferences();
+ IEclipsePreferences instancePreferences = getInstancePreferences();
+
+ if (newOptions == null){
+ try {
+ instancePreferences.clear();
+ } catch(BackingStoreException e) {
+ // ignore
+ }
+ } else {
+ Enumeration keys = newOptions.keys();
+ while (keys.hasMoreElements()){
+ String key = (String)keys.nextElement();
+ int optionLevel = getOptionLevel(key);
+ if (optionLevel == UNKNOWN_OPTION) continue; // unrecognized option
+ if (key.equals(JavaCore.CORE_ENCODING)) {
+ if (cachedValue != null) {
+ cachedValue.put(key, JavaCore.getEncoding());
+ }
+ continue; // skipped, contributed by resource prefs
+ }
+ String value = (String) newOptions.get(key);
+ String defaultValue = defaultPreferences.get(key, null);
+ // Store value in preferences
+ if (defaultValue != null && defaultValue.equals(value)) {
+ value = null;
+ }
+ storePreference(key, value, instancePreferences, newOptions);
+ }
+ try {
+ // persist options
+ instancePreferences.flush();
+ } catch(BackingStoreException e) {
+ // ignore
}
}
-
- Hashtable cachedValue = newOptions == null ? null : new Hashtable(newOptions);
- IEclipsePreferences defaultPreferences = getDefaultPreferences();
- IEclipsePreferences instancePreferences = getInstancePreferences();
-
- if (newOptions == null){
- try {
- instancePreferences.clear();
- } catch(BackingStoreException e) {
- // ignore
- }
- } else {
- Enumeration keys = newOptions.keys();
- while (keys.hasMoreElements()){
- String key = (String)keys.nextElement();
- int optionLevel = getOptionLevel(key);
- if (optionLevel == UNKNOWN_OPTION) continue; // unrecognized option
- if (key.equals(JavaCore.CORE_ENCODING)) {
- if (cachedValue != null) {
- cachedValue.put(key, JavaCore.getEncoding());
- }
- continue; // skipped, contributed by resource prefs
- }
- String value = (String) newOptions.get(key);
- String defaultValue = defaultPreferences.get(key, null);
- // Store value in preferences
- if (defaultValue != null && defaultValue.equals(value)) {
- value = null;
- }
- storePreference(key, value, instancePreferences, newOptions);
- }
- try {
- // persist options
- instancePreferences.flush();
- } catch(BackingStoreException e) {
- // ignore
- }
- }
- // update cache
- Util.fixTaskTags(cachedValue);
- this.optionsCache = cachedValue;
+ // update cache
+ Util.fixTaskTags(cachedValue);
+ this.optionsCache = cachedValue;
}
public void startup() throws CoreException {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java
index 75f441f..d130e0f 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -53,6 +53,7 @@
/* can only replace a current state if its less than the new one */
// key = indexLocation path, value = index state integer
private SimpleLookupTable indexStates = null;
+ private File indexNamesMapFile = new File(getSavedIndexesDirectory(), "indexNamesMap.txt"); //$NON-NLS-1$
private File savedIndexNamesFile = new File(getSavedIndexesDirectory(), "savedIndexNames.txt"); //$NON-NLS-1$
private File participantIndexNamesFile = new File(getSavedIndexesDirectory(), "participantsIndexNames.txt"); //$NON-NLS-1$
private boolean javaLikeNamesChanged = true;
@@ -394,6 +395,7 @@
this.javaLikeNamesChanged = false;
deleteIndexFiles();
}
+ readIndexMap();
return this.indexStates;
}
private IPath getParticipantsContainer(IndexLocation indexLocation) {
@@ -517,7 +519,7 @@
}
synchronized boolean addIndex(IPath containerPath, IndexLocation indexFile) {
- this.indexStates.put(indexFile, REUSE_STATE);
+ getIndexStates().put(indexFile, REUSE_STATE);
this.indexLocations.put(containerPath, indexFile);
Index index = getIndex(containerPath, indexFile, true, false);
if (index == null) {
@@ -525,6 +527,7 @@
this.indexLocations.put(containerPath, null);
return false;
}
+ writeIndexMapFile();
return true;
}
@@ -906,6 +909,27 @@
return buffer.toString();
}
+private void readIndexMap() {
+ try {
+ char[] indexMaps = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(this.indexNamesMapFile, null);
+ char[][] names = CharOperation.splitOn('\n', indexMaps);
+ if (names.length >= 3) {
+ // First line is DiskIndex signature (see writeIndexMapFile())
+ String savedSignature = DiskIndex.SIGNATURE;
+ if (savedSignature.equals(new String(names[0]))) {
+ for (int i = 1, l = names.length-1 ; i < l ; i+=2) {
+ IndexLocation indexPath = IndexLocation.createIndexLocation(new URL(new String(names[i])));
+ this.indexLocations.put(new Path(new String(names[i+1])), indexPath );
+ this.indexStates.put(indexPath, REUSE_STATE);
+ }
+ }
+ }
+ } catch (IOException ignored) {
+ if (VERBOSE)
+ Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$
+ }
+ return;
+}
private char[][] readIndexState(String dirOSString) {
try {
char[] savedIndexNames = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(this.savedIndexNamesFile, null);
@@ -963,6 +987,7 @@
if (!changed) return;
writeSavedIndexNamesFile();
+ writeIndexMapFile();
}
private synchronized void updateIndexState(IndexLocation indexLocation, Integer indexState) {
if (indexLocation == null)
@@ -1037,6 +1062,39 @@
}
}
}
+private void writeIndexMapFile() {
+ BufferedWriter writer = null;
+ try {
+ writer = new BufferedWriter(new FileWriter(this.indexNamesMapFile));
+ writer.write(DiskIndex.SIGNATURE);
+ writer.write('\n');
+ Object[] keys = this.indexStates.keyTable;
+ Object[] states = this.indexStates.valueTable;
+ for (int i = 0, l = states.length; i < l; i++) {
+ IndexLocation location = (IndexLocation)keys[i];
+ if (location != null && states[i] == REUSE_STATE) {
+ IPath container = (IPath)this.indexLocations.keyForValue(location);
+ if (container != null) {
+ writer.write(location.toString());
+ writer.write('\n');
+ writer.write(container.toOSString());
+ writer.write('\n');
+ }
+ }
+ }
+ } catch (IOException ignored) {
+ if (VERBOSE)
+ Util.verbose("Failed to write saved index file names", System.err); //$NON-NLS-1$
+ } finally {
+ if (writer != null) {
+ try {
+ writer.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+}
private void writeParticipantsIndexNamesFile() {
BufferedWriter writer = null;
try {