Update jdt.core & tests to v20120410-0701 for first primary 4.2 build.
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConcurrentBatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConcurrentBatchCompilerTest.java
new file mode 100644
index 0000000..6e96692
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConcurrentBatchCompilerTest.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Stephan Herrmann - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+public class ConcurrentBatchCompilerTest extends BatchCompilerTest {
+	
+	public static Test suite() {
+		return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_6);
+	}
+	public static Class testClass() {
+		return ConcurrentBatchCompilerTest.class;
+	}
+	public ConcurrentBatchCompilerTest(String name) {
+		super(name);
+	}
+
+	Thread runner1;
+	Thread runner2;
+
+	static int COUNT = 100;
+	
+	/* Invoke the compiler COUNT times to increase bug probabililty. */
+	protected boolean invokeCompiler(PrintWriter out, PrintWriter err, Object extraArguments, TestCompilationProgress compilationProgress) {
+		boolean success = true;
+		for (int j=0; j<COUNT; j++) {
+			success &= super.invokeCompiler(out, err, extraArguments, compilationProgress);
+		}
+		return success;
+	}
+	
+	/* Disambiguate file names for concurrent tests in the same directory. */
+	protected String testName() {
+		Thread current = Thread.currentThread();
+		String baseName = super.testName();
+		if (current == this.runner1)
+			return baseName+"-Thread1";
+		if (current == this.runner2)
+			return baseName+"-Thread2";
+		return baseName;
+	}
+	
+	public void testBug372319() throws Throwable {
+		try {
+			FakedTrackingVariable.TEST_372319 = true;
+	
+			// expected error output for runner2 times COUNT:
+			final StringBuffer errorOutput = new StringBuffer();
+			for (int j=0; j<COUNT; j++)
+				errorOutput.append("----------\n" +
+						"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/test01/X.java (at line 12)\n" +
+						"	FileReader reader = getReader(\"somefile\");\n" +
+						"	           ^^^^^^\n" +
+						"Potential resource leak: \'reader\' may not be closed\n" +
+						"----------\n" +
+						"1 problem (1 error)");
+	
+			// collect exceptions indicating a failure:
+			final Throwable[] thrown = new Throwable[2];
+			
+			this.runner1 = new Thread(new Runnable() {
+					public void run() {
+						try {
+							runConformTest(new String[] {
+								"org/eclipse/jdt/internal/launching/CompositeId.java",
+								"/*******************************************************************************\n" + 
+								" * Copyright (c) 2000, 2012 IBM Corporation and others.\n" + 
+								" * All rights reserved. This program and the accompanying materials\n" + 
+								" * are made available under the terms of the Eclipse Public License v1.0\n" + 
+								" * which accompanies this distribution, and is available at\n" + 
+								" * http://www.eclipse.org/legal/epl-v10.html\n" + 
+								" * \n" + 
+								" * Contributors:\n" + 
+								" *     IBM Corporation - initial API and implementation\n" + 
+								" *******************************************************************************/\n" + 
+								"package org.eclipse.jdt.internal.launching;\n" + 
+								"\n" + 
+								"import java.util.ArrayList;\n" + 
+								"\n" + 
+								"/**\n" + 
+								" * Utility class for id's made of multiple Strings\n" + 
+								" */\n" + 
+								"public class CompositeId {\n" + 
+								"	private String[] fParts;\n" + 
+								"	\n" + 
+								"	public CompositeId(String[] parts) {\n" + 
+								"		fParts= parts;\n" + 
+								"	}\n" + 
+								"	\n" + 
+								"	public static CompositeId fromString(String idString) {\n" + 
+								"		ArrayList<String> parts= new ArrayList<String>();\n" + 
+								"		int commaIndex= idString.indexOf(',');\n" + 
+								"		while (commaIndex > 0) {\n" + 
+								"			int length= Integer.valueOf(idString.substring(0, commaIndex)).intValue();\n" + 
+								"			String part= idString.substring(commaIndex+1, commaIndex+1+length);\n" + 
+								"			parts.add(part);\n" + 
+								"			idString= idString.substring(commaIndex+1+length);\n" + 
+								"			commaIndex= idString.indexOf(',');\n" + 
+								"		}\n" + 
+								"		String[] result= parts.toArray(new String[parts.size()]);\n" + 
+								"		return new CompositeId(result);\n" + 
+								"	}\n" + 
+								"	\n" + 
+								"	@Override\n" + 
+								"	public String toString() {\n" + 
+								"		StringBuffer buf= new StringBuffer();\n" +
+								"		for (int i= 0; i < fParts.length; i++) {\n" + 
+								"			buf.append(fParts[i].length());\n" + 
+								"			buf.append(',');\n" + 
+								"			buf.append(fParts[i]);\n" + 
+								"		}\n" + 
+								"		return buf.toString();\n" + 
+								"	}\n" + 
+								"	\n" + 
+								"	public String get(int index) {\n" + 
+								"		return fParts[index];\n" + 
+								"	}\n" + 
+								"	\n" + 
+								"	public int getPartCount() {\n" + 
+								"		return fParts.length;\n" + 
+								"	}\n" + 
+								"}\n" + 
+								""
+							},
+					        "\"" + OUTPUT_DIR +  File.separator + "org/eclipse/jdt/internal/launching/CompositeId.java\""
+				            + " -1.5 -g -preserveAllLocals"
+				            + " -proceedOnError -d \"" + OUTPUT_DIR + "\"",
+							"",
+							"",
+							false);
+						} catch (Throwable t) {
+							thrown[0] = t;
+						}
+					}
+			});
+			this.runner2 = new Thread(new Runnable() {
+				public void run() {
+					try {
+						// from ResourceLeakTests.test056e():
+						Map options = getCompilerOptions();
+						options.put(CompilerOptions.OPTION_ReportUnclosedCloseable, CompilerOptions.ERROR);
+						options.put(CompilerOptions.OPTION_ReportPotentiallyUnclosedCloseable, CompilerOptions.ERROR);
+						runNegativeTest(
+							new String[] {
+								"test01/X.java",
+								"package test01;\n" +
+								"import java.io.File;\n" +
+								"import java.io.FileReader;\n" +
+								"import java.io.IOException;\n" +
+								"public class X {\n" +
+								"    FileReader getReader(String filename) throws IOException {\n" +
+								"        File file = new File(\"somefile\");\n" +
+								"        FileReader fileReader = new FileReader(file);\n" +
+								"        return fileReader;\n" + 		// don't complain here, pass responsibility to caller
+								"    }\n" +
+								"    void foo() throws IOException {\n" +
+								"        FileReader reader = getReader(\"somefile\");\n" +
+								"        char[] in = new char[50];\n" +
+								"        reader.read(in);\n" +
+								"    }\n" +
+								"    public static void main(String[] args) throws IOException {\n" +
+								"        new X().foo();\n" +
+								"    }\n" +
+								"}\n"
+							},
+					        "\"" + OUTPUT_DIR +  File.separator + "test01/X.java\""
+				            + " -1.5 -g -preserveAllLocals -err:+resource"
+				            + " -proceedOnError -d \"" + OUTPUT_DIR + "\"",
+				            "",
+							errorOutput.toString(),
+							false);
+					} catch (Throwable t) {
+						thrown[1] = t;
+					}
+				}
+			});
+	
+			this.runner2.start();
+			this.runner1.start();
+			this.runner1.join();
+			this.runner2.join();
+			if (thrown[0] != null) throw thrown[0];
+			if (thrown[1] != null) throw thrown[1];
+		} finally {
+			FakedTrackingVariable.TEST_372319 = false;
+		}
+	}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
index f2968e4..ee7d81e 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
@@ -2549,4 +2549,23 @@
 		"Comparable is a raw type. References to generic type Comparable<T> should be parameterized\n" + 
 		"----------\n");
 }
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375394
+public void test375394() {
+	this.runNegativeTest(
+		new String[] {
+			"X.java",
+			"import java.util.Collection;\n" +
+			"public class X {\n" +
+			"    static <C1,C2 extends Collection<Object>> boolean foo(C1 c, C2 c2) {\n" +
+			"        return foo(c2,c); \n" +
+			"    }\n" +
+			"}\n",
+		},
+		"----------\n" + 
+		"1. ERROR in X.java (at line 4)\n" + 
+		"	return foo(c2,c); \n" + 
+		"	       ^^^\n" + 
+		"Bound mismatch: The generic method foo(C1, C2) of type X is not applicable for the arguments (C2, C1). The inferred type C1 is not a valid substitute for the bounded parameter <C2 extends Collection<Object>>\n" + 
+		"----------\n");
+}
 }
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
index fc413fa..49a2b1f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
@@ -101,6 +101,7 @@
 	since_1_5.add(InternalHexFloatTest.class);
 	since_1_5.add(JavadocTest_1_5.class);
 	since_1_5.add(BatchCompilerTest.class);
+	since_1_5.add(ConcurrentBatchCompilerTest.class);
 	since_1_5.add(ExternalizeStringLiterals15Test.class);
 	since_1_5.add(Deprecated15Test.class);
 	since_1_5.add(InnerEmulationTest_1_5.class);
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 48b9ad3..e606150 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
@@ -3626,6 +3626,458 @@
 		"X::~X\n" + 
 		"true");
 }
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248 (AIOOB with try with resources)
+public void test375248() {
+	this.runConformTest(
+		new String[] {
+			"X.java",
+			"import java.io.IOException;\n" +
+			"import java.io.InputStream;\n" +
+			"import java.net.MalformedURLException;\n" +
+			"import java.net.URL;\n" +
+			"\n" +
+			"public class X {\n" +
+			"    public static void main(String[] args) throws Exception {\n" +
+			"      System.out.println(\"Done\");\n" +
+			"    }\n" +
+			"    public void foo() throws MalformedURLException {\n" +
+			"        URL url = new URL(\"dummy\"); //$NON-NLS-1$\n" +
+			"        try (InputStream is = url.openStream()) {\n" +
+			"        } catch (IOException e) {\n" +
+			"             return;\n" +
+			"        } finally {\n" +
+			"            try {\n" +
+			"                java.nio.file.Files.delete(null);\n" +
+			"            } catch (IOException e1) {\n" +
+			"            }\n" +
+			"        }\n" +
+			"    }\n" +
+			"}\n",
+		},
+		"Done");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248 (AIOOB with try with resources)
+public void test375248a() {
+	this.runConformTest(
+		new String[] {
+			"X.java",
+			"import java.io.File;\n" +
+			"import java.io.IOException;\n" +
+			"import java.io.InputStream;\n" +
+			"import java.net.MalformedURLException;\n" +
+			"import java.net.URL;\n" +
+			"import java.nio.file.Path;\n" +
+			"import java.nio.file.StandardCopyOption;\n" +
+			"\n" +
+			"public class X {\n" +
+			"    public static void main(String[] args) throws Exception {\n" +
+			"      System.out.println(\"Done\");\n" +
+			"    }\n" +
+			"    public void executeImports() throws MalformedURLException {\n" +
+			"        for (int i = 0; i < 3; i++) {\n" +
+			"            URL url = new URL(\"dummy\"); //$NON-NLS-1$\n" +
+			"            if (url != null) {\n" +
+			"                Path target = new File(\"dummy\").toPath();\n" +
+			"                try (InputStream is = url.openStream()) {\n" +
+			"                    java.nio.file.Files.copy(is, target,\n" +
+			"                            StandardCopyOption.REPLACE_EXISTING);\n" +
+			"                } catch (IOException e) {\n" +
+			"                     break;\n" +
+			"                } finally {\n" +
+			"                    try {\n" +
+			"                        java.nio.file.Files.delete(target);\n" +
+			"                    } catch (IOException e1) {\n" +
+			"\n" +
+			"                    }\n" +
+			"                }\n" +
+			"            }\n" +
+			"        }\n" +
+			"    }\n" +
+			"}\n",
+		},
+		"Done");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248 (AIOOB with try with resources)
+public void test375248b() {
+	this.runConformTest(
+		new String[] {
+			"X.java",
+			"import java.io.File;\n" +
+			"import java.io.IOException;\n" +
+			"import java.io.InputStream;\n" +
+			"import java.net.MalformedURLException;\n" +
+			"import java.net.URL;\n" +
+			"import java.nio.file.Path;\n" +
+			"import java.nio.file.StandardCopyOption;\n" +
+			"\n" +
+			"public class X {\n" +
+			"    public static void main(String[] args) throws Exception {\n" +
+			"      System.out.println(\"Done\");\n" +
+			"    }\n" +
+			"    public void executeImports() throws MalformedURLException {\n" +
+			"        for (int i = 0; i < 3; i++) {\n" +
+			"            URL url = new URL(\"dummy\"); //$NON-NLS-1$\n" +
+			"            if (url != null) {\n" +
+			"                Path target = new File(\"dummy\").toPath();\n" +
+			"                try (InputStream is = url.openStream()) {\n" +
+			"                    java.nio.file.Files.copy(is, target,\n" +
+			"                            StandardCopyOption.REPLACE_EXISTING);\n" +
+			"                } catch (IOException e) {\n" +
+			"                     continue;\n" +
+			"                } finally {\n" +
+			"                    try {\n" +
+			"                        java.nio.file.Files.delete(target);\n" +
+			"                    } catch (IOException e1) {\n" +
+			"\n" +
+			"                    }\n" +
+			"                }\n" +
+			"            }\n" +
+			"        }\n" +
+			"    }\n" +
+			"}\n",
+		},
+		"Done");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248 (AIOOB with try with resources)
+public void test375248c() {
+	this.runConformTest(
+		new String[] {
+			"X.java",
+			"import java.io.File;\n" +
+			"import java.io.IOException;\n" +
+			"import java.io.InputStream;\n" +
+			"import java.net.MalformedURLException;\n" +
+			"import java.net.URL;\n" +
+			"import java.nio.file.Path;\n" +
+			"import java.nio.file.StandardCopyOption;\n" +
+			"\n" +
+			"public class X implements AutoCloseable {\n" +
+			"	public void foo()  {\n" +
+			"        try (X x = new X()) {\n" +
+			"	     System.out.println(\"Try\");\n" +
+			"	     throw new Exception();\n" +
+			"        } catch (Exception e) {\n" +
+			"	     System.out.println(\"Catch\");\n"+ 
+			"             return;\n" +
+			"        } finally {\n" +
+			"        	System.out.println(\"Finally\");\n" +
+			"        }\n" +
+			"    }\n" +
+			"	public void close() {\n" +
+			"		System.out.println(\"Close\");\n" +
+			"	}\n" +
+			"	public static void main(String[] args) {\n" +
+			"		new X().foo();\n" +
+			"	}\n" +
+			"}\n" 
+		},
+		"Try\n" + 
+		"Close\n" + 
+		"Catch\n" + 
+		"Finally");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248 (AIOOB with try with resources)
+public void test375248d() {
+	this.runConformTest(
+		new String[] {
+			"X.java",
+			"import java.io.File;\n" +
+			"import java.io.IOException;\n" +
+			"import java.io.InputStream;\n" +
+			"import java.net.MalformedURLException;\n" +
+			"import java.net.URL;\n" +
+			"import java.nio.file.Path;\n" +
+			"import java.nio.file.StandardCopyOption;\n" +
+			"\n" +
+			"public class X implements AutoCloseable {\n" +
+			"	public void foo()  {\n" +
+			"        try (X x = new X()) {\n" +
+			"	     System.out.println(\"Try\");\n" +
+			"        } catch (Exception e) {\n" +
+			"	     System.out.println(\"Catch\");\n"+ 
+			"             return;\n" +
+			"        } finally {\n" +
+			"        	System.out.println(\"Finally\");\n" +
+			"           return;\n" +
+			"        }\n" +
+			"    }\n" +
+			"	public void close() {\n" +
+			"		System.out.println(\"Close\");\n" +
+			"	}\n" +
+			"	public static void main(String[] args) {\n" +
+			"		new X().foo();\n" +
+			"	}\n" +
+			"}\n" 
+		},
+		"Try\n" + 
+		"Close\n" + 
+		"Finally");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375326
+public void test375326() {
+	this.runConformTest(
+		new String[] {
+			"X.java",
+			"public class X {\n" + 
+			"	public static void main(String[] args) throws Exception {\n" + 
+			"		HasAutoCloseable a;\n" + 
+			"		try(AutoCloseable b=(a=new HasAutoCloseable()).a) {\n" + 
+			"		}\n" + 
+			"		System.out.println(a);\n" + 
+			"	}\n" +
+			"	public static class AutoCloseableA implements AutoCloseable {\n" + 
+			"		@Override\n" + 
+			"		public void close() {\n" + 
+			"			// TODO Auto-generated method stub\n" + 
+			"		}\n" + 
+			"	}\n" + 
+			"	public static class HasAutoCloseable {\n" + 
+			"		AutoCloseable a = new AutoCloseableA();\n" + 
+			"		public String toString() {\n" + 
+			"			return \"SUCCESS\";\n" + 
+			"		}\n" + 
+			"	}\n" + 
+			"}" 
+		},
+		"SUCCESS");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375326
+public void test375326a() {
+	this.runNegativeTest(
+		new String[] {
+			"X.java",
+			"public class X {\n" +
+			"    public static void main(String [] args) throws Exception {\n" +
+			"        HasAutoCloseable aLocal;\n" +
+			"        try(AutoCloseable b=(new HasAutoCloseable()).a){\n" +
+			"        	aLocal = new HasAutoCloseable();\n" +
+			"        }\n" +
+			"        catch (Throwable e) {\n" +
+			"        }\n" +
+			"       System.out.println(aLocal.toString());       \n" +
+			"    } \n" +
+			"    public static class AutoCloseableA implements AutoCloseable{\n" +
+			"        @Override\n" +
+			"        public void close() {\n" +
+			"        }\n" +
+			"    }\n" +
+			"    public static class HasAutoCloseable{\n" +
+			"        AutoCloseable a=new AutoCloseableA(); \n" +
+			"    }\n" +
+			"}\n"
+		},
+		"----------\n" + 
+		"1. ERROR in X.java (at line 9)\n" + 
+		"	System.out.println(aLocal.toString());       \n" + 
+		"	                   ^^^^^^\n" + 
+		"The local variable aLocal may not have been initialized\n" + 
+		"----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375326
+public void test375326b() {
+	this.runNegativeTest(
+		new String[] {
+			"X.java",
+			"public class X {\n" +
+			"    public static void main(String [] args) throws Exception {\n" +
+			"        HasAutoCloseable aLocal;\n" +
+			"        try(AutoCloseable b=(aLocal = new HasAutoCloseable()).a){\n" +
+			"        	\n" +
+			"        }\n" +
+			"        catch (Throwable e) {\n" +
+			"        }\n" +
+			"       System.out.println(aLocal.toString());       \n" +
+			"    } \n" +
+			"    public static class AutoCloseableA implements AutoCloseable{\n" +
+			"        @Override\n" +
+			"        public void close() {\n" +
+			"        }\n" +
+			"    }\n" +
+			"    public static class HasAutoCloseable{\n" +
+			"        AutoCloseable a=new AutoCloseableA(); \n" +
+			"    }\n" +
+			"}\n"
+		},
+		"----------\n" + 
+		"1. ERROR in X.java (at line 9)\n" + 
+		"	System.out.println(aLocal.toString());       \n" + 
+		"	                   ^^^^^^\n" + 
+		"The local variable aLocal may not have been initialized\n" + 
+		"----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375326
+public void test375326c() {
+	this.runConformTest(
+		new String[] {
+			"X.java",
+			"public class X {\n" + 
+			"	public static void main(String[] args) throws Exception {\n" + 
+			"		HasAutoCloseable a;\n" + 
+			"		try(AutoCloseable b=(a=new HasAutoCloseable()).a) {\n" + 
+			"       } finally {\n" +
+			"            System.out.println(\"Finally\");\n" +
+			"        }\n" +
+			"		System.out.println(a);\n" + 
+			"	}\n" +
+			"	public static class AutoCloseableA implements AutoCloseable {\n" + 
+			"		@Override\n" + 
+			"		public void close() {\n" + 
+			"			// TODO Auto-generated method stub\n" + 
+			"		}\n" + 
+			"	}\n" + 
+			"	public static class HasAutoCloseable {\n" + 
+			"		AutoCloseable a = new AutoCloseableA();\n" + 
+			"		public String toString() {\n" + 
+			"			return \"SUCCESS\";\n" + 
+			"		}\n" + 
+			"	}\n" + 
+			"}" 
+		},
+		"Finally\n" + 
+		"SUCCESS");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375326
+public void test375326d() {
+	this.runNegativeTest(
+		new String[] {
+			"X.java",
+			"public class X {\n" +
+			"    public static void main(String [] args) throws Exception {\n" +
+			"        HasAutoCloseable aLocal;\n" +
+			"        try(AutoCloseable b=(new HasAutoCloseable()).a){\n" +
+			"        	aLocal = new HasAutoCloseable();\n" +
+			"        }\n" +
+			"        catch (Throwable e) {\n" +
+			"        } finally {\n" +
+			"            System.out.println(\"Finally\");\n" +
+			"        }\n" +
+			"       System.out.println(aLocal.toString());       \n" +
+			"    } \n" +
+			"    public static class AutoCloseableA implements AutoCloseable{\n" +
+			"        @Override\n" +
+			"        public void close() {\n" +
+			"        }\n" +
+			"    }\n" +
+			"    public static class HasAutoCloseable{\n" +
+			"        AutoCloseable a=new AutoCloseableA(); \n" +
+			"    }\n" +
+			"}\n"
+		},
+		"----------\n" + 
+		"1. ERROR in X.java (at line 11)\n" + 
+		"	System.out.println(aLocal.toString());       \n" + 
+		"	                   ^^^^^^\n" + 
+		"The local variable aLocal may not have been initialized\n" + 
+		"----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375326
+public void test375326e() {
+	this.runNegativeTest(
+		new String[] {
+			"X.java",
+			"public class X {\n" +
+			"    public static void main(String [] args) throws Exception {\n" +
+			"        HasAutoCloseable aLocal;\n" +
+			"        try(AutoCloseable b=(aLocal = new HasAutoCloseable()).a){\n" +
+			"        	\n" +
+			"        }\n" +
+			"        catch (Throwable e) {\n" +
+			"        } finally {\n" +
+			"            System.out.println(\"Finally\");\n" +
+			"        }\n" +
+			"       System.out.println(aLocal.toString());       \n" +
+			"    } \n" +
+			"    public static class AutoCloseableA implements AutoCloseable{\n" +
+			"        @Override\n" +
+			"        public void close() {\n" +
+			"        }\n" +
+			"    }\n" +
+			"    public static class HasAutoCloseable{\n" +
+			"        AutoCloseable a=new AutoCloseableA(); \n" +
+			"    }\n" +
+			"}\n"
+		},
+		"----------\n" + 
+		"1. ERROR in X.java (at line 11)\n" + 
+		"	System.out.println(aLocal.toString());       \n" + 
+		"	                   ^^^^^^\n" + 
+		"The local variable aLocal may not have been initialized\n" + 
+		"----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375326
+public void test375326f() {
+	this.runNegativeTest(
+		new String[] {
+			"X.java",
+			"public class X {\n" +
+			"    public void testWithResourcesAssignment() throws Exception{\n" +
+			"        HasAutoCloseable a;\n" +
+			"        try(AutoCloseable b=(a=new HasAutoCloseable()).a){\n" +
+			"        } finally {\n" +
+			"        	System.out.println(a);\n" +
+			"        }\n" +
+			"    }\n" +
+			"    public class AutoCloseableA implements AutoCloseable{\n" +
+			"        @Override\n" +
+			"        public void close() {\n" +
+			"        }\n" +
+			"    }\n" +
+			"    public class HasAutoCloseable{\n" +
+			"        AutoCloseable a=new AutoCloseableA();\n" +
+			"    }\n" +
+			"}\n"
+		},
+		"----------\n" + 
+		"1. ERROR in X.java (at line 6)\n" + 
+		"	System.out.println(a);\n" + 
+		"	                   ^\n" + 
+		"The local variable a may not have been initialized\n" + 
+		"----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375326
+public void test375326g() {
+	this.runNegativeTest(
+		new String[] {
+			"X.java",
+			"class CheckedException extends Throwable {}\n" +
+			"public class X {\n" +
+			"    public void testWithResourcesAssignment() throws Exception{\n" +
+			"        HasAutoCloseable a;\n" +
+			"        try(AutoCloseable b=(a=new HasAutoCloseable()).a){\n" +
+			"            throw new CheckedException();\n" +
+			"        } catch (CheckedException e) {\n" +
+			"            System.out.println(a);\n" +
+			"        } finally {\n" +
+			"        	System.out.println(a);\n" +
+			"        }\n" +
+			"    }\n" +
+			"    public class AutoCloseableA implements AutoCloseable{\n" +
+			"        @Override\n" +
+			"        public void close() {\n" +
+			"        }\n" +
+			"    }\n" +
+			"    public class HasAutoCloseable{\n" +
+			"        AutoCloseable a=new AutoCloseableA();\n" +
+			"    }\n" +
+			"}\n"
+		},
+		"----------\n" + 
+		"1. WARNING in X.java (at line 1)\n" + 
+		"	class CheckedException extends Throwable {}\n" + 
+		"	      ^^^^^^^^^^^^^^^^\n" + 
+		"The serializable class CheckedException does not declare a static final serialVersionUID field of type long\n" + 
+		"----------\n" + 
+		"2. ERROR in X.java (at line 8)\n" + 
+		"	System.out.println(a);\n" + 
+		"	                   ^\n" + 
+		"The local variable a may not have been initialized\n" + 
+		"----------\n" + 
+		"3. ERROR in X.java (at line 10)\n" + 
+		"	System.out.println(a);\n" + 
+		"	                   ^\n" + 
+		"The local variable a may not have been initialized\n" + 
+		"----------\n");
+}
 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 37eddcd..8a6a0c8 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
@@ -2749,7 +2749,6 @@
 	}
 	public void setUpSuite() throws Exception {
 		super.setUpSuite();
-
 		// ensure autobuilding is turned off
 		IWorkspaceDescription description = getWorkspace().getDescription();
 		if (description.isAutoBuilding()) {
@@ -2759,7 +2758,7 @@
 	}
 	protected void setUp () throws Exception {
 		super.setUp();
-
+		System.setProperty("jdt.bug.367669", "non-null");
 		if (NameLookup.VERBOSE || BasicSearchEngine.VERBOSE || JavaModelManager.VERBOSE) {
 			System.out.println("--------------------------------------------------------------------------------");
 			System.out.println("Running test "+getName()+"...");
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java
index 26a62e1..33a03e5 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java
@@ -10,7 +10,6 @@
  *******************************************************************************/
 package org.eclipse.jdt.core.tests.model;
 
-import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -51,7 +50,6 @@
 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
 import org.eclipse.jdt.internal.core.ExternalFoldersManager;
 import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
-import org.eclipse.jdt.internal.core.JavaModelManager;
 import org.eclipse.jdt.internal.core.JavaProject;
 import org.eclipse.jdt.internal.core.util.Util;
 
@@ -507,33 +505,7 @@
 
 		String externalLib = externalFolder + "/lib";
 		IJavaProject javaProject = null;
-		try {
-			javaProject = createJavaProject("P", new String[0], new String[] {externalLib}, "");
-		}
-		catch (Exception e) {
-			IFolder folder = getFolder(externalLib);
-			System.out.println("----------  This information is logged for debugging purposes as this test fails sporadically.---------");
-			System.out.println("Failing when creating Link folder for: " + externalFolder);
-			System.out.println("Existing? " + folder.exists());
-			IProject externalFolderProject = JavaModelManager.getExternalManager().getExternalFoldersProject();
-			IFile externalProjectFile = externalFolderProject.getFile(".project");
-			if (externalProjectFile.exists()) {
-				System.out.println("External Folder Project exists with following content:");
-				BufferedInputStream bs = new BufferedInputStream(externalProjectFile.getContents());
-				int available = 0;
-				while ((available = bs.available()) > 0) {
-					byte[] contents = new byte[available];
-					bs.read(contents);
-					System.out.println(new String(contents));
-				}
-				bs.close();
-			}
-			else {
-				System.out.println("External folders project doesn't exist.");
-			}
-			System.out.println("----------  Debug information ends ---------");
-			throw e;
-		}
+		javaProject = createJavaProject("P", new String[0], new String[] {externalLib}, "");
 		IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(externalLib);
 		attachSource(root, externalFolder + "/src228639", "");
 		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassFileTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassFileTests.java
index feec85f..f6aa5ef 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassFileTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassFileTests.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
@@ -39,7 +39,7 @@
 // All specified tests which do not belong to the class are skipped...
 static {
 //	TESTS_PREFIX = "testGetCategories";
-//	TESTS_NAMES = new String[] { "testAnnotations19"};
+//	TESTS_NAMES = new String[] { "testBug372687"};
 //	TESTS_NUMBERS = new int[] { 13 };
 //	TESTS_RANGE = new int[] { 16, -1 };
 }
@@ -1638,5 +1638,46 @@
 			removeLibrary(getJavaProject("P"), "lib316937.jar", "src316937.zip");
 		}
 	}
-	
+	/*
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=372687
+	 * Ensures that if more than one thread try to open a class file at the same time, the children are correct.
+	 */
+	public void testBug372687() throws CoreException {
+		String expected = "X.class\n" + 
+						  "  class X\n" + 
+						  "    X()\n" + 
+						  "    void foo()";
+		class GetClassThread extends Thread {
+			public String childString;
+			public void run(){
+				IClassFile clazz = ClassFileTests.this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class");
+				try {
+					this.childString = expandAll(clazz);
+				} catch (CoreException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		for (int i = 0; i < 10; i++) {
+			GetClassThread th1 = new GetClassThread();
+			GetClassThread th2 = new GetClassThread();
+			GetClassThread th3 = new GetClassThread();
+			th1.start();
+			th2.start();
+			th3.start();
+			try {
+				th1.join();
+				th2.join();
+				th3.join();
+			} catch (InterruptedException e) {
+				// ignore
+			}
+			assertEquals("Unexpected children", expected, th1.childString);
+			assertEquals("Unexpected children", expected, th2.childString);
+			assertEquals("Unexpected children", expected, th3.childString);
+			IClassFile clazz = ClassFileTests.this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class");
+			clazz.close();
+		}
+	}
+
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
index a4da2e3..b5e07e9 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
@@ -27,6 +27,9 @@
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
 import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTParser;
 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
 import org.eclipse.jdt.internal.core.JavaModelManager;
 import org.eclipse.jdt.internal.core.PackageFragmentRoot;
@@ -37,7 +40,7 @@
 	super(name);
 }
 static {
-//	TESTS_NAMES = new String[] { "testBug360164" };
+//	TESTS_NAMES = new String[] { "testBug351697" };
 }
 public static Test suite() {
 	TestSuite suite = (TestSuite) buildModelTestSuite(JavaProjectTests.class);
@@ -2530,4 +2533,54 @@
 		this.deleteProject("P");
 	}
 }
+/**
+ * @bug 351697: java.lang.ClassCastException
+ * @test Verify that ClassCastException is not thrown when a .class file is copied to a wrong source package.
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=351697"
+ */
+public void testBug351697() throws Exception {
+	try {
+		IJavaProject proj = this.createJavaProject("P", new String[] {"src"}, "bin");
+		proj.getProject().open(null);
+		createFolder("/P/src/p");
+		createFolder("/P/src/q");
+		createFolder("/P/temp_folder");
+
+		IFile toEdit = createFile("/P/src/p/P.java",
+				"package p;" +
+				"public class P {" +
+				"	Q b = new Q();" +
+				"	public void foo() {" +
+				"	}");
+
+		IFile toDelete = createFile("/P/src/q/Q.java",
+				"package q;" +
+				"public class Q {" +
+				"}");
+		proj.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+
+		moveFile("/P/bin/q/Q.class", "/P/temp_folder/Q.class");
+		deleteResource(toDelete);
+		proj.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+
+		ICompilationUnit unit = (ICompilationUnit)JavaCore.create(toEdit);
+		unit.open(null);
+		moveFile( "/P/temp_folder/Q.class", "/P/src/p/Q.class/");
+		proj.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+
+		try {
+			ASTParser parser= ASTParser.newParser(AST.JLS4);
+			parser.setSource(unit);
+			parser.setResolveBindings(true);
+			ASTNode node = parser.createAST(null);
+			assertNotNull("ASTNode should not be null", node);
+		}
+		catch(ClassCastException cce) {
+			fail("ClassCastException:" + cce.getMessage());
+		}
+
+	} finally {
+		this.deleteProject("P");
+	}
+}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java
index 6625053..942f889 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.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
@@ -702,6 +702,36 @@
 	}
 }
 /**
+ * @throws IOException 
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=375568"
+ */
+public void testParamAnnotations9() throws CoreException, IOException {
+	try {
+		IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
+		String[] pathAndContents = new String[]{"p/X.java",
+				"package p;\n" +
+				"public class X {\n" +
+				"	X field;\n" +
+				"	@Deprecated\n" +
+				"	public void Test(@Default String processor) {}\n" +
+				"}" +
+				"@interface Default{\n" +
+				"}"};
+		addLibrary(project, "lib334783.jar", "libsrc.zip", pathAndContents, JavaCore.VERSION_1_5);
+		
+		waitForAutoBuild();
+		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783.jar"));
+		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
+		String annotationString = "@p.Default [in processor [in Test(java.lang.String) [in X [in X.class [in p [in lib334783.jar [in P]]]]]]]";
+		
+		IMethod method = type.getMethods()[1];
+		assertEquals(1, method.getParameters()[0].getAnnotations().length);
+		assertEquals(annotationString, method.getParameters()[0].getAnnotations()[0].toString());
+	} finally {
+		deleteProject("P");
+	}
+}
+/**
  * @bug 342393: Anonymous class' occurrence count is incorrect when two methods in a class have the same name.
  *
  * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=342393"
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 40c166d..e9e9e16 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
@@ -20,7 +20,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.C40, 3.8.0 M6
+compiler.version = 0.C44, 3.8.0 M7
 compiler.copyright = Copyright IBM Corp 2000, 2011. All rights reserved.
 
 ###{ObjectTeams:
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index f7894b8..cfdcfd5 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -42,6 +42,64 @@
 	</td>
   </tr>
 </table>
+<a name="v_C44"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.8.0 - April 10, 2012 - 3.8.0 M7
+<br>Project org.eclipse.jdt.core v_C44
+(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_C44">cvs</a>).
+<h2>What's new in this drop</h2>
+
+<h3>Problem Reports Fixed</h3>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=351697">351697</a>
+ClassCastException while copying a .class file to wrong source package
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=375394">375394</a>
+Incorrect type checking for parameterized types
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=375326">375326</a>
+try-with-resources assignment in statement produces stack map exception
+
+<a name="v_C43"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.8.0 - April 3, 2012
+<br>Project org.eclipse.jdt.core v_C43
+(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_C43">cvs</a>).
+<h2>What's new in this drop</h2>
+
+<h3>Problem Reports Fixed</h3>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=375568">375568</a>
+@PolymorphicSignature methods in MethodHandle have wrong annotation on parameter
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=372687">372687</a>
+org.eclipse.jdt.core.LRUCache.get(Object key) returns an empty list from a class that has methods
+
+<a name="v_C42"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.8.0 - March 27, 2012
+<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=374538">374538</a>
+[local] localFile service tries to set modified time on virtual files
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248">375248</a>
+AIOOBE inside twr with finally block
+
+<a name="v_C41"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.8.0 - March 20, 2012
+<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=372319">372319</a>
+Unexpected 'The local variable i may not have been initialized' compile error
+
 <a name="v_C40"></a>
 <hr><h1>
 Eclipse Platform Build Notes<br>
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
index f84c472..3f228e6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
@@ -123,7 +123,7 @@
 	}
 
 	// after having analysed exceptions above start tracking newly allocated resource:
-	if (FakedTrackingVariable.isAnyCloseable(this.resolvedType) && currentScope.compilerOptions().analyseResourceLeaks)
+	if (currentScope.compilerOptions().analyseResourceLeaks && FakedTrackingVariable.isAnyCloseable(this.resolvedType))
 		FakedTrackingVariable.analyseCloseableAllocation(currentScope, flowInfo, this);
 
 	if (this.binding.declaringClass.isMemberType() && !this.binding.declaringClass.isStatic()) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java
index 4ac6c2f..102fd01 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java
@@ -60,6 +60,8 @@
 	private static final int REPORTED_POTENTIAL_LEAK = 32;
 	// a location independent definitive problem has been reported against this resource:
 	private static final int REPORTED_DEFINITIVE_LEAK = 64;
+	
+	public static boolean TEST_372319 = false; // see https://bugs.eclipse.org/372319
 
 	/**
 	 * Bitset of {@link #CLOSE_SEEN}, {@link #SHARED_WITH_OUTSIDE}, {@link #OWNED_BY_OUTSIDE}, {@link #CLOSED_IN_NESTED_METHOD}, {@link #REPORTED_EXPLICIT_CLOSE}, {@link #REPORTED_POTENTIAL_LEAK} and {@link #REPORTED_DEFINITIVE_LEAK}.
@@ -528,6 +530,9 @@
 	 * @return one of the constants FlowInfo.{NULL,POTENTIALLY_NULL,POTENTIALLY_NON_NULL,NON_NULL}.
 	 */
 	private int getNullStatusAggressively(LocalVariableBinding local, FlowInfo flowInfo) {
+		if (flowInfo == FlowInfo.DEAD_END) {
+			return FlowInfo.UNKNOWN;
+		}
 		int reachMode = flowInfo.reachMode();
 		int status = 0;
 		try {
@@ -535,6 +540,11 @@
 			if (reachMode != FlowInfo.REACHABLE)
 				flowInfo.tagBits &= ~FlowInfo.UNREACHABLE;
 			status = flowInfo.nullStatus(local);
+			if (TEST_372319) { // see https://bugs.eclipse.org/372319
+				try {
+					Thread.sleep(5); // increase probability of concurrency bug
+				} catch (InterruptedException e) { /* nop */ }
+			}
 		} finally {
 			// reset
 			flowInfo.tagBits |= reachMode;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
index e7c6d71..a50378e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
@@ -124,8 +124,8 @@
 	FlowInfo preInitInfo = null;
 	boolean shouldAnalyseResource = this.binding != null 
 			&& flowInfo.reachMode() == FlowInfo.REACHABLE
-			&& FakedTrackingVariable.isAnyCloseable(this.initialization.resolvedType)
-			&& currentScope.compilerOptions().analyseResourceLeaks;
+			&& currentScope.compilerOptions().analyseResourceLeaks
+			&& FakedTrackingVariable.isAnyCloseable(this.initialization.resolvedType);
 	if (shouldAnalyseResource) {
 		preInitInfo = flowInfo.unconditionalCopy();
 		// analysis of resource leaks needs additional context while analyzing the RHS:
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
index 7fa5367..72abdea 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
@@ -185,7 +185,7 @@
 		}
 
 		// after having analysed exceptions above start tracking newly allocated resource:
-		if (FakedTrackingVariable.isAnyCloseable(this.resolvedType) && currentScope.compilerOptions().analyseResourceLeaks) {
+		if (currentScope.compilerOptions().analyseResourceLeaks && FakedTrackingVariable.isAnyCloseable(this.resolvedType)) {
 			FakedTrackingVariable.analyseCloseableAllocation(currentScope, flowInfo, this);
 		}
 
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 5e108a0..8abdf5b 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
@@ -141,9 +141,10 @@
 		// only try blocks initialize that member - may consider creating a
 		// separate class if needed
 
+		FlowInfo tryInfo = flowInfo.copy();
 		for (int i = 0; i < resourcesLength; i++) {
-			flowInfo = this.resources[i].analyseCode(currentScope, handlingContext, flowInfo.copy());
-			this.postResourcesInitStateIndexes[i] = currentScope.methodScope().recordInitializationStates(flowInfo);
+			tryInfo = this.resources[i].analyseCode(currentScope, handlingContext, tryInfo);
+			this.postResourcesInitStateIndexes[i] = currentScope.methodScope().recordInitializationStates(tryInfo);
 			LocalVariableBinding resourceBinding = this.resources[i].binding;
 			resourceBinding.useFlag = LocalVariableBinding.USED; // Is implicitly used anyways.
 			if (resourceBinding.closeTracker != null) {
@@ -158,16 +159,13 @@
 				if (closeMethod != null && closeMethod.returnType.id == TypeIds.T_void) {
 					ReferenceBinding[] thrownExceptions = closeMethod.thrownExceptions;
 					for (int j = 0, length = thrownExceptions.length; j < length; j++) {
-						handlingContext.checkExceptionHandlers(thrownExceptions[j], this.resources[i], flowInfo, currentScope, true);
+						handlingContext.checkExceptionHandlers(thrownExceptions[j], this.resources[i], tryInfo, currentScope, true);
 					}
 				}
 			}
 		}
-		FlowInfo tryInfo;
-		if (this.tryBlock.isEmptyBlock()) {
-			tryInfo = flowInfo;
-		} else {
-			tryInfo = this.tryBlock.analyseCode(currentScope, handlingContext, flowInfo.copy());
+		if (!this.tryBlock.isEmptyBlock()) {
+			tryInfo = this.tryBlock.analyseCode(currentScope, handlingContext, tryInfo);
 			if ((tryInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0)
 				this.bits |= ASTNode.IsTryBlockExiting;
 		}
@@ -283,9 +281,10 @@
 		// only try blocks initialize that member - may consider creating a
 		// separate class if needed
 
+		FlowInfo tryInfo = flowInfo.copy();
 		for (int i = 0; i < resourcesLength; i++) {
-			flowInfo = this.resources[i].analyseCode(currentScope, handlingContext, flowInfo.copy());
-			this.postResourcesInitStateIndexes[i] = currentScope.methodScope().recordInitializationStates(flowInfo);
+			tryInfo = this.resources[i].analyseCode(currentScope, handlingContext, tryInfo);
+			this.postResourcesInitStateIndexes[i] = currentScope.methodScope().recordInitializationStates(tryInfo);
 			LocalVariableBinding resourceBinding = this.resources[i].binding;
 			resourceBinding.useFlag = LocalVariableBinding.USED; // Is implicitly used anyways.
 			if (resourceBinding.closeTracker != null) {
@@ -300,16 +299,13 @@
 				if (closeMethod != null && closeMethod.returnType.id == TypeIds.T_void) {
 					ReferenceBinding[] thrownExceptions = closeMethod.thrownExceptions;
 					for (int j = 0, length = thrownExceptions.length; j < length; j++) {
-						handlingContext.checkExceptionHandlers(thrownExceptions[j], this.resources[i], flowInfo, currentScope, true);
+						handlingContext.checkExceptionHandlers(thrownExceptions[j], this.resources[i], tryInfo, currentScope, true);
 					}
 				}
 			}
 		}
-		FlowInfo tryInfo;
-		if (this.tryBlock.isEmptyBlock()) {
-			tryInfo = flowInfo;
-		} else {
-			tryInfo = this.tryBlock.analyseCode(currentScope, handlingContext, flowInfo.copy());
+		if (!this.tryBlock.isEmptyBlock()) {
+			tryInfo = this.tryBlock.analyseCode(currentScope, handlingContext, tryInfo);
 			if ((tryInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0)
 				this.bits |= ASTNode.IsTryBlockExiting;
 		}
@@ -566,6 +562,10 @@
 					// i is off by one
 					codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.postResourcesInitStateIndexes[i - 1]);
 					codeStream.addDefinitelyAssignedVariables(currentScope, this.postResourcesInitStateIndexes[i - 1]);
+				} else {
+					// For the first resource, its preset state is the preTryInitStateIndex
+					codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.preTryInitStateIndex);
+					codeStream.addDefinitelyAssignedVariables(currentScope, this.preTryInitStateIndex);
 				}
 
 				codeStream.pushExceptionOnStack(this.scope.getJavaLangThrowable());
@@ -612,6 +612,7 @@
 		}
 	} finally {
 		this.declaredExceptionLabels = null;
+		this.resourceExceptionLabels = null;  // https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248
 	}
 	boolean tryBlockHasSomeCode = codeStream.position != pc;
 	// flag telling if some bytecodes were issued inside the try block
@@ -861,7 +862,7 @@
 public boolean generateSubRoutineInvocation(BlockScope currentScope, CodeStream codeStream, Object targetLocation, int stateIndex, LocalVariableBinding secretLocal) {
 
 	int resourceCount = this.resources.length;
-	if (resourceCount > 0) {
+	if (resourceCount > 0 && this.resourceExceptionLabels != null) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248
 		for (int i = resourceCount; i > 0; --i) {
 			// Disarm the handlers and take care of resource closure.
 			this.resourceExceptionLabels[i].placeEnd();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java
index c07f07a..4b79be2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.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
@@ -113,7 +113,18 @@
 		for (int i = 0, length = typeVariables.length; i < length; i++) {
 		    TypeVariableBinding typeVariable = typeVariables[i];
 		    TypeBinding substitute = methodSubstitute.typeArguments[i]; // retain for diagnostics
-		    TypeBinding substituteForChecks = Scope.substitute(new LingeringTypeVariableEliminator(typeVariables, null, scope), substitute); // while using this for bounds check
+		    /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=375394, To avoid spurious bounds check failures due to circularity in formal bounds, 
+		       we should eliminate only the lingering embedded type variable references after substitution, not alien type variable references
+		       that constitute the inference per se. Also short circuit this step, if the substitution has no type variables in the first place 
+		       (as it is effectively a nop.)
+		     */ 
+		    TypeBinding substituteForChecks;
+		    if (substitute instanceof TypeVariableBinding || ((substitute.tagBits & TagBits.HasTypeVariable) == 0)) {
+		    	substituteForChecks = substitute;
+		    } else {
+		    	substituteForChecks = Scope.substitute(new LingeringTypeVariableEliminator(typeVariables, null, scope), substitute); // while using this for bounds check
+		    }
+		    
 		    if (uncheckedArguments != null && uncheckedArguments[i] == null) continue; // only bound check if inferred through 15.12.2.6
 //{ObjectTeams: methods with generic declared lifting need to be checked in knowledge of the actual receiver type:
 		    ReferenceBinding actualReceiverRefType = null;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BecomeWorkingCopyOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BecomeWorkingCopyOperation.java
index a132158..7f5be9a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BecomeWorkingCopyOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BecomeWorkingCopyOperation.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
@@ -35,7 +35,7 @@
 		// open the working copy now to ensure contents are that of the current state of this element
 		CompilationUnit workingCopy = getWorkingCopy();
 		JavaModelManager.getJavaModelManager().getPerWorkingCopyInfo(workingCopy, true/*create if needed*/, true/*record usage*/, this.problemRequestor);
-		workingCopy.openWhenClosed(workingCopy.createElementInfo(), this.progressMonitor);
+		workingCopy.openWhenClosed(workingCopy.createElementInfo(), true, this.progressMonitor);
 
 		if (!workingCopy.isPrimary()) {
 			// report added java delta for a non-primary working copy
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java
index c8a1fa8..1d1fd29 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.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
@@ -97,22 +97,18 @@
 				-1,
 				true);
 		localVariables[i] = localVariable;
-		IAnnotation[] annotations = getAnnotations(localVariable, info.getParameterAnnotations(i), info.getTagBits());
+		IAnnotation[] annotations = getAnnotations(localVariable, info.getParameterAnnotations(i));
 		localVariable.annotations = annotations;
 	}
 	return localVariables;
 }
-private IAnnotation[] getAnnotations(JavaElement annotationParent, IBinaryAnnotation[] binaryAnnotations, long tagBits) {
-	IAnnotation[] standardAnnotations = getStandardAnnotations(tagBits);
-	if (binaryAnnotations == null)
-		return standardAnnotations;
+private IAnnotation[] getAnnotations(JavaElement annotationParent, IBinaryAnnotation[] binaryAnnotations) {
+	if (binaryAnnotations == null) return Annotation.NO_ANNOTATIONS;
 	int length = binaryAnnotations.length;
-	int standardLength = standardAnnotations.length;
-	IAnnotation[] annotations = new IAnnotation[length + standardLength];
+	IAnnotation[] annotations = new IAnnotation[length];
 	for (int i = 0; i < length; i++) {
 		annotations[i] = Util.getAnnotation(annotationParent, binaryAnnotations[i], null);
 	}
-	System.arraycopy(standardAnnotations, 0, annotations, length, standardLength);
 	return annotations;
 }
 public IMemberValuePair getDefaultValue() throws JavaModelException {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
index 1ec4f83..8e00079 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.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
@@ -325,7 +325,7 @@
 	JavaModelManager manager = JavaModelManager.getJavaModelManager();
 	Object info = manager.getInfo(this);
 	if (info != null && info != JavaModelCache.NON_EXISTING_JAR_TYPE_INFO) return info;
-	return openWhenClosed(createElementInfo(), monitor);
+	return openWhenClosed(createElementInfo(), false, monitor);
 }
 /*
  * @see IJavaElement
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java
index 1edf492..c277eaa 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java
@@ -1092,12 +1092,12 @@
 			info.resolveBindings = resolveBindings;
 			info.reconcileFlags = reconcileFlags;
 			info.problems = problems;
-			openWhenClosed(info, monitor);
+			openWhenClosed(info, true, monitor);
 			org.eclipse.jdt.core.dom.CompilationUnit result = info.ast;
 			info.ast = null;
 			return result;
 		} else {
-			openWhenClosed(createElementInfo(), monitor);
+			openWhenClosed(createElementInfo(), true, monitor);
 			return null;
 		}
 	} finally {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java
index 638384f..cc69c62 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.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
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java
index 928b6d1..9ad73c8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java
@@ -11,6 +11,7 @@
  *******************************************************************************/
 package org.eclipse.jdt.internal.core;
 
+import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -24,6 +25,7 @@
 import java.util.Set;
 import java.util.Vector;
 
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectDescription;
@@ -149,10 +151,46 @@
 									IProject externalFoldersProject, IProgressMonitor monitor) throws CoreException {
 		
 		IFolder result = addFolder(externalFolderPath, externalFoldersProject, false);
-		if (!result.exists())
-			result.createLink(externalFolderPath, IResource.ALLOW_MISSING_LOCAL, monitor);
-		else if (refreshIfExistAlready)
-			result.refreshLocal(IResource.DEPTH_INFINITE,  monitor);
+		try {
+			if (!result.exists())
+				result.createLink(externalFolderPath, IResource.ALLOW_MISSING_LOCAL, monitor);
+			else if (refreshIfExistAlready)
+				result.refreshLocal(IResource.DEPTH_INFINITE,  monitor);
+		}
+		catch(IllegalArgumentException e) {
+			if (System.getProperty("jdt.bug.367669") != null) { //$NON-NLS-1$
+				System.out.println("============================================================================================================"); //$NON-NLS-1$
+				System.out.println("The following logs are created for troubleshooting bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=367669"); //$NON-NLS-1$
+				System.out.println("Exteral folder: " + externalFolderPath); //$NON-NLS-1$
+				System.out.println("Link folder: " + result.toString()); //$NON-NLS-1$
+				File externalFile = new File(externalFolderPath.toOSString());
+				System.out.println(externalFile.exists() ? "External folder exists" : "ERROR: External folder DOES NOT exist"); //$NON-NLS-1$ //$NON-NLS-2$
+				System.out.println(result.exists() ? "Link for folder exists" : "ERROR: Link for folder does not exist");  //$NON-NLS-1$//$NON-NLS-2$
+				IProject externalFolderProject = getExternalFoldersProject();
+				IFile externalProjectFile = externalFolderProject.getFile(IProjectDescription.DESCRIPTION_FILE_NAME);
+				if (externalProjectFile.exists()) {
+					System.out.println("External Folder Project exists with following content:"); //$NON-NLS-1$
+					BufferedInputStream bs = new BufferedInputStream(externalProjectFile.getContents());
+					int available = 0;
+					try {
+						while ((available = bs.available()) > 0) {
+							byte[] contents = new byte[available];
+							bs.read(contents);
+							System.out.println(new String(contents));
+						}
+						bs.close();
+					} catch (IOException e1) {
+						System.out.println("Error reading external folder project file: Here is the stack trace:"); //$NON-NLS-1$
+						e1.printStackTrace();
+					}
+				}
+				else {
+					System.out.println("ERROR: External folders project doesn't exist."); //$NON-NLS-1$
+				}
+				System.out.println("========================================== Debug information ends =========================================="); //$NON-NLS-1$
+			}
+			throw e;
+		}
 		return result;
 	}
 
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
index a37caa0..6f10548 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.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
@@ -272,7 +272,7 @@
 //{ObjectTeams: role files are not found via containment of regular JavaElements:
 	  try {
 // orig:
-		return openWhenClosed(createElementInfo(), monitor);
+		return openWhenClosed(createElementInfo(), false, monitor);
 // :giro
 	  } catch (JavaModelException jme) {
 		// try to interpret as a ROFI:
@@ -573,7 +573,7 @@
 	 * Opens an <code>Openable</code> that is known to be closed (no check for <code>isOpen()</code>).
 	 * Returns the created element info.
 	 */
-	protected Object openWhenClosed(Object info, IProgressMonitor monitor) throws JavaModelException {
+	protected Object openWhenClosed(Object info, boolean forceAdd, IProgressMonitor monitor) throws JavaModelException {
 		JavaModelManager manager = JavaModelManager.getJavaModelManager();
 		boolean hadTemporaryCache = manager.hasTemporaryCache();
 		try {
@@ -592,7 +592,7 @@
 				throw newNotPresentException();
 			}
 			if (!hadTemporaryCache) {
-				manager.putInfos(this, newElements);
+				info = manager.putInfos(this, info, forceAdd, newElements);
 			}
 		} finally {
 			if (!hadTemporaryCache) {
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 4373699..e61387b 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
@@ -3609,9 +3609,17 @@
 	 * Puts the infos in the given map (keys are IJavaElements and values are JavaElementInfos)
 	 * in the Java model cache in an atomic way.
 	 */
-	protected synchronized void putInfos(IJavaElement openedElement, Map newElements) {
+	protected synchronized Object putInfos(IJavaElement openedElement, Object newInfo, boolean forceAdd, Map newElements) {
 		// remove existing children as the are replaced with the new children contained in newElements
 		Object existingInfo = this.cache.peekAtInfo(openedElement);
+		if (existingInfo != null && !forceAdd) {
+			// If forceAdd is false, then it could mean that the particular element 
+			// wasn't in cache at that point of time, but would have got added through 
+			// another thread. In that case, we better use the other thread's info
+			// rather than removing it's children and creating one another. 
+			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=372687
+			return existingInfo;
+		}
 		if (openedElement instanceof IParent) {
 			closeChildren(existingInfo);
 		}
@@ -3641,6 +3649,7 @@
 			Map.Entry entry = (Map.Entry) iterator.next();
 			this.cache.putInfo((IJavaElement) entry.getKey(), entry.getValue());
 		}
+		return newInfo;
 	}
 
 	private void closeChildren(Object info) {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
index d08dff5..ebfb67b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.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
@@ -1087,6 +1087,11 @@
 						int lastDot = cuName.lastIndexOf('.');
 						if (lastDot != topLevelTypeName.length() || !topLevelTypeName.regionMatches(0, cuName, 0, lastDot))
 							continue;
+
+						// https://bugs.eclipse.org/bugs/show_bug.cgi?id=351697
+						// If we are looking at source location, just ignore binary types
+						if (!(cu instanceof ICompilationUnit))
+							continue;
 						IType type = ((ICompilationUnit) cu).getType(topLevelTypeName);
 						type = getMemberType(type, name, firstDot);
 						if (acceptType(type, acceptFlags, true/*a source type*/)) { // accept type checks for existence
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NamedMember.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NamedMember.java
index c966d1d..ef819dfd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NamedMember.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NamedMember.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 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
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
index 817fc9b..a2be223 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
@@ -489,7 +489,7 @@
 	JavaModelManager manager = JavaModelManager.getJavaModelManager();
 	PackageFragmentRootInfo info = (PackageFragmentRootInfo) manager.peekAtInfo(this);
 	if (info == null) {
-		info = (PackageFragmentRootInfo) openWhenClosed(createElementInfo(), null);
+		info = (PackageFragmentRootInfo) openWhenClosed(createElementInfo(), false, null);
 	}
 	return info.getRootKind();
 }