diff --git a/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF
index 1a69758..c8add58 100644
--- a/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF
@@ -1,8 +1,8 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jdt.core.tests.model; singleton:=true
-Bundle-Version: 3.3.100
+Bundle-SymbolicName: org.eclipse.jdt.core.tests.model;singleton:=true
+Bundle-Version: 3.4.0.qualifier
 Bundle-ClassPath: jdtcoretestsmodel.jar
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
@@ -15,13 +15,13 @@
  org.eclipse.jdt.core.tests.rewrite.modifying
 Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
  org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.3.0,4.0.0)",
+ org.eclipse.jdt.core;bundle-version="[3.7.0,4.0.0)",
  org.junit;bundle-version="3.8.1",
  org.eclipse.test.performance;bundle-version="[3.1.0,4.0.0)",
- org.eclipse.jdt.core.tests.compiler;bundle-version="[3.3.0,4.0.0)",
- org.eclipse.jdt.core.tests.builder;bundle-version="[3.3.0,4.0.0)",
+ org.eclipse.jdt.core.tests.compiler;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.jdt.core.tests.builder;bundle-version="[3.4.0,4.0.0)",
  org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)",
  org.eclipse.text;bundle-version="[3.2.0,4.0.0)",
- com.ibm.icu;bundle-version="[3.4.4,4.3.0)",
+ com.ibm.icu;bundle-version="3.4.4",
  org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)"
 Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/org.eclipse.jdt.core.tests.model/plugin.xml b/org.eclipse.jdt.core.tests.model/plugin.xml
index 380511d..6cda687 100644
--- a/org.eclipse.jdt.core.tests.model/plugin.xml
+++ b/org.eclipse.jdt.core.tests.model/plugin.xml
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
index 127d9e6..cd0cdb0 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
@@ -47,7 +47,7 @@
 	}
 
 	static {
-//		TESTS_NUMBERS = new int[] { 342, 343 };
+//		TESTS_NUMBERS = new int[] { 344 };
 //		TESTS_RANGE = new int[] { 325, -1 };
 //		TESTS_NAMES = new String[] {"test0204"};
 	}
@@ -62,7 +62,7 @@
 			this.workingCopy = null;
 		}
 	}
-	
+
 	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=234609 BindingKey#toSignature() fails with key from createWilcardTypeBindingKey(..)
 	public void test234609() throws JavaModelException {
 
@@ -10990,4 +10990,129 @@
 		annotations = binding.getAnnotations();
 		assertEquals("Wrong size", 1, annotations.length);
 	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=223225
+	public void test344() throws JavaModelException {
+		String contents =
+			"public class X {\n" + 
+			"    private @interface Strings {\n" + 
+			"        String[] value() default \"default element\";\n" + 
+			"    }\n" + 
+			"    private @interface Annot {\n" + 
+			"        String[] value();\n" + 
+			"    }\n" + 
+			"    private @interface Annot2 {\n" + 
+			"        String value();\n" + 
+			"    }\n" + 
+			"    private @interface Annot3 {\n" + 
+			"        Class<?> value();\n" + 
+			"    }\n" + 
+			"    @Strings\n" + 
+			"    public void marker() {\n" + 
+			"        // nothing\n" + 
+			"    }\n" + 
+			"    @Strings(\"single element\")\n" + 
+			"    public void single() {\n" + 
+			"        // nothing\n" + 
+			"    }\n" + 
+			"    @Strings(value = \"single element\")\n" + 
+			"    public void singleValue() {\n" + 
+			"        // nothing\n" + 
+			"    }\n" + 
+			"    @Strings({\"single element\"})\n" + 
+			"    public void singleArray() {\n" + 
+			"        // nothing\n" + 
+			"    }\n" + 
+			"    @Strings(value = {\"single element\"})\n" + 
+			"    public void singleArrayValue() {\n" + 
+			"        // nothing\n" + 
+			"    }\n" + 
+			"    @Strings({\"one\", \"two\", \"three\"})\n" + 
+			"    public void multi() {\n" + 
+			"        // nothing\n" + 
+			"    }\n" + 
+			"    @Strings(value = {\"one\", \"two\", \"three\"})\n" + 
+			"    public void multiValue() {\n" + 
+			"        // nothing\n" + 
+			"    }\n" + 
+			"    @Annot(\"test\")\n" + 
+			"    public void singleValue2() {\n" + 
+			"        // nothing\n" + 
+			"    }\n" + 
+			"    @Annot2(\"test\")\n" +
+			"    @Annot3(Object.class)\n" + 
+			"    public void singleValue3() {\n" + 
+			"        // nothing\n" + 
+			"    }\n" + 
+			"}";
+		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
+		CompilationUnit unit= (CompilationUnit) buildAST(
+			contents,
+			this.workingCopy,
+			true,
+			true,
+			true);
+		class MyVisitor extends ASTVisitor {
+			List memberPairBindings = new ArrayList();
+			private boolean checkAnnotationBinding(Annotation annotation) {
+				final IAnnotationBinding annotationBinding = annotation.resolveAnnotationBinding();
+				final IMemberValuePairBinding[] allMemberValuePairs = annotationBinding.getAllMemberValuePairs();
+				assertEquals("Wrong size", 1, allMemberValuePairs.length);
+				IMemberValuePairBinding memberValuePairBinding = allMemberValuePairs[0];
+				final Object value = memberValuePairBinding.getValue();
+				if ("Strings".equals(annotationBinding.getName())) {
+					assertTrue("Not an array", value.getClass().isArray());
+				}
+				this.memberPairBindings.add(memberValuePairBinding);
+				return false;
+			}
+			public boolean visit(MarkerAnnotation node) {
+				return checkAnnotationBinding(node);
+			}
+			public boolean visit(SingleMemberAnnotation node) {
+				return checkAnnotationBinding(node);
+			}
+			public boolean visit(NormalAnnotation node) {
+				return checkAnnotationBinding(node);
+			}
+			public List allMemberValuePairs() {
+				return this.memberPairBindings;
+			}
+		}
+		MyVisitor visitor = new MyVisitor();
+		unit.accept(visitor);
+		List allMemberValuePairsBindings = visitor.allMemberValuePairs();
+		AnnotationTypeDeclaration annotationTypeDeclaration = (AnnotationTypeDeclaration) ((AbstractTypeDeclaration) unit.types().get(0)).bodyDeclarations().get(0);
+		AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration = (AnnotationTypeMemberDeclaration) annotationTypeDeclaration.bodyDeclarations().get(0);
+		IMethodBinding binding = annotationTypeMemberDeclaration.resolveBinding();
+		Object defaultValue = binding.getDefaultValue();
+		assertTrue("Not an array", !defaultValue.getClass().isArray());
+		unit = (CompilationUnit) buildAST(
+				contents,
+				this.workingCopy,
+				true,
+				true,
+				true);
+		visitor = new MyVisitor();
+		unit.accept(visitor);
+		List allMemberValuePairsBindings2 = visitor.allMemberValuePairs();
+		final int size = allMemberValuePairsBindings.size();
+		assertEquals("Wrong size", 10, size);
+		assertEquals("Wrong size", 10, allMemberValuePairsBindings2.size());
+		StringBuffer buffer = new StringBuffer();
+		StringBuffer buffer2 = new StringBuffer();
+		for (int i = 0; i < size; i++) {
+			final IMemberValuePairBinding firstMemberValuePairBinding = (IMemberValuePairBinding) allMemberValuePairsBindings.get(i);
+			final IMemberValuePairBinding secondMemberValuePairBinding = (IMemberValuePairBinding) allMemberValuePairsBindings2.get(i);
+			final boolean isEqualTo = firstMemberValuePairBinding.isEqualTo(secondMemberValuePairBinding);
+			assertTrue("not equals: " + i, isEqualTo);
+			buffer.append(firstMemberValuePairBinding);
+			buffer2.append(secondMemberValuePairBinding);
+		}
+		assertTrue("Different output", buffer.toString().equals(buffer2.toString()));
+		annotationTypeDeclaration = (AnnotationTypeDeclaration) ((AbstractTypeDeclaration) unit.types().get(0)).bodyDeclarations().get(1);
+		annotationTypeMemberDeclaration = (AnnotationTypeMemberDeclaration) annotationTypeDeclaration.bodyDeclarations().get(0);
+		binding = annotationTypeMemberDeclaration.resolveBinding();
+		defaultValue = binding.getDefaultValue();
+		assertNull("Got a default value", defaultValue);
+	}
 }
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java
index 4653c1f..8384b3e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java
@@ -50,7 +50,7 @@
  * Then open the CU on which the test fails in a ASTView and verify the offset/length
  * of the offending node located at the positions displayed in the console when the test failed...
  *
- * Since 3.4, the failing test also provides the comparision between the source of the comment
+ * Since 3.4, the failing test also provides the comparison between the source of the comment
  * and the string get from the built DOM/AST nodes in the comment (see {@link ASTConverterJavadocFlattener})
  * but this may be not enough to see precisely the origin of the problem.
  */
@@ -94,8 +94,6 @@
 	protected String compilerOption = JavaCore.IGNORE;
 	protected List failures;
 	protected boolean stopOnFailure = true;
-	// Project
-	protected IJavaProject currentProject;
 	Map savedOptions = null;
 
 	/**
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
index bafdf1f..cfe8d9e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
@@ -122,7 +122,7 @@
 	static {
 //		TESTS_NAMES = new String[] {"test0602"};
 //		TESTS_RANGE = new int[] { 713, -1 };
-//		TESTS_NUMBERS =  new int[] { 653 };
+//		TESTS_NUMBERS =  new int[] { 719 };
 	}
 	public static Test suite() {
 		return buildModelTestSuite(ASTConverterTestAST3_2.class);
@@ -10497,4 +10497,65 @@
 			}
 		}
 	}
+	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258905
+	public void test0719() throws JavaModelException {
+		ICompilationUnit workingCopy = null;
+		try {
+			workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/);
+			String contents =
+				"public class X {}";
+	
+			CompilationUnit unit = (CompilationUnit) buildAST(
+					contents,
+					workingCopy,
+					true);
+			final AST currentAst = unit.getAST();
+			// well known bindings
+			String[] wkbs = {
+				"byte", "char", "short", "int", "long", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+				"boolean", "float", "double", "void", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+				"java.lang.AssertionError", //$NON-NLS-1$
+				"java.lang.Class", //$NON-NLS-1$
+				"java.lang.Cloneable", //$NON-NLS-1$
+				"java.lang.Error", //$NON-NLS-1$
+				"java.lang.Exception", //$NON-NLS-1$
+				"java.lang.Object", //$NON-NLS-1$
+				"java.lang.RuntimeException", //$NON-NLS-1$
+				"java.lang.String", //$NON-NLS-1$
+				"java.lang.StringBuffer", //$NON-NLS-1$
+				"java.lang.Throwable", //$NON-NLS-1$
+				"java.io.Serializable", //$NON-NLS-1$
+				"java.lang.Boolean", //$NON-NLS-1$
+				"java.lang.Byte", //$NON-NLS-1$
+				"java.lang.Character", //$NON-NLS-1$
+				"java.lang.Double", //$NON-NLS-1$
+				"java.lang.Float", //$NON-NLS-1$
+				"java.lang.Integer", //$NON-NLS-1$
+				"java.lang.Long", //$NON-NLS-1$
+				"java.lang.Short", //$NON-NLS-1$
+				"java.lang.Void", //$NON-NLS-1$
+			};
+
+			// no-so-well-known bindings
+			String[] nwkbs = {
+				"verylong", //$NON-NLS-1$
+				"java.lang.Math", //$NON-NLS-1$
+				"com.example.MyCode", //$NON-NLS-1$
+			};
+
+			// all of the well known bindings resolve
+			for (int i = 0; i<wkbs.length; i++) {
+				assertNotNull("No binding for " + wkbs[i], currentAst.resolveWellKnownType(wkbs[i]));
+			}
+
+			// none of the no so well known bindings resolve
+			for (int i = 0; i<nwkbs.length; i++) {
+				assertNull("Binding for " + nwkbs[i], currentAst.resolveWellKnownType(nwkbs[i]));
+			}
+		} finally {
+			if (workingCopy != null) {
+				workingCopy.discardWorkingCopy();
+			}
+		}
+	}
 }
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java
index 88f5c10..f21cf50 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java
@@ -44,7 +44,7 @@
 	// All specified tests which do not belong to the class are skipped...
 	static {
 //		TESTS_PREFIX =  "testBug86380";
-//		TESTS_NAMES = new String[] { "testCreateBindings23" };
+//		TESTS_NAMES = new String[] { "testLocalVariable6" };
 //		TESTS_NUMBERS = new int[] { 83230 };
 //		TESTS_RANGE = new int[] { 83304, -1 };
 		}
@@ -1481,6 +1481,62 @@
 	}
 
 	/*
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48420
+	 */
+	public void testLocalVariable6() throws JavaModelException {
+		ASTNode node = buildAST(
+			"public class X {\n" +
+			"	{\n" +
+			"		int local;\n" +
+			"	}\n" +
+			"	public void foo() {\n" +
+			"		int i = 0;\n" +
+			"	}\n" +
+			"	public static void foo(final int n) {\n" +
+			"		int i;\n" +
+			"	}\n" +
+			"	public X(final int j) {\n" +
+			"		int i;\n" +
+			"	}\n" +
+			"}"
+		);
+		node.accept(new ASTVisitor() {
+			public boolean visit(VariableDeclarationFragment fragment) {
+				final IVariableBinding binding = fragment.resolveBinding();
+				final IJavaElement javaElement = binding.getJavaElement();
+				assertNotNull("No java element", javaElement);
+				final int type = javaElement.getElementType();
+				assertEquals("Wrong type", IJavaElement.LOCAL_VARIABLE, type);
+				ILocalVariable variable = (ILocalVariable) javaElement;
+				final ITypeRoot typeRoot = variable.getTypeRoot();
+				assertNotNull("Not type root", typeRoot);
+				assertTrue("Invalid", typeRoot.exists());
+				assertNotNull("No declaring element", variable.getDeclaringMember());
+				int flags = variable.getFlags();
+				assertFalse("wrong modifier for " + variable.getElementName(), Flags.isFinal(flags));
+				assertFalse("wrong value for isParameter" + variable.getElementName(), variable.isParameter());
+				return true;
+			}
+			public boolean visit(SingleVariableDeclaration variableDeclaration) {
+				final IVariableBinding binding = variableDeclaration.resolveBinding();
+				final IJavaElement javaElement = binding.getJavaElement();
+				assertNotNull("No java element", javaElement);
+				final int type = javaElement.getElementType();
+				assertEquals("Wrong type", IJavaElement.LOCAL_VARIABLE, type);
+				ILocalVariable variable = (ILocalVariable) javaElement;
+				final ITypeRoot typeRoot = variable.getTypeRoot();
+				assertNotNull("Not type root", typeRoot);
+				assertTrue("Invalid", typeRoot.exists());
+				assertNotNull("No declaring element", variable.getDeclaringMember());
+				int flags = variable.getFlags();
+				assertTrue("wrong modifier for " + variable.getElementName(), Flags.isFinal(flags));
+				assertTrue("wrong value for isParameter" + variable.getElementName(), variable.isParameter());
+				return true;
+			}
+		});
+	}
+
+	/*
 	 * Ensures that the IJavaElement of an IBinding representing a member type is correct.
 	 */
 	public void testMemberType() throws JavaModelException {
@@ -2113,6 +2169,11 @@
 			"<T> [in X [in [Working copy] X.java [in <default> [in src [in P]]]]]",
 			element
 		);
+		assertEquals("Wrong type", IJavaElement.TYPE_PARAMETER, element.getElementType());
+		ITypeParameter typeParameter = (ITypeParameter) element;
+		final ITypeRoot typeRoot = typeParameter.getTypeRoot();
+		assertNotNull("Not type root", typeRoot);
+		assertTrue("Invalid", typeRoot.exists());
 	}
 
 	/*
@@ -2222,5 +2283,80 @@
 			deleteFile(filePath);
 		}
 	}
+	public void test320802() throws CoreException {
+		String filePath = "/P/src/X.java";
+		String filePathY = "/P/src/p/Y.java";
+		try {
+			String contents =
+				"import p.Y;\n" +
+				"public class X {\n" +
+				"	Y<MissingType1, MissingType2> y;\n" +
+				"	public X() {\n" +
+				"		this.y = new Y<MissingType1, MissingType2>();\n" +
+				"	}\n" + 
+				"}";
+			createFile(filePath, contents);
+			ICompilationUnit compilationUnit = getCompilationUnit("P", "src", "", "X.java");
+			assertTrue(compilationUnit.exists());
 
+			String contents2 =
+				"package p;\n" +
+				"public class Y<T, U> {}";
+			createFolder("/P/src/p");
+			createFile(filePathY, contents2);
+			ICompilationUnit compilationUnit2 = getCompilationUnit("P", "src", "p", "Y.java");
+			assertTrue(compilationUnit2.exists());
+
+			final CompilationUnit[] asts = new CompilationUnit[1];
+			BindingRequestor requestor = new BindingRequestor() {
+				public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
+					asts[0] = ast;
+				}
+			};
+			resolveASTs(
+				new ICompilationUnit[] {compilationUnit},
+				new String[0],
+				requestor,
+				getJavaProject("P"),
+				this.workingCopy.getOwner()
+			);
+			assertNotNull("No ast", asts[0]);
+			final IProblem[] problems = asts[0].getProblems();
+			String expectedProblems = 
+				"1. ERROR in /P/src/X.java (at line 3)\n" + 
+				"	Y<MissingType1, MissingType2> y;\n" + 
+				"	  ^^^^^^^^^^^^\n" + 
+				"MissingType1 cannot be resolved to a type\n" + 
+				"----------\n" + 
+				"2. ERROR in /P/src/X.java (at line 3)\n" + 
+				"	Y<MissingType1, MissingType2> y;\n" + 
+				"	                ^^^^^^^^^^^^\n" + 
+				"MissingType2 cannot be resolved to a type\n" + 
+				"----------\n" + 
+				"3. ERROR in /P/src/X.java (at line 5)\n" + 
+				"	this.y = new Y<MissingType1, MissingType2>();\n" + 
+				"	^^^^^^\n" + 
+				"MissingType1 cannot be resolved to a type\n" + 
+				"----------\n" + 
+				"4. ERROR in /P/src/X.java (at line 5)\n" + 
+				"	this.y = new Y<MissingType1, MissingType2>();\n" + 
+				"	^^^^^^\n" + 
+				"MissingType2 cannot be resolved to a type\n" + 
+				"----------\n" + 
+				"5. ERROR in /P/src/X.java (at line 5)\n" + 
+				"	this.y = new Y<MissingType1, MissingType2>();\n" + 
+				"	               ^^^^^^^^^^^^\n" + 
+				"MissingType1 cannot be resolved to a type\n" + 
+				"----------\n" + 
+				"6. ERROR in /P/src/X.java (at line 5)\n" + 
+				"	this.y = new Y<MissingType1, MissingType2>();\n" + 
+				"	                             ^^^^^^^^^^^^\n" + 
+				"MissingType2 cannot be resolved to a type\n" + 
+				"----------\n";
+			assertProblems("Wrong problems", expectedProblems, problems, contents.toCharArray());
+		} finally {
+			deleteFile(filePath);
+			deleteFile(filePathY);
+		}
+	}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
index 2ab6d2b..a6cd7c7 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -1338,6 +1338,7 @@
 		String[] wkbs = {
 			"byte", "char", "short", "int", "long", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
 			"boolean", "float", "double", "void", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			"java.lang.AssertionError", //$NON-NLS-1$
 			"java.lang.Class", //$NON-NLS-1$
 			"java.lang.Cloneable", //$NON-NLS-1$
 			"java.lang.Error", //$NON-NLS-1$
@@ -1719,6 +1720,16 @@
 		} catch (RuntimeException e) {
 			// pass
 		}
+		
+		// test for 319900
+		x.setLiteralValue("'");
+		assertEquals("", "\"'\"", x.getEscapedValue());
+		assertEquals("", "'", x.getLiteralValue());
+		
+		// test for 319900
+		x.setEscapedValue("\"'\"");
+		assertEquals("", "\"'\"", x.getEscapedValue());
+		assertEquals("", "'", x.getLiteralValue());
 	}
 
 	public void testStringLiteralUnicode() {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
index e4513d2..e784905 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
@@ -363,17 +363,17 @@
 	this.formatterPrefs.disabling_tag = "disable-formatter".toCharArray();
 	this.formatterPrefs.enabling_tag = "enable-formatter".toCharArray();
 	String source =
-		"public class X04 {\r\n" + 
-		"\r\n" + 
-		"/* disable-formatter */\r\n" + 
-		"void     foo(    )      {	\r\n" + 
-		"				//      unformatted       comment  	  \r\n" + 
-		"}\r\n" + 
-		"/* enable-formatter */\r\n" + 
-		"void     bar(    )      {	\r\n" + 
-		"				//      formatted       comment  	  \r\n" + 
-		"}\r\n" + 
-		"}\r\n";
+		"public class X04 {\n" + 
+		"\n" + 
+		"/* disable-formatter */\n" + 
+		"void     foo(    )      {	\n" + 
+		"				//      unformatted       comment  	  \n" + 
+		"}\n" + 
+		"/* enable-formatter */\n" + 
+		"void     bar(    )      {	\n" + 
+		"				//      formatted       comment  	  \n" + 
+		"}\n" + 
+		"}\n";
 	formatSource(source,
 		"public class X04 {\n" + 
 		"\n" + 
@@ -410,22 +410,22 @@
 		"}\n" + 
 		"}\n";
 	formatSource(source,
-		"public class X04b {\r\n" + 
-		"\r\n" + 
-		"/* disable-formatter */\r\n" + 
-		"void     foo(    )      {	\r\n" + 
-		"				//      unformatted       comment  	  \r\n" + 
-		"}\r\n" + 
-		"/* enable-formatter */\r\n" + 
-		"	void bar() {\r\n" + 
-		"		// formatted comment\r\n" + 
-		"	}\r\n" + 
-		"}\r\n",
+		"public class X04b {\n" + 
+		"\n" + 
+		"/* disable-formatter */\n" + 
+		"void     foo(    )      {	\n" + 
+		"				//      unformatted       comment  	  \n" + 
+		"}\n" + 
+		"/* enable-formatter */\n" + 
+		"	void bar() {\n" + 
+		"		// formatted comment\n" + 
+		"	}\n" + 
+		"}\n",
 		CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS,
 		0 /* indentation level */,
 		0 /* offset */,
 		-1 /* length (all) */,
-		"\r\n",
+		"\n",
 		true/*repeat*/);
 }
 public void testBug027079d3() throws JavaModelException {
@@ -433,34 +433,34 @@
 	this.formatterPrefs.disabling_tag = "disable-formatter".toCharArray();
 	this.formatterPrefs.enabling_tag = "enable-formatter".toCharArray();
 	String source =
-		"public class X04c {\r\n" + 
-		"\r\n" + 
-		"/* disable-formatter */\r\n" + 
-		"void     foo(    )      {	\r\n" + 
-		"				//      unformatted       comment  	  \r\n" + 
-		"}\r\n" + 
-		"/* enable-formatter */\r\n" + 
-		"void     bar(    )      {	\r\n" + 
-		"				//      formatted       comment  	  \r\n" + 
-		"}\r\n" + 
-		"}\r\n";
+		"public class X04c {\n" + 
+		"\n" + 
+		"/* disable-formatter */\n" + 
+		"void     foo(    )      {	\n" + 
+		"				//      unformatted       comment  	  \n" + 
+		"}\n" + 
+		"/* enable-formatter */\n" + 
+		"void     bar(    )      {	\n" + 
+		"				//      formatted       comment  	  \n" + 
+		"}\n" + 
+		"}\n";
 	formatSource(source,
-		"public class X04c {\r\n" + 
-		"\r\n" + 
-		"/* disable-formatter */\r\n" + 
-		"void     foo(    )      {	\r\n" + 
-		"				//      unformatted       comment  	  \r\n" + 
-		"}\r\n" + 
-		"/* enable-formatter */\r\n" + 
-		"	void bar() {\r\n" + 
-		"		// formatted comment\r\n" + 
-		"	}\r\n" + 
-		"}\r\n",
+		"public class X04c {\n" + 
+		"\n" + 
+		"/* disable-formatter */\n" + 
+		"void     foo(    )      {	\n" + 
+		"				//      unformatted       comment  	  \n" + 
+		"}\n" + 
+		"/* enable-formatter */\n" + 
+		"	void bar() {\n" + 
+		"		// formatted comment\n" + 
+		"	}\n" + 
+		"}\n",
 		CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS,
 		0 /* indentation level */,
 		0 /* offset */,
 		-1 /* length (all) */,
-		"\r\n",
+		"\n",
 		true/*repeat*/);
 }
 public void testBug027079d4() throws JavaModelException {
@@ -1690,7 +1690,6 @@
  * @bug 252556: [formatter] Spaces removed before formatted region of a compilation unit.
  * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=252556"
  */
-// TODO Fix the bug... this test currently verifies that the problem still occurs!
 public void testBug252556() {
 	String source =
 		"package a;\n" + 
@@ -1711,8 +1710,7 @@
 		"public class Test {\n" + 
 		"\n" + 
 		"	private int field;\n" + 
-//		"	\n" + // this is the expected untouched line
-		"\n" + // instead the tab is removed although it is outside the selection...
+		"	\n" + 
 		"	/**\n" + 
 		"	 * fds\n" + 
 		"	 */\n" + 
@@ -1721,6 +1719,161 @@
 		"}\n"
 	);
 }
+// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=95340
+public void testBug252556a() {
+	String source =
+		"public class Test {\n" + 
+		"\n" + 
+		"int foo() {[#\n" + 
+		"return 0;\n" + 
+		"#]}\n" + 
+		"void bar(){}\n" + 
+		"}\n";
+	formatSource(source,
+		"public class Test {\n" + 
+		"\n" + 
+		"int foo() {\n" + 
+		"		return 0;\n" + 
+		"	}\n" + 
+		"void bar(){}\n" + 
+		"}\n"
+	);
+}
+// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=95340
+public void testBug252556b() {
+	String source =
+		"public class Test {\n" + 
+		"\n" + 
+		"int [#foo() {\n" + 
+		"return 0;\n" + 
+		"#]}\n" + 
+		"void bar(){}\n" + 
+		"}\n";
+	formatSource(source,
+		"public class Test {\n" + 
+		"\n" + 
+		"int foo() {\n" + 
+		"		return 0;\n" + 
+		"	}\n" + 
+		"void bar(){}\n" + 
+		"}\n"
+	);
+}
+// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=95340
+public void testBug252556c() {
+	String source =
+		"public class Test {\n" + 
+		"\n" + 
+		"[#int foo() {\n" + 
+		"return 0;\n" + 
+		"#]}\n" + 
+		"void bar(){}\n" + 
+		"}\n";
+	formatSource(source,
+		"public class Test {\n" + 
+		"\n" + 
+		"	int foo() {\n" + 
+		"		return 0;\n" + 
+		"	}\n" + 
+		"void bar(){}\n" + 
+		"}\n"
+	);
+}
+// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=95340
+public void testBug252556d() {
+	String source =
+		"public class Test {\n" + 
+		"\n" + 
+		"[#int foo() {\n" + 
+		"return 0;\n" + 
+		"}#]\n" + 
+		"void bar(){}\n" + 
+		"}\n";
+	formatSource(source,
+		"public class Test {\n" + 
+		"\n" + 
+		"	int foo() {\n" + 
+		"		return 0;\n" + 
+		"	}\n" + 
+		"void bar(){}\n" + 
+		"}\n"
+	);
+}
+// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=95340
+public void testBug252556e() {
+	String source =
+		"public class Test {\n" + 
+		"\n" + 
+		"[#int foo() {\n" + 
+		"return 0;\n" + 
+		"}\n" + 
+		"#]void bar(){}\n" + 
+		"}\n";
+	formatSource(source,
+		"public class Test {\n" + 
+		"\n" + 
+		"	int foo() {\n" + 
+		"		return 0;\n" + 
+		"	}\n" + 
+		"\n" + 
+		"	void bar(){}\n" + 
+		"}\n"
+	);
+}
+// see org.eclipse.jdt.ui.tests.core.CodeFormatterUtilTest.testFormatSubstring()
+public void testBug252556f() {
+	String source =
+		"package test1;\n" + 
+		"\n" + 
+		"import java.util.Vector;\n" + 
+		"\n" + 
+		"public class A {\n" + 
+		"    public void foo() {\n" + 
+		"    [#Runnable runnable= new Runnable() {};#]\n" + 
+		"    runnable.toString();\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"package test1;\n" + 
+		"\n" + 
+		"import java.util.Vector;\n" + 
+		"\n" + 
+		"public class A {\n" + 
+		"    public void foo() {\n" + 
+		"    	Runnable runnable = new Runnable() {\n" + 
+		"		};\n" + 
+		"    runnable.toString();\n" + 
+		"    }\n" + 
+		"}\n"
+	);
+}
+// Adding a test case impacted by the fix for bug 252556 got from massive tests
+public void testBug252556_wksp3a() {
+	String source =
+		"package wksp3;\n" + 
+		"\n" + 
+		"/**\n" + 
+		" * <pre>import java.net.*;\n" + 
+		" * import org.xml.sax.*;\n" + 
+		" * </pre>\n" + 
+		" */\n" + 
+		"public class X01 {\n" + 
+		"\n" + 
+		"}\n";
+	formatSource(source,
+		"package wksp3;\n" + 
+		"\n" + 
+		"/**\n" + 
+		" * <pre>\n" + 
+		" * import java.net.*;\n" + 
+		" * import org.xml.sax.*;\n" + 
+		" * </pre>\n" + 
+		" */\n" + 
+		"public class X01 {\n" + 
+		"\n" + 
+		"}\n"
+	);
+}
 
 /**
  * @bug 281655: [formatter] "Never join lines" does not work for annotations.
@@ -6046,6 +6199,423 @@
 }
 
 /**
+ * @bug 311578: [formatter] Enable/disable tag detection should include comment start/end tokens
+ * @test Ensure that the formatter now accepts tags with comment start/end tokens
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311578"
+ */
+public void testBug311578a() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	this.formatterPrefs.disabling_tag = "//J-".toCharArray();
+	this.formatterPrefs.enabling_tag = "//J+".toCharArray();
+	String source =
+		"package a;\n" + 
+		"public class Bug {\n" + 
+		"int a      =  -     1  +    42;\n" + 
+		"\n" + 
+		"//J-\n" + 
+		"int b      =  -     1  +    42;\n" + 
+		"//J+\n" + 
+		"\n" + 
+		"char                       x;\n" + 
+		"\n" + 
+		"////J-\n" + 
+		"int c      =  -     1  +    42;\n" + 
+		"////J+\n" + 
+		"\n" + 
+		"char                       y;\n" + 
+		"\n" + 
+		"/* J- */\n" + 
+		"int d      =  -     1  +    42;\n" + 
+		"/* J+ */\n" + 
+		"\n" + 
+		"char                       z;\n" + 
+		"\n" + 
+		"/* //J- */\n" + 
+		"int e      =  -     1  +    42;\n" + 
+		"/* //J+ */\n" + 
+		"\n" + 
+		"/** J-1 blabla */\n" + 
+		"char                       t;\n" + 
+		"}\n";
+	formatSource(source,
+		"package a;\n" + 
+		"\n" + 
+		"public class Bug {\n" + 
+		"	int a = -1 + 42;\n" + 
+		"\n" + 
+		"//J-\n" + 
+		"int b      =  -     1  +    42;\n" + 
+		"//J+\n" + 
+		"\n" + 
+		"	char x;\n" + 
+		"\n" + 
+		"////J-\n" + 
+		"int c      =  -     1  +    42;\n" + 
+		"////J+\n" + 
+		"\n" + 
+		"	char y;\n" + 
+		"\n" + 
+		"	/* J- */\n" + 
+		"	int d = -1 + 42;\n" + 
+		"	/* J+ */\n" + 
+		"\n" + 
+		"	char z;\n" + 
+		"\n" + 
+		"/* //J- */\n" + 
+		"int e      =  -     1  +    42;\n" + 
+		"/* //J+ */\n" + 
+		"\n" + 
+		"	/** J-1 blabla */\n" + 
+		"	char t;\n" + 
+		"}\n"
+	);
+}
+public void testBug311578b() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	this.formatterPrefs.disabling_tag = "/* J- */".toCharArray();
+	this.formatterPrefs.enabling_tag = "/* J+ */".toCharArray();
+	String source =
+		"package a;\n" + 
+		"public class Bug {\n" + 
+		"int a      =  -     1  +    42;\n" + 
+		"\n" + 
+		"//J-\n" + 
+		"int b      =  -     1  +    42;\n" + 
+		"//J+\n" + 
+		"\n" + 
+		"char                       x;\n" + 
+		"\n" + 
+		"////J-\n" + 
+		"int c      =  -     1  +    42;\n" + 
+		"////J+\n" + 
+		"\n" + 
+		"char                       y;\n" + 
+		"\n" + 
+		"/* J- */\n" + 
+		"int d      =  -     1  +    42;\n" + 
+		"/* J+ */\n" + 
+		"\n" + 
+		"char                       z;\n" + 
+		"\n" + 
+		"/* //J- */\n" + 
+		"int e      =  -     1  +    42;\n" + 
+		"/* //J+ */\n" + 
+		"\n" + 
+		"/** J-1 blabla */\n" + 
+		"char                       t;\n" + 
+		"}\n";
+	formatSource(source,
+		"package a;\n" + 
+		"\n" + 
+		"public class Bug {\n" + 
+		"	int a = -1 + 42;\n" + 
+		"\n" + 
+		"	// J-\n" + 
+		"	int b = -1 + 42;\n" + 
+		"	// J+\n" + 
+		"\n" + 
+		"	char x;\n" + 
+		"\n" + 
+		"	// //J-\n" + 
+		"	int c = -1 + 42;\n" + 
+		"	// //J+\n" + 
+		"\n" + 
+		"	char y;\n" + 
+		"\n" + 
+		"/* J- */\n" + 
+		"int d      =  -     1  +    42;\n" + 
+		"/* J+ */\n" + 
+		"\n" + 
+		"	char z;\n" + 
+		"\n" + 
+		"	/* //J- */\n" + 
+		"	int e = -1 + 42;\n" + 
+		"	/* //J+ */\n" + 
+		"\n" + 
+		"	/** J-1 blabla */\n" + 
+		"	char t;\n" + 
+		"}\n"
+	);
+}
+public void testBug311578c() throws JavaModelException {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, DefaultCodeFormatterConstants.TRUE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "//F--");
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, "//F++");
+	String source =
+		"package a;\n" + 
+		"public class Bug {\n" + 
+		"int a      =  -     1  +    42;\n" + 
+		"\n" + 
+		"//F--\n" + 
+		"int b      =  -     1  +    42;\n" + 
+		"//F++\n" + 
+		"\n" + 
+		"char                       x;\n" + 
+		"\n" + 
+		"////F--\n" + 
+		"int c      =  -     1  +    42;\n" + 
+		"////F++\n" + 
+		"\n" + 
+		"char                       y;\n" + 
+		"\n" + 
+		"/* F-- */\n" + 
+		"int d      =  -     1  +    42;\n" + 
+		"/* F++ */\n" + 
+		"\n" + 
+		"char                       z;\n" + 
+		"\n" + 
+		"/* //F-- */\n" + 
+		"int e      =  -     1  +    42;\n" + 
+		"/* //F++ */\n" + 
+		"\n" + 
+		"/** F--1 blabla */\n" + 
+		"char                       t;\n" + 
+		"}\n";
+	formatSource(source,
+		"package a;\n" + 
+		"\n" + 
+		"public class Bug {\n" + 
+		"	int a = -1 + 42;\n" + 
+		"\n" + 
+		"//F--\n" + 
+		"int b      =  -     1  +    42;\n" + 
+		"//F++\n" + 
+		"\n" + 
+		"	char x;\n" + 
+		"\n" + 
+		"////F--\n" + 
+		"int c      =  -     1  +    42;\n" + 
+		"////F++\n" + 
+		"\n" + 
+		"	char y;\n" + 
+		"\n" + 
+		"	/* F-- */\n" + 
+		"	int d = -1 + 42;\n" + 
+		"	/* F++ */\n" + 
+		"\n" + 
+		"	char z;\n" + 
+		"\n" + 
+		"/* //F-- */\n" + 
+		"int e      =  -     1  +    42;\n" + 
+		"/* //F++ */\n" + 
+		"\n" + 
+		"	/** F--1 blabla */\n" + 
+		"	char t;\n" + 
+		"}\n"
+	);
+}
+public void testBug311578d() throws JavaModelException {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, DefaultCodeFormatterConstants.TRUE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "/*F--*/");
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, "/*F++*/");
+	String source =
+		"package a;\n" + 
+		"public class Bug {\n" + 
+		"int a      =  -     1  +    42;\n" + 
+		"\n" + 
+		"//F--\n" + 
+		"int b      =  -     1  +    42;\n" + 
+		"//F++\n" + 
+		"\n" + 
+		"char                       x;\n" + 
+		"\n" + 
+		"////F--\n" + 
+		"int c      =  -     1  +    42;\n" + 
+		"////F++\n" + 
+		"\n" + 
+		"char                       y;\n" + 
+		"\n" + 
+		"/* F-- */\n" + 
+		"int d      =  -     1  +    42;\n" + 
+		"/* F++ */\n" + 
+		"\n" + 
+		"char                       y2;\n" + 
+		"\n" + 
+		"/*F--*/\n" + 
+		"int d2      =  -     1  +    42;\n" + 
+		"/*F++*/\n" + 
+		"\n" + 
+		"char                       z;\n" + 
+		"\n" + 
+		"/* //F-- */\n" + 
+		"int e      =  -     1  +    42;\n" + 
+		"/* //F++ */\n" + 
+		"\n" + 
+		"/** F--1 blabla */\n" + 
+		"char                       t;\n" + 
+		"}\n";
+	formatSource(source,
+		"package a;\n" + 
+		"\n" + 
+		"public class Bug {\n" + 
+		"	int a = -1 + 42;\n" + 
+		"\n" + 
+		"	// F--\n" + 
+		"	int b = -1 + 42;\n" + 
+		"	// F++\n" + 
+		"\n" + 
+		"	char x;\n" + 
+		"\n" + 
+		"	// //F--\n" + 
+		"	int c = -1 + 42;\n" + 
+		"	// //F++\n" + 
+		"\n" + 
+		"	char y;\n" + 
+		"\n" + 
+		"	/* F-- */\n" + 
+		"	int d = -1 + 42;\n" + 
+		"	/* F++ */\n" + 
+		"\n" + 
+		"	char y2;\n" + 
+		"\n" + 
+		"/*F--*/\n" + 
+		"int d2      =  -     1  +    42;\n" + 
+		"/*F++*/\n" + 
+		"\n" + 
+		"	char z;\n" + 
+		"\n" + 
+		"	/* //F-- */\n" + 
+		"	int e = -1 + 42;\n" + 
+		"	/* //F++ */\n" + 
+		"\n" + 
+		"	/** F--1 blabla */\n" + 
+		"	char t;\n" + 
+		"}\n"
+	);
+}
+public void testBug311578e() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	this.formatterPrefs.disabling_tag = "//J-".toCharArray();
+	this.formatterPrefs.enabling_tag = "//J+".toCharArray();
+	String source =
+		"package a;\n" + 
+		"public class Bug {\n" + 
+		"char                       z2;\n" + 
+		"\n" + 
+		"//J-1\n" + 
+		"int f      =  -     1  +    42;\n" + 
+		"//J+2\n" + 
+		"\n" + 
+		"char                       z3;\n" + 
+		"\n" + 
+		"//J- 1\n" + 
+		"int g      =  -     1  +    42;\n" + 
+		"//J+ 2\n" + 
+		"\n" + 
+		"char                       z4;\n" + 
+		"\n" + 
+		"  //J-\n" + 
+		"int h      =  -     1  +    42;\n" + 
+		"  //J+\n" + 
+		"\n" + 
+		"char                       z5;\n" + 
+		"\n" + 
+		"/*\n" + 
+		"//J-\n" + 
+		"*/\n" + 
+		"int i      =  -     1  +    42;\n" + 
+		"/*\n" + 
+		" //J+\n" + 
+		" */\n" + 
+		"\n" + 
+		"char                       z6;" +
+		"}\n";
+	formatSource(source,
+		"package a;\n" + 
+		"\n" + 
+		"public class Bug {\n" + 
+		"	char z2;\n" + 
+		"\n" + 
+		"//J-1\n" + 
+		"int f      =  -     1  +    42;\n" + 
+		"//J+2\n" + 
+		"\n" + 
+		"	char z3;\n" + 
+		"\n" + 
+		"//J- 1\n" + 
+		"int g      =  -     1  +    42;\n" + 
+		"//J+ 2\n" + 
+		"\n" + 
+		"	char z4;\n" + 
+		"\n" + 
+		"	//J-\n" + 
+		"int h      =  -     1  +    42;\n" + 
+		"  //J+\n" + 
+		"\n" + 
+		"	char z5;\n" + 
+		"\n" + 
+		"/*\n" + 
+		"//J-\n" + 
+		"*/\n" + 
+		"int i      =  -     1  +    42;\n" + 
+		"/*\n" + 
+		" //J+\n" + 
+		" */\n" + 
+		"\n" + 
+		"	char z6;\n" + 
+		"}\n"
+	);
+}
+public void testBug311578_320754a() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	this.formatterPrefs.disabling_tag = "//J-".toCharArray();
+	this.formatterPrefs.enabling_tag = "//J+".toCharArray();
+	String source =
+		"//J-\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"//J+\n" + 
+		"public class X\n" + 
+		"{\n" + 
+		"    public void foo()\n" + 
+		"    {\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"//J-\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"//J+\n" + 
+		"public class X {\n" + 
+		"	public void foo() {\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void testBug311578_320754b() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	this.formatterPrefs.disabling_tag = "/*J-*/".toCharArray();
+	this.formatterPrefs.enabling_tag = "/*J+*/".toCharArray();
+	String source =
+		"/*J-*/\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"/*J+*/\n" + 
+		"public class X\n" + 
+		"{\n" + 
+		"    public void foo()\n" + 
+		"    {\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"/*J-*/\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"/*J+*/\n" + 
+		"public class X {\n" + 
+		"	public void foo() {\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+
+/**
  * @bug 311582: [formatter] Master switch to enable/disable on/off tags
  * @test Ensure that the formatter does not take care of formatting tags by default
  * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311582"
@@ -6692,4 +7262,294 @@
 	);
 }
 
+/**
+ * @bug 320754: [formatter] formatter:off/on tags does not work correctly
+ * @test Ensure disabling/enabling tags work properly around annotations
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=320754"
+ */
+public void testBug320754_00() throws JavaModelException {
+	String source =
+		"public class X00\n" + 
+		"{\n" + 
+		"    public static void main(String[] args)\n" + 
+		"    {\n" + 
+		"        int a=0;int b;\n" + 
+		"\n" + 
+		"        System.out.println(a);\n" + 
+		"\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"public class X00 {\n" + 
+		"	public static void main(String[] args) {\n" + 
+		"		int a = 0;\n" + 
+		"		int b;\n" + 
+		"\n" + 
+		"		System.out.println(a);\n" + 
+		"\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void testBug320754_01a() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	String source =
+		"//@formatter:off\n" + 
+		"//@formatter:on\n" + 
+		"public class X01a\n" + 
+		"{\n" + 
+		"    public static void main(String[] args)\n" + 
+		"    {\n" + 
+		"        int a=0;int b;\n" + 
+		"\n" + 
+		"        System.out.println(a);\n" + 
+		"\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"//@formatter:off\n" + 
+		"//@formatter:on\n" + 
+		"public class X01a {\n" + 
+		"	public static void main(String[] args) {\n" + 
+		"		int a = 0;\n" + 
+		"		int b;\n" + 
+		"\n" + 
+		"		System.out.println(a);\n" + 
+		"\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void testBug320754_01b() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	String source =
+		"/* @formatter:off */\n" + 
+		"/* @formatter:on */\n" + 
+		"public class X01b\n" + 
+		"{\n" + 
+		"    public static void main(String[] args)\n" + 
+		"    {\n" + 
+		"        int a=0;int b;\n" + 
+		"\n" + 
+		"        System.out.println(a);\n" + 
+		"\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"/* @formatter:off */\n" + 
+		"/* @formatter:on */\n" + 
+		"public class X01b {\n" + 
+		"	public static void main(String[] args) {\n" + 
+		"		int a = 0;\n" + 
+		"		int b;\n" + 
+		"\n" + 
+		"		System.out.println(a);\n" + 
+		"\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void testBug320754_01c() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	String source =
+		"/** @formatter:off */\n" + 
+		"/** @formatter:on */\n" + 
+		"public class X01c\n" + 
+		"{\n" + 
+		"    public static void main(String[] args)\n" + 
+		"    {\n" + 
+		"        int a=0;int b;\n" + 
+		"\n" + 
+		"        System.out.println(a);\n" + 
+		"\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"/** @formatter:off */\n" + 
+		"/** @formatter:on */\n" + 
+		"public class X01c {\n" + 
+		"	public static void main(String[] args) {\n" + 
+		"		int a = 0;\n" + 
+		"		int b;\n" + 
+		"\n" + 
+		"		System.out.println(a);\n" + 
+		"\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void testBug320754_02a() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	String source =
+		"//@formatter:off\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"//@formatter:on\n" + 
+		"public class X02\n" + 
+		"{\n" + 
+		"    public static void main(String[] args)\n" + 
+		"    {\n" + 
+		"        int a=0;int b;\n" + 
+		"\n" + 
+		"        System.out.println(a);\n" + 
+		"\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"//@formatter:off\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"//@formatter:on\n" + 
+		"public class X02 {\n" + 
+		"	public static void main(String[] args) {\n" + 
+		"		int a = 0;\n" + 
+		"		int b;\n" + 
+		"\n" + 
+		"		System.out.println(a);\n" + 
+		"\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void testBug320754_02b() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	String source =
+		"/* @formatter:off */\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"/* @formatter:on */\n" + 
+		"public class X02b\n" + 
+		"{\n" + 
+		"    public static void main(String[] args)\n" + 
+		"    {\n" + 
+		"        int a=0;int b;\n" + 
+		"\n" + 
+		"        System.out.println(a);\n" + 
+		"\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"/* @formatter:off */\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"/* @formatter:on */\n" + 
+		"public class X02b {\n" + 
+		"	public static void main(String[] args) {\n" + 
+		"		int a = 0;\n" + 
+		"		int b;\n" + 
+		"\n" + 
+		"		System.out.println(a);\n" + 
+		"\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void testBug320754_02c() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	String source =
+		"/** @formatter:off */\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"/** @formatter:on */\n" + 
+		"public class X02c\n" + 
+		"{\n" + 
+		"    public static void main(String[] args)\n" + 
+		"    {\n" + 
+		"        int a=0;int b;\n" + 
+		"\n" + 
+		"        System.out.println(a);\n" + 
+		"\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"/** @formatter:off */\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"/** @formatter:on */\n" + 
+		"public class X02c {\n" + 
+		"	public static void main(String[] args) {\n" + 
+		"		int a = 0;\n" + 
+		"		int b;\n" + 
+		"\n" + 
+		"		System.out.println(a);\n" + 
+		"\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void testBug320754_02d() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	String source =
+		"//@formatter:off\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"\n" + 
+		"//@formatter:on\n" + 
+		"public class X02d\n" + 
+		"{\n" + 
+		"    public static void main(String[] args)\n" + 
+		"    {\n" + 
+		"        int a=0;int b;\n" + 
+		"\n" + 
+		"        System.out.println(a);\n" + 
+		"\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"//@formatter:off\n" + 
+		"@MyAnnot (\n" + 
+		"  testAttribute = {\"test1\", \"test2\", \"test3\"}\n" + 
+		")\n" + 
+		"\n" + 
+		"//@formatter:on\n" + 
+		"public class X02d {\n" + 
+		"	public static void main(String[] args) {\n" + 
+		"		int a = 0;\n" + 
+		"		int b;\n" + 
+		"\n" + 
+		"		System.out.println(a);\n" + 
+		"\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void testBug320754_03() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	String source =
+		"//@formatter:off\n" + 
+		"\n" + 
+		"//@formatter:on\n" + 
+		"public class X03\n" + 
+		"{\n" + 
+		"    public static void main(String[] args)\n" + 
+		"    {\n" + 
+		"        int a=0;int b;\n" + 
+		"\n" + 
+		"        System.out.println(a);\n" + 
+		"\n" + 
+		"    }\n" + 
+		"}\n";
+	formatSource(source,
+		"//@formatter:off\n" + 
+		"\n" + 
+		"//@formatter:on\n" + 
+		"public class X03 {\n" + 
+		"	public static void main(String[] args) {\n" + 
+		"		int a = 0;\n" + 
+		"		int b;\n" + 
+		"\n" + 
+		"		System.out.println(a);\n" + 
+		"\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
index d00b922..b096973 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
@@ -714,7 +714,7 @@
 		"public class Test {\r\n" +
 		"\r\n" +
 		"	private int field;\r\n" +
-		"\r\n" +
+		"	\r\n" +
 		"	/**\r\n" +
 		"	 * fds\r\n" +
 		"	 */\r\n" +
@@ -954,8 +954,8 @@
 	// This is due to the fact that the region is adapted to include the edit just before the comment
 	formatSource(source,
 		"public class C {\n" +
-		"\n" +
-		"	/**\n" +
+		"	\n" +
+		"        /**\n" +
 		"	 * a b c d .\n" +
 		"	 */\n" +
 		"	void m1() {\n" +
@@ -987,8 +987,8 @@
 	// This is due to the fact that the region is adapted to include the edit just before the comment
 	formatSource(source,
 		"public class C {\n" +
-		"\n" +
-		"	/**\n" +
+		"	\n" +
+		"        /**\n" +
 		"	 * a b c d .\n" +
 		"	 */\n" +
 		"	void m1  (   )   {\n" +
@@ -1083,9 +1083,9 @@
 	// Note that the incorrect indentation before the javadoc is fixed in this test case...
 	// This is due to the fact that the region is adapted to include the edit just before the comment
 	formatSource(source,
-		"   public     class			C{\n" +
-		"\n" +
-		"	/**\n" +
+		"   public     class			C{    \n" +
+		"	\n" +
+		"        /**\n" +
 		"	 * a b c d .\n" +
 		"	 */\n" +
 		"        void		m1  (   )   {\n" +
@@ -1147,8 +1147,8 @@
 	// This is due to the fact that the region is adapted to include the edit just before the comment
 	formatSource(source,
 		"public class D {\n" +
-		"\n" +
-		"	/*\n" +
+		"	\n" +
+		"        /*\n" +
 		"	 * a b c d .\n" +
 		"	 */\n" +
 		"	void m2() {\n" +
@@ -1180,8 +1180,8 @@
 	// This is due to the fact that the region is adapted to include the edit just before the comment
 	formatSource(source,
 		"public class D {\n" +
-		"\n" +
-		"	/*\n" +
+		"	\n" +
+		"        /*\n" +
 		"	 * a b c d .\n" +
 		"	 */\n" +
 		"	void m2  (   )   {\n" +
@@ -1276,9 +1276,9 @@
 	// Note that the incorrect indentation before the javadoc is fixed in this test case...
 	// This is due to the fact that the region is adapted to include the edit just before the comment
 	formatSource(source,
-		"   public     class			D{\n" +
-		"\n" +
-		"	/*\n" +
+		"   public     class			D{    \n" +
+		"	\n" +
+		"        /*\n" +
 		"	 * a b c d .\n" +
 		"	 */\n" +
 		"        void		m2  (   )   {\n" +
@@ -1553,7 +1553,7 @@
 	formatSource(source,
 		"\n" +
 		"public class E01 {\n" +
-		"	/**\n" +
+		"        /**\n" +
 		"	 * Javadoc comment\n" +
 		"	 */\n" +
 		"        /*\n" +
@@ -6758,7 +6758,7 @@
  * @test Ensure that no NPE occurs while formatting an empty code inline tag.
  * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311864"
  */
-public void testBug0311864() throws JavaModelException {
+public void testBug311864() throws JavaModelException {
 	this.formatterPrefs.use_tags = true;
 	String source =
 		"public class Test {\n" + 
@@ -6797,4 +6797,262 @@
 	);
 }
 
+/**
+ * @bug 315577: [formatter] NullPointerException (always) on inserting a custom template proposal into java code when "Use code formatter" is on
+ * @test Ensure that no NPE occurs when inserting the custom template
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=315577"
+ */
+public void testBug315577() throws JavaModelException {
+	String source =
+		"public class C {\n" + 
+		"\n" + 
+		"	/**\n" + 
+		"	 * aaaa aaa aaa.<br>\n" + 
+		"	 * {@link C}: aaaa.<br>\n" + 
+		"	 * {@link C}: aaaa.<br>\n" + 
+		"	 * aaa {@link C}: aaaa.<br>\n" + 
+		"	 * {@link C}: aaaa<br>\n" + 
+		"	 * {@link C}: aaaa.<br>\n" + 
+		"	 */\n" + 
+		"	public C() {\n" + 
+		"	}\n" + 
+		"}\n";
+	formatSource(source);
+}
+
+/**
+ * @bug 315732: [formatter] NullPointerException (always) on inserting a custom template proposal into java code when "Use code formatter" is on
+ * @test Ensure that no NPE occurs when inserting the custom template
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=315732"
+ */
+public void testBug315732() throws JavaModelException {
+	this.formatterPrefs.use_tags = true;
+	String source =
+		"// ============================================================================\r\n" +
+		"// /*-*/\r\n" +
+		"// ============================================================================\r\n";
+	formatSource(source,
+		"	// ============================================================================\n" + 
+		"	// /*-*/\n" + 
+		"	// ============================================================================\n",
+		CodeFormatter.K_UNKNOWN,
+		1,
+		true
+	);
+}
+
+/**
+ * @bug 313651: [formatter] Unexpected indentation of line comment
+ * @test Verify that comments with too different indentation are not considered as contiguous
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=313651"
+ */
+public void testBug313651_01() {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.TRUE);
+	String source = 
+		"public class X01 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"//		System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n";
+	formatSource(source);
+}
+public void testBug313651_01b() {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.TRUE);
+	String source = 
+		"public class X01 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"//		System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n";
+	formatSource(source);
+}
+public void testBug313651_01c() {
+	String source = 
+		"public class X01 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"//		System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n";
+	formatSource(source,
+		"public class X01 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"		// System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n"
+	);
+}
+public void testBug313651_02() {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.TRUE);
+	String source = 
+		"public class X02 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"		System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"//		System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n";
+	formatSource(source);
+}
+public void testBug313651_02b() {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.TRUE);
+	String source = 
+		"public class X02 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"		System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"//		System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n";
+	formatSource(source);
+}
+public void testBug313651_02c() {
+	String source = 
+		"public class X02 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"		System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"//		System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n";
+	formatSource(source,
+		"public class X02 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"		System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"		// System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n"
+	);
+}
+public void testBug313651_03() {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.TRUE);
+	String source = 
+		"public class X03 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"//		System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"//		System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n";
+	formatSource(source);
+}
+public void testBug313651_03b() {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.TRUE);
+	String source = 
+		"public class X03 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"//		System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"//		System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n";
+	formatSource(source);
+}
+public void testBug313651_03c() {
+	String source = 
+		"public class X03 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"//		System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"//		System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n";
+	formatSource(source,
+		"public class X03 {\n" + 
+		"	public void testMethod() {\n" + 
+		"		// Comment 1\n" + 
+		"		System.out.println(\"start\");\n" + 
+		"		// System.out.println(\"next\");\n" + 
+		"		// Comment 1\n" + 
+		"		// System.out.println(\"end\");\n" + 
+		"	}\n" + 
+	    "}\n"
+	);
+}
+public void testBug313651_wksp3_01() {
+	String source = 
+		"package wksp3;\n" + 
+		"public class X01 implements\n" + 
+		"// start of comment\n" + 
+		"// MyFirstInterface {\n" + 
+		"	MySecondInterface {\n" + 
+		"// end of comment\n" + 
+	    "}\n";
+	formatSource(source,
+		"package wksp3;\n" + 
+		"\n" + 
+		"public class X01 implements\n" + 
+		"// start of comment\n" + 
+		"// MyFirstInterface {\n" + 
+		"		MySecondInterface {\n" + 
+		"	// end of comment\n" + 
+	    "}\n"
+	);
+}
+public void testBug313651_wksp3_02() {
+	String source = 
+		"package wksp3;\n" + 
+		"public class X02 implements MyOtherInterface, \n" + 
+		"// start of comment\n" + 
+		"// MyFirstInterface {\n" + 
+		"	MySecondInterface {\n" + 
+		"// end of comment\n" + 
+	    "}\n";
+	formatSource(source,
+		"package wksp3;\n" + 
+		"\n" + 
+		"public class X02 implements MyOtherInterface,\n" + 
+		"// start of comment\n" + 
+		"// MyFirstInterface {\n" + 
+		"		MySecondInterface {\n" + 
+		"	// end of comment\n" + 
+	    "}\n"
+	);
+}
+
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterMassiveRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterMassiveRegressionTests.java
index 54c9fe1..72d6a54 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterMassiveRegressionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterMassiveRegressionTests.java
@@ -57,97 +57,160 @@
 /**
  * Comment formatter test suite for massive tests at a given location.
  * <p>
- * This test suite has only one generic test. The tests are dynamically defined by
- * getting all compilation units located at the running workspace or at the
- * directory specified using the "dir" system property and create
- * one test per unit.
+ * This test suite has only one generic test. When running this test suite, one test
+ * is created per compilation unit found while traversing the directory specified
+ * using the <code>inputDir</code> system property<br>(e.g.
+ * <code>-DinputDir=D:\eclipse\workspaces\formatter\inputs\full-src-30</code>).
  * </p><p>
- * The test consists in first format the compilation unit using the new comments
- * formatter (i.e. since bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780
- * has been fixed) and second eventually compare it with the output that the
- * previous comments formatter would have done.
+ * Each test formats twice the compilation unit and compare the result to a
+ * previous formatting already stored at the same location from a root directory
+ * specified using the <code>outputDir</code> system property.
  * </p><p>
- * So, if no comparison is done, the test only insure that the new formatter does
- * not blow up while formatting the files found at the given location and that the
- * second formatting gives the same output than the first one.
+ * For example, if <code>outputDir</code> is set to the following value:<br>
+ * <code>-DoutputDir=D:\eclipse\workspaces\formatter\outputs</code><br>
+ * then a compilation unit found in <code>...\inputs\full-src-30\test\A.java</code>
+ * will be compared with the previously stored output in:
+ * <code>...\outputs\full-src-30\test\A.java</code>
  * </p><p>
- * TODO See how fix the remaining failing tests when comparing the
- * formatting of JUnit 3.8.2 files:
- * <ul>
- * 	<li>0 error</li>
- * 	<li>0 failure</li>
- * 	<li>0 file has different line leading spaces than old formatter</li>
- * 	<li>23 files have spaces differences with old formatter</li>
- *		</ul>
- * </p><p>
- * TODO Fix failures while running on workspaces without comparing.
- *
- * It is not possible to continue to compare the entire files after 2 formatting
- * as the code formatter cannot handle properly following snippet:
+ * To store the outputs on a specific input directory using a specific version,
+ * then load a JDT/Core version in the workspace and run this test suite using
+ * the following VM arguments:
  * <pre>
- * public class X02 {
- * 	int field; // This is a long comment that should be split in multiple line comments in case the line comment formatting is enabled
- * }
+ * -DinputDir=D:\eclipse\workspaces\formatter\inputs\full-src-30
+ * -DoutputDir=D:\eclipse\workspaces\formatter\outputs,clean
  * </pre>
- * Which is formatted as:
+ * Note the <code>clean</code> arguments added at the end of the outputDir
+ * system property to signify that the formatter outputs must be cleaned and
+ * stored.
+ * </p><p>
+ * The <code>logDir</code> system property can be set to tell the suite to
+ * write the console output in a file located in the specified directory. That makes
+ * the comparison between version and patches easier to do using the eclipse
+ * file comparison...
+ * </p><p><br>
+ * <b>***************************************<br>
+ * * Process to run massive tests against a patch *<br>
+ * ***************************************</b>
+ * <p>
+ * Here is the full description of the process to run massive tests against a patch
+ * using this test suite and all the compilation units of the JDT/Core performance
+ * <b>full-source-R3_0.zip</b> file...
+ * </p>
+ * <h3>Set-up input directory</h3>
+ * <p>
+ * The test suite needs to know where are the sources which will be used
+ * to massively test the formatter. To make it easy to set-up, only a root directory
+ * is necessary. From there, all compilation units found while traversing the tree of
+ * this directory will be used for the massive tests.
+ * </p><p>
+ * In our example, we will extract the content of the <b>full-source-R3_0.zip</b>
+ * file located in the <b>org.eclipse.jdt.core.tests.performance</b> plugin
+ * somewhere on our local disk... let's say in the
+ * <b>D:\tmp\formatter\inputs\full-src-30</b> directory.
+ * </p>
+ * <h3>Create the output reference</h3>
+ * <p>
+ * The reference from which the patch output will be compared to while running
+ * the massive test needs also to be created. To do this, a launch config
+ * for the <code>FormatterMassiveRegressionTests</code> test suite is necessary.
+ * </p><p>
+ *  For example, create a launch config named
+ * <b>FormatterMassiveRegressionTests (Eclipse 3.0 - clean)</b> with the
+ * following VM arguments:
  * <pre>
- * public class X02 {
- * 	int field; // This is a long comment that should be split in multiple line
- * 				// comments in case the line comment formatting is enabled
- * }
+ * -Xmx256M
+ * -DinputDir=D:\tmp\formatter\inputs\full-src-30
+ * -DoutputDir=D:\tmp\formatter\outputs,clean
+ * -DlogDir=D:\tmp\formatter\log
  * </pre>
- * But got a different output if formatted again:
+ * </p><p>
+ * Load the last version of JDT/Core plugins (e.g. <code>v_B11</code>) and
+ * launch this config...
+ * </p><p>
+ * When done, the console should have the following content:
  * <pre>
- * public class X02 {
- * 	int field; // This is a long comment that should be split in multiple line
- * 	// comments in case the line comment formatting is enabled
- * }
+ * Get all files from D:\tmp\formatter\inputs\full-src-30...done
+ * Deleting all files from D:\tmp\formatter\outputs\v37\full-src-30...done
+ * Version   : v_B11
+ * Profiles  : none!
+ * Test date : 9/12/10 1:47 PM
+ * Input dir : D:\tmp\formatter\inputs\full-src-30
+ *             9950 java files to format...
+ * Output dir: D:\tmp\formatter\outputs\v37\full-src-30
+ *             CLEANED
  * </pre>
- *
- * So, we're now obliged to ignore some whitespaces using the system property
- *  <code>ignoreWhitespaces</code> while running a launch config on this
- * test suite on big workspaces as full source perfs 3.0 or ganymede.
- *
- * Here are the results when setting the system property to
- * <code>linesLeading</code> (e.g. ignore white spaces at the beginning of the
- * lines, including the star inside javadoc or block comments):
- * <ul>
- * 	<li>JUnit 3.8.2 workspace (71 units):
- * 		<ul>
- * 		<li>0 error</li>
- * 		<li>0 failures</li>
- * 		<li>0 failures due to old formatter</li>
- * 		<li>8 files have different lines leading spaces</li>
- * 		<li>0 files have different spaces</li>
- *		</ul>
- *	</li>
- * 	<li>Eclipse 3.0 performance workspace (9951 units):
- * 		<ul>
- * 		<li>1 file has no output while formatting!</li>
- * 		<li>8 files have different output while reformatting twice but was expected!</li>
- * 		<li>714 files have different output while reformatting twice but only by leading whitespaces!</li>
- * 		<li>7 files have different output while reformatting twice but only by whitespaces!</li>
- *		</ul>
- *	</li>
- *	<li>Galileo workspace (41881 units):
- *		<ul>
- * 		<li>3 files have no output while formatting!</li>
- * 		<li>47 files have different output while reformatting twice!</li>
- * 		<li>2 files have different output while reformatting twice but was expected!</li>
- * 		<li>2384 files have different output while reformatting twice but only by leading whitespaces!</li>
- * 		<li>14 files have different output while reformatting twice but only by whitespaces!</li>
- *		</ul>
- *	</li>
- *	<li>JDKs workspace (29069 units):
- *		<ul>
- * 		<li>4 files have unexpected failure while formatting!</li>
- *		<li>1 file has no output while formatting!</li>
- * 		<li>115 files have different output while reformatting twice!</li>
- * 		<li>1148 files have different output while reformatting twice but only by leading whitespaces!</li>
- * 		<li>43 files have different output while reformatting twice but only by whitespaces!</li>
- *		</ul>
- *	</li>
- * </ul>
+ * Looking at the output directory, it should contain the same folders tree than
+ * the input one...
+ * </p>
+ * <h3>Create the log reference</h3>
+ * <p>
+ * The test suite log several problems which may occur while formatting a unit:
+ * 	<ul>
+ * 	<li>the file may have compilation errors preventing the formatter to proceed</li>
+ * 	<li>there's no output while formatting</li>
+ * 	<li>the output may be different while formatting twice</li>
+ * 	<li>the output may be different while formatting twice but only by leading whitespaces</li>
+ * 	<li>the output may be different while formatting twice but only by whitespaces</li>
+ *	</ul>
+ * </p><p>
+ * Even with last version of the formatter, such problems may happen on one or
+ * several tested compilation unit. So, it's important to know which are the existing
+ * issues of the used formatter version (e.g. <code>v_B11</code> in our example...).
+ * </p><p>
+ * To do this, another launch config is necessary to run the massive tests of the
+ * loaded JDT/Core version.
+ * </p><p>
+ *  For example, copy the previous launch config and rename it
+ * <b>FormatterMassiveRegressionTests (Eclipse 3.0)</b>. Change the VM 
+ * arguments as follows (<i>note that the <code>clean</code> has been removed
+ * from the <code>outputDir</code> system property</i>):
+ * <pre>
+ * -Xmx256M
+ * -DinputDir=D:\tmp\formatter\inputs\full-src-30
+ * -DoutputDir=D:\tmp\formatter\outputs
+ * -DlogDir=D:\tmp\formatter\log
+ * </pre>
+ * </p><p>
+ * Launch the config...
+ * </p><p>
+ * The log file contains the console output but also the complete list of the units
+ * on which problems were observed. As this run was done with the JDT/Core
+ * version it can be considered as the reference for this version...
+ * </p><p>
+ * Note that for our example, the observed problems for <code>v_B11</code>
+ * version while running massive tests on a Eclipse 3.0 performance workspace
+ * (9951 units) are:
+ * 	<ul>
+ * 	<li>1 file has compilation errors which prevent the formatter to proceed!</li>
+ * 	<li>4 files have different output while reformatting twice!</li>
+ * 	<li>10 files have different output while reformatting twice but only by leading whitespaces!</li>
+ * 	<li>4 files have different output while reformatting twice but only by whitespaces!</li>
+ *	</ul>
+ * </p>
+ * <h3>Run the massive tests on the patch</h3>
+ * <p>
+ * As the setup has been done for the massive tests, it's now possible to test a
+ * patch applied on the reference version (<code>v_B11</code>). For this, the
+ * patch needs of course to be applied first and also the <b>buildnotes_jdt-core.html</b>
+ * modified.
+ * </p><p>
+ * If the patch vXX of bug XXXXXX is about to be tested, then the line
+ * <code>Patch vXX for bug XXXXXX</code> needs to be added at the
+ * beginning of the first <b>What's new in this drop</b> section of the
+ * <b>buildnotes_jdt-core.html</b> file, e.g.:
+ * <pre>
+ * &lt;h2&gt;What's new in this drop&lt;/h2&gt;
+ * Patch v05 for bug 303519
+ * &lt;ul&gt;
+ * ...
+ * </pre>
+ * </p><p>
+ * Launch the <b>FormatterMassiveRegressionTests (Eclipse 3.0)</b> config...
+ * </p><p>
+ * Like the previous run, the written log file contains the complete list of the units
+ * on which problems were observed. Comparing this log file with the reference one
+ * will show whether the patch implies behavior changes for the formatter or not.
+ * </p>
  */
 public class FormatterMassiveRegressionTests extends FormatterRegressionTests {
 
@@ -201,6 +264,9 @@
 	private static File LOG_FILE;
 	private static PrintStream LOG_STREAM;
 
+	// Maintenance
+	private static boolean MAINTENANCE = false;
+
 	// Comparison
 	private static boolean CLEAN = false;
 	private static boolean CAN_COMPARE = true;
@@ -589,6 +655,8 @@
 			String token = tokenizer.nextToken();
 			if (token.equals("clean")) {
 				CLEAN = true;
+			} else if (token.equals("maintenance")) {
+				MAINTENANCE = true;
 			} else if (token.equals("list")) {
 				LIST = true;
 			} else if (token.equals("tmp")) {
@@ -818,7 +886,20 @@
 	}
 
 	// Compute the final output dir
-	OUTPUT_DIR = new File(new File(OUTPUT_DIR, ECLIPSE_VERSION), inputDir.getName());
+	File parent = new File(OUTPUT_DIR, ECLIPSE_VERSION);
+	if (MAINTENANCE) {
+		try {
+			int version = Integer.parseInt(ECLIPSE_VERSION.substring(1));
+			File maintenance = new File(OUTPUT_DIR, "v"+(version-1));
+			if (maintenance.exists()) {
+				parent = maintenance;
+			}
+		}
+		catch (NumberFormatException nfe) {
+			// skip
+		}
+	}
+	OUTPUT_DIR = new File(parent, inputDir.getName());
 }
 
 private static void initFailures() {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
index 2adaac3..b54a1b0 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
@@ -10364,7 +10364,10 @@
 		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
 		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
 		preferences.line_separator = "\n";//$NON-NLS-1$
-		preferences.insert_new_line_after_annotation_on_member = false;
+		preferences.insert_new_line_after_annotation_on_type = false;
+		preferences.insert_new_line_after_annotation_on_field = false;
+		preferences.insert_new_line_after_annotation_on_method = false;
+		preferences.insert_new_line_after_annotation_on_package = false;
 		preferences.insert_new_line_after_annotation_on_parameter = true;
 		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
 		IRegion[] regions = new IRegion[] {
@@ -10378,7 +10381,10 @@
 		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
 		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
 		preferences.line_separator = "\n";//$NON-NLS-1$
-		preferences.insert_new_line_after_annotation_on_member = false;
+		preferences.insert_new_line_after_annotation_on_type = false;
+		preferences.insert_new_line_after_annotation_on_field = false;
+		preferences.insert_new_line_after_annotation_on_method = false;
+		preferences.insert_new_line_after_annotation_on_package = false;
 		preferences.insert_new_line_after_annotation_on_parameter = false;
 		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
 		IRegion[] regions = new IRegion[] {
@@ -10393,7 +10399,10 @@
 		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
 		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
 		preferences.line_separator = "\n";//$NON-NLS-1$
-		preferences.insert_new_line_after_annotation_on_member = false;
+		preferences.insert_new_line_after_annotation_on_type = false;
+		preferences.insert_new_line_after_annotation_on_field = false;
+		preferences.insert_new_line_after_annotation_on_method = false;
+		preferences.insert_new_line_after_annotation_on_package = false;
 		preferences.insert_new_line_after_annotation_on_parameter = true;
 		preferences.insert_new_line_after_annotation_on_local_variable = false;
 		Hashtable javaCoreOptions = JavaCore.getOptions();
@@ -10419,7 +10428,10 @@
 	public void test707() {
 		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
 		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
-		preferences.insert_new_line_after_annotation_on_member = true;
+		preferences.insert_new_line_after_annotation_on_type = true;
+		preferences.insert_new_line_after_annotation_on_field = true;
+		preferences.insert_new_line_after_annotation_on_method = true;
+		preferences.insert_new_line_after_annotation_on_package = true;
 		preferences.insert_new_line_after_annotation_on_parameter = true;
 		preferences.insert_new_line_after_annotation_on_local_variable = false;
 		preferences.line_separator = "\n";//$NON-NLS-1$
@@ -10447,7 +10459,10 @@
 		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
 		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
 		preferences.line_separator = "\n";//$NON-NLS-1$
-		preferences.insert_new_line_after_annotation_on_member = true;
+		preferences.insert_new_line_after_annotation_on_type = true;
+		preferences.insert_new_line_after_annotation_on_field = true;
+		preferences.insert_new_line_after_annotation_on_method = true;
+		preferences.insert_new_line_after_annotation_on_package = true;
 		preferences.insert_new_line_after_annotation_on_parameter = false;
 		preferences.insert_new_line_after_annotation_on_local_variable = false;
 		Hashtable javaCoreOptions = JavaCore.getOptions();
@@ -10473,7 +10488,10 @@
 	public void test709() {
 		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
 		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
-		preferences.insert_new_line_after_annotation_on_member = false;
+		preferences.insert_new_line_after_annotation_on_type = false;
+		preferences.insert_new_line_after_annotation_on_field = false;
+		preferences.insert_new_line_after_annotation_on_method = false;
+		preferences.insert_new_line_after_annotation_on_package = false;
 		preferences.insert_new_line_after_annotation_on_parameter = false;
 		preferences.insert_new_line_after_annotation_on_local_variable = false;
 		preferences.line_separator = "\n";//$NON-NLS-1$
@@ -10500,7 +10518,10 @@
 	public void test710() {
 		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
 		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
-		preferences.insert_new_line_after_annotation_on_member = false;
+		preferences.insert_new_line_after_annotation_on_type = false;
+		preferences.insert_new_line_after_annotation_on_field = false;
+		preferences.insert_new_line_after_annotation_on_method = false;
+		preferences.insert_new_line_after_annotation_on_package = false;
 		preferences.insert_new_line_after_annotation_on_parameter = true;
 		preferences.insert_new_line_after_annotation_on_local_variable = true;
 		preferences.line_separator = "\n";//$NON-NLS-1$
@@ -10527,7 +10548,10 @@
 	public void test711() {
 		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
 		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
-		preferences.insert_new_line_after_annotation_on_member = false;
+		preferences.insert_new_line_after_annotation_on_type = false;
+		preferences.insert_new_line_after_annotation_on_field = false;
+		preferences.insert_new_line_after_annotation_on_method = false;
+		preferences.insert_new_line_after_annotation_on_package = false;
 		preferences.insert_new_line_after_annotation_on_parameter = false;
 		preferences.insert_new_line_after_annotation_on_local_variable = true;
 		preferences.line_separator = "\n";//$NON-NLS-1$
@@ -10726,4 +10750,173 @@
 		"}\n"
 	);
 }
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=308000
+public void test725() {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
+	String source =
+		"@Deprecated package pack;\n" + 
+		"public class Test {\n" + 
+		"    @Deprecated Test(String s) {}\n" + 
+		"    @Deprecated String label;\n" + 
+		"    @Deprecated void foo() {}\n" + 
+		"    @Deprecated interface I {}\n" + 
+		"}\n";
+	formatSource(source,
+		"@Deprecated\n" +
+		"package pack;\n" + 
+		"\n" + 
+		"public class Test {\n" + 
+		"	@Deprecated\n" + 
+		"	Test(String s) {\n" + 
+		"	}\n" + 
+		"\n" + 
+		"	@Deprecated\n" + 
+		"	String label;\n" + 
+		"\n" + 
+		"	@Deprecated\n" + 
+		"	void foo() {\n" + 
+		"	}\n" + 
+		"\n" + 
+		"	@Deprecated\n" + 
+		"	interface I {\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void test726() {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, DefaultCodeFormatterConstants.FALSE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, DefaultCodeFormatterConstants.FALSE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, DefaultCodeFormatterConstants.FALSE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, DefaultCodeFormatterConstants.FALSE);
+	String source =
+		"@Deprecated package pack;\n" + 
+		"public class Test {\n" + 
+		"    @Deprecated Test(String s) {}\n" + 
+		"    @Deprecated String label;\n" + 
+		"    @Deprecated void foo() {}\n" + 
+		"    @Deprecated interface I {}\n" + 
+		"}\n";
+	formatSource(source,
+		"@Deprecated package pack;\n" + 
+		"\n" + 
+		"public class Test {\n" + 
+		"	@Deprecated Test(String s) {\n" + 
+		"	}\n" + 
+		"\n" + 
+		"	@Deprecated String label;\n" + 
+		"\n" + 
+		"	@Deprecated void foo() {\n" + 
+		"	}\n" + 
+		"\n" + 
+		"	@Deprecated interface I {\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+
+/**
+ * @deprecated Use a deprecated formatter option.
+ */
+public void test727() {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, DefaultCodeFormatterConstants.TRUE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, DefaultCodeFormatterConstants.FALSE);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, DefaultCodeFormatterConstants.FALSE);
+	String source =
+		"@Deprecated package pack;\n" + 
+		"public class Test {\n" + 
+		"    @Deprecated Test(String s) {}\n" + 
+		"    @Deprecated String label;\n" + 
+		"    @Deprecated void foo() {}\n" + 
+		"    @Deprecated interface I {}\n" + 
+		"}\n";
+	formatSource(source,
+		"@Deprecated package pack;\n" + 
+		"\n" + 
+		"public class Test {\n" + 
+		"	@Deprecated Test(String s) {\n" + 
+		"	}\n" + 
+		"\n" + 
+		"	@Deprecated String label;\n" + 
+		"\n" + 
+		"	@Deprecated void foo() {\n" + 
+		"	}\n" + 
+		"\n" + 
+		"	@Deprecated interface I {\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+
+/**
+ * @deprecated Use a deprecated formatter option.
+ */
+public void test728() {
+	this.formatterPrefs = null;
+	this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
+	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, DefaultCodeFormatterConstants.FALSE);
+	String source =
+		"@Deprecated package pack;\n" + 
+		"public class Test {\n" + 
+		"    @Deprecated Test(String s) {}\n" + 
+		"    @Deprecated String label;\n" + 
+		"    @Deprecated void foo() {}\n" + 
+		"    @Deprecated interface I {}\n" + 
+		"}\n";
+	formatSource(source,
+		"@Deprecated package pack;\n" + 
+		"\n" + 
+		"public class Test {\n" + 
+		"	@Deprecated Test(String s) {\n" + 
+		"	}\n" + 
+		"\n" + 
+		"	@Deprecated String label;\n" + 
+		"\n" + 
+		"	@Deprecated void foo() {\n" + 
+		"	}\n" + 
+		"\n" + 
+		"	@Deprecated interface I {\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+public void testONLY_729() {
+	this.formatterPrefs = null;
+	String profilePath = getResource("profiles", "b308000.xml");
+	this.formatterOptions = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(profilePath, "b308000");
+	assertNotNull("No preferences", this.formatterOptions);
+	String source =
+		"package p;\n" + 
+		"\n" + 
+		"@Deprecated public class C {\n" + 
+		"	@Deprecated public static void main(@Deprecated String[] args) {\n" + 
+		"		@Deprecated int i= 2;\n" + 
+		"		System.out.println(i);\n" + 
+		"	}\n" + 
+		"}\n";
+	formatSource(source,
+		"package p;\n" + 
+		"\n" + 
+		"@Deprecated public class C {\n" + 
+		"	@Deprecated public static void main(@Deprecated String[] args) {\n" + 
+		"		@Deprecated\n" + 
+		"		int i = 2;\n" + 
+		"		System.out.println(i);\n" + 
+		"	}\n" + 
+		"}\n"
+	);
+}
+
 }
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 fe5c4db..b85874e 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
@@ -1938,6 +1938,12 @@
 			case IJavaElement.ANNOTATION:
 				nameRange = ((IAnnotation) element).getNameRange();
 				break;
+			case IJavaElement.PACKAGE_DECLARATION :
+				nameRange = ((IPackageDeclaration) element).getNameRange();
+				break;
+			case IJavaElement.IMPORT_DECLARATION :
+				nameRange = ((IImportDeclaration) element).getNameRange();
+				break;
 			default:
 				nameRange = ((IMember) element).getNameRange();
 				break;
@@ -2851,6 +2857,14 @@
 		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) {
 			discardWorkingCopies(this.workingCopies);
@@ -2858,6 +2872,17 @@
 		}
 		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();
@@ -2865,6 +2890,8 @@
 			"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/AbstractJavaSearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java
index 987818d..8596b7c 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java
@@ -42,10 +42,10 @@
 	public static List JAVA_SEARCH_SUITES = null;
 	protected static IJavaProject JAVA_PROJECT;
 	protected static boolean COPY_DIRS = true;
-	protected static int EXACT_RULE = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
-	protected static int EQUIVALENT_RULE = EXACT_RULE | SearchPattern.R_EQUIVALENT_MATCH;
-	protected static int ERASURE_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH;
-	protected static int RAW_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH | SearchPattern.R_EQUIVALENT_MATCH;
+	protected final static int EXACT_RULE = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
+	protected final static int EQUIVALENT_RULE = EXACT_RULE | SearchPattern.R_EQUIVALENT_MATCH;
+	protected final static int ERASURE_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH;
+	protected final static int RAW_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH | SearchPattern.R_EQUIVALENT_MATCH;
 
 //	ICompilationUnit[] workingCopies;
 //	boolean discard;
@@ -222,7 +222,7 @@
 				} else if (element instanceof ILocalVariable) {
 					this.line.append(" ");
 					ILocalVariable localVar = (ILocalVariable)element;
-					IJavaElement parent = localVar.getParent();
+					IJavaElement parent = localVar.getDeclaringMember();
 					if (parent instanceof IInitializer) {
 						IInitializer initializer = (IInitializer)parent;
 						append(initializer);
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 1b26949..385eccc 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
@@ -36,7 +36,7 @@
 */
 public class AttachSourceTests extends ModifyingResourceTests {
 	static {
-//		TESTS_NAMES = new String[] { "testClassFileBuffer" };
+//		TESTS_NAMES = new String[] { "testConstructorAccess" };
 //		TESTS_NUMBERS = new int[] { 5 };
 //		TESTS_RANGE = new int[] { 169, 180 };
 	}
@@ -127,6 +127,14 @@
 		"  }\n" +
 		"}\n" +
 		"class AType<E> {\n" + // type name containing character 'T'
+		"}",
+		"Container.java",
+		"public class Container {\n" + 
+		"	class Inner<S> {\n" + 
+		"		Inner(String st, Class<S> s) {\n" + 
+		"			super();\n" + 
+		"		}\n" + 
+		"	}\n" + 
 		"}"
 	};
 	addLibrary("generic.jar", "genericsrc.zip", pathAndContents, JavaCore.VERSION_1_5);
@@ -951,7 +959,7 @@
 }
 
 /*
- * Ensures that having a project as source attachement finds the source
+ * Ensures that having a project as source attachment finds the source
  * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=65186)
  */
 public void testProjectAsSourceAttachment() throws CoreException {
@@ -1062,7 +1070,7 @@
 	root.close();
 }
 /**
- * Attach a jar with a source attachement that doesn't contain the source folders
+ * Attach a jar with a source attachment that doesn't contain the source folders
  */
 public void testRootPath4() throws JavaModelException {
 	IJavaProject project = getJavaProject("/AttachSourceTests");
@@ -1079,7 +1087,7 @@
 	root.close();
 }
 /**
- * Attach a jar with a source attachement that doesn't contain the source folders
+ * Attach a jar with a source attachment that doesn't contain the source folders
  */
 public void testRootPath5() throws JavaModelException {
 	IJavaProject project = getJavaProject("/AttachSourceTests");
@@ -1104,7 +1112,7 @@
 	root.close();
 }
 /**
- * Attach a jar with a source attachement that doesn't contain the source folders
+ * Attach a jar with a source attachment that doesn't contain the source folders
  */
 public void testRootPath6() throws JavaModelException {
 	IJavaProject project = getJavaProject("/AttachSourceTests");
@@ -1129,7 +1137,7 @@
 	root.close();
 }
 /**
- * Attach a jar with a source attachement that doesn't contain the source folders
+ * Attach a jar with a source attachment that doesn't contain the source folders
  */
 public void testRootPath7() throws JavaModelException {
 	IJavaProject project = getJavaProject("/AttachSourceTests");
@@ -1162,7 +1170,7 @@
 	root.close();
 }
 /**
- * Attach a jar with a source attachement that contains the source folders
+ * Attach a jar with a source attachment that contains the source folders
  */
 public void testRootPath8() throws JavaModelException {
 	IJavaProject project = getJavaProject("/AttachSourceTests");
@@ -1195,7 +1203,7 @@
 	root.close();
 }
 /**
- * Attach a jar with a source attachement that contains the source folders
+ * Attach a jar with a source attachment that contains the source folders
  */
 public void testRootPath9() throws JavaModelException {
 	IJavaProject project = getJavaProject("/AttachSourceTests");
@@ -1228,7 +1236,7 @@
 	root.close();
 }
 /**
- * Attach a jar with a source attachement that is itself
+ * Attach a jar with a source attachment that is itself
  */
 public void testRootPath10() throws JavaModelException {
 	IJavaProject project = getJavaProject("/AttachSourceTests");
@@ -1279,8 +1287,8 @@
 	root.close();
 }
 /**
- * Attach a jar with a source attachement that is itself. The jar contains 2 root paths for the same class file.
- * (regression test for bug 74014 prefix path for source attachements - automatic detection does not seem to work)
+ * Attach a jar with a source attachment that is itself. The jar contains 2 root paths for the same class file.
+ * (regression test for bug 74014 prefix path for source attachments - automatic detection does not seem to work)
  */
 public void testRootPath12() throws JavaModelException {
 	IJavaProject project = getJavaProject("/AttachSourceTests");
@@ -1514,4 +1522,26 @@
 	IBuffer buffer2 = classFile.getBuffer();
 	assertTrue("Same buffer is not reused", buffer2 == buffer);
 }
+/**
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=242029
+ */
+public void testConstructorAccess() throws JavaModelException {
+	IJavaProject project = this.getJavaProject("/AttachSourceTests");
+	IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/AttachSourceTests/generic.jar"));
+	attachSource(root, "/AttachSourceTests/genericsrc.zip", null);
+	
+	IClassFile cf = root.getPackageFragment("").getClassFile("Container$Inner.class");
+	final IType type = cf.getType();
+	final IMethod[] methods = type.getMethods();
+	assertEquals("wrong size", 1, methods.length);
+	assertTrue("Not a constructor", methods[0].isConstructor());
+	assertSourceEquals(
+		"Unexpected source for generic constructor",
+		"Inner(String st, Class<S> s) {\n" + 
+		"			super();\n" + 
+		"		}",
+		methods[0].getSource());
+	attachSource(root, null, null); // detach source
+	root.close();
+}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java
index cf7c479..00121ce 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java
@@ -687,5 +687,35 @@
 			}
 			removeLibrary(this.project, "/lib/chaining.jar", null);
 		}
-	}	
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=320167
+	// Test to verify that while trying to get javadoc contents from a malformed
+	// javadoc, CharOperation doesnt throw an IOOBE
+	public void testBug320167() throws JavaModelException {
+		try {
+			setJavadocLocationAttribute("malformedDoc");
+
+			IPackageFragment packageFragment = this.root.getPackageFragment("p1.p2"); //$NON-NLS-1$
+			assertNotNull("Should not be null", packageFragment); //$NON-NLS-1$
+			IClassFile classFile = packageFragment.getClassFile("X.class"); //$NON-NLS-1$
+			assertNotNull(classFile);
+			IType type = classFile.getType();
+			IMethod method = type.getMethod("foo", new String[] {"I", "J", "Ljava.lang.String;"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			assertTrue(method.exists());
+			String javadoc = method.getAttachedJavadoc(new NullProgressMonitor()); //$NON-NLS-1$
+			assertNotNull("Should have a javadoc", javadoc); //$NON-NLS-1$
+			String[] paramNames = method.getParameterNames();
+			assertNotNull(paramNames);
+			assertEquals("Wrong size", 3, paramNames.length); //$NON-NLS-1$
+			assertEquals("Wrong name for first param", "i", paramNames[0]); //$NON-NLS-1$ //$NON-NLS-2$
+			assertEquals("Wrong name for second param", "l", paramNames[1]); //$NON-NLS-1$ //$NON-NLS-2$
+			assertEquals("Wrong name for third param", "s", paramNames[2]); //$NON-NLS-1$ //$NON-NLS-2$
+		} catch (IndexOutOfBoundsException e) {
+			assertTrue("Should not happen", false);
+		} catch (JavaModelException e) {
+			assertTrue("Should happen", true);
+		} finally {
+			setJavadocLocationAttribute(DEFAULT_DOC_FOLDER);
+		}
+	}
 }
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 f2afc82..773d552 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
@@ -21,6 +21,7 @@
 import org.eclipse.jdt.core.search.IJavaSearchConstants;
 import org.eclipse.jdt.core.search.IJavaSearchScope;
 import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.internal.core.ClasspathEntry;
 
 import junit.framework.Test;
 
@@ -1543,5 +1544,55 @@
 		assertStringsEqual("Type parameter bounds signatures", 
 							"TT;\n", typeParam.getBoundsSignatures());
 	}
+	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
+	public void testBug316937() throws Exception {
+		try {
+			IJavaProject project = getJavaProject("P");
+			String[] pathAndContents = new String[] {
+					"bug316937/Foo.java",
+					"package bug316937;\n" + "public class Foo {\n"
+							+ "	class Bar {\n"
+							+ "		public Bar(int a, int b) {}\n" + "	}\n"
+							+ "}\n" };
+			addLibrary(project, "lib316937.jar", "src316937.zip",
+					pathAndContents, JavaCore.VERSION_1_5);
+			IPackageFragmentRoot packageFragRoot = project
+					.getPackageFragmentRoot(getFile("/P/lib316937.jar"));
 
+			IType type = packageFragRoot.getPackageFragment("bug316937")
+					.getClassFile("Foo.class").getType();
+			IType subType = type.getType("Bar");
+			IMethod[] methods = subType.getMethods();
+			assertEquals("Constructros", 1, methods.length);
+			IMethod method = methods[0];
+			String[] paramNames = method.getParameterNames();
+			assertStringsEqual("Type parameter names", "a\n" + "b\n",
+					paramNames);
+
+			// Remove the source attachment
+			IClasspathEntry[] rawClasspath = project.getRawClasspath();
+			for (int index = 0; index < rawClasspath.length; index++) {
+				IClasspathEntry entry = rawClasspath[index];
+				if (entry.getPath().toString().endsWith("lib316937.jar")) {
+					((ClasspathEntry) entry).sourceAttachmentPath = null;
+				}
+			}
+			project.setRawClasspath(rawClasspath, null);
+
+			packageFragRoot = project
+					.getPackageFragmentRoot(getFile("/P/lib316937.jar"));
+			type = packageFragRoot.getPackageFragment("bug316937")
+					.getClassFile("Foo.class").getType();
+			subType = type.getType("Bar");
+			methods = subType.getMethods();
+			assertEquals("Constructros", 1, methods.length);
+			method = methods[0];
+			paramNames = method.getParameterNames();
+			assertStringsEqual("Type parameter names", "a\n" + "b\n",
+					paramNames);
+		} finally {
+			removeLibrary(getJavaProject("P"), "lib316937.jar", "src316937.zip");
+		}
+	}
+	
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
index f2797ed..1bb88fa 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
@@ -6747,5 +6747,26 @@
 		ContainerInitializer.setInitializer(null);
 	}
 }
+public void testBug321170() throws Exception {
+	try {
+		IJavaProject p = this.createJavaProject("P", new String[] {}, "bin");
+		
+		IFile file = this.createFile("/P/bin/X.java", "public class X {}");
+		
+		IClasspathEntry[] classpath = new IClasspathEntry[1];
+		classpath[0] = JavaCore.newLibraryEntry(new Path("/P/bin/X.java"), null, null);
+		setClasspath(p, classpath);
+		ICompilationUnit element = (ICompilationUnit)JavaCore.create(file, p);
+		assertNotNull("File created", element);
+	}
+	catch(ClassCastException e){
+		fail("classcast exception");
+	}
+	finally {
+		deleteProject("P");
+		ContainerInitializer.setInitializer(null);
+	}
+}
+
 
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
index 4b1509a..796ed6d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
@@ -79,6 +79,9 @@
 		"  }\n" +
 		"  X(String... s) {\n" +
 		"  }\n" +
+		"  native void foo2();\n" +
+		"  volatile void foo3() {}\n" +
+		"  strictfp void foo4() {}\n" +
 		"}\n" +
 		"/** @deprecated\n */" +
 		"interface I {\n" +
@@ -1698,8 +1701,8 @@
 public void testGetMethods() throws JavaModelException {
 	IType type = this.cu.getType("X");
 	IMethod[] methods= type.getMethods();
-	String[] methodNames = new String[] {"foo", "bar", "fred", "fred2", "testIsVarArgs", "X"};
-	String[] flags = new String[] {"public", "protected static", "private", "private", "", ""};
+	String[] methodNames = new String[] {"foo", "bar", "fred", "fred2", "testIsVarArgs", "X", "foo2", "foo3", "foo4"};
+	String[] flags = new String[] {"public", "protected static", "private", "private", "", "", "native", "volatile", "strictfp"};
 	assertEquals("Wrong number of methods returned", methodNames.length, methods.length);
 	for (int i = 0; i < methods.length; i++) {
 		assertEquals("Incorrect name for the " + i + " method", methodNames[i], methods[i].getElementName());
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java
index a2eb976..ace6a4c 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java
@@ -4002,7 +4002,6 @@
 		"expectedTypesKeys={I}\n" +
 		"completion token location=UNKNOWN\n" +
 		"visibleElements={\n" +
-		"	field1 {key=Ltest/X;.field1)I} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]],\n" +
 		"	field0 {key=Ltest/X;.field0)I} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]],\n" +
 		"	wait(long, int) {key=Ljava/lang/Object;.wait(JI)V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in "+jclPath+"]]]],\n" +
 		"	wait(long) {key=Ljava/lang/Object;.wait(J)V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in "+jclPath+"]]]],\n" +
@@ -5291,4 +5290,139 @@
 		"}",
 		result.context);
 }
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312603
+public void test0174() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[3];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src3/test/X.java",
+		"package test;\n" +
+		"import java.text.MessageFormat;\n" +
+		"public class X {\n" +
+		"    String fooBar = \"Hi\";" +
+		"	 String furchtbar= MessageFormat.format\n" +
+		"}");
+
+	String str = this.workingCopies[0].getSource();
+	int tokenStart = str.lastIndexOf("format");
+	int tokenEnd = tokenStart + "format".length() - 1;
+	int cursorLocation = str.lastIndexOf("format") + "format".length();
+
+	CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation, true, true);
+	String jclPath = getExternalJCLPathString();
+	assertResults(
+		"completion offset="+(cursorLocation)+"\n" +
+		"completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" +
+		"completion token=\"format\"\n" +
+		"completion token kind=TOKEN_KIND_NAME\n" +
+		"expectedTypesSignatures={Ljava.lang.String;}\n" +
+		"expectedTypesKeys={Ljava/lang/String;}\n" +
+		"completion token location=UNKNOWN\n" +
+		"enclosingElement=furchtbar {key=Ltest/X;.furchtbar)Ljava/lang/String;} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]]\n" +
+		"visibleElements={\n" +
+		"	fooBar {key=Ltest/X;.fooBar)Ljava/lang/String;} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]],\n" +
+		"	wait(long, int) {key=Ljava/lang/Object;.wait(JI)V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	wait(long) {key=Ljava/lang/Object;.wait(J)V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	wait() {key=Ljava/lang/Object;.wait()V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	toString() {key=Ljava/lang/Object;.toString()Ljava/lang/String;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	notifyAll() {key=Ljava/lang/Object;.notifyAll()V|Ljava/lang/IllegalMonitorStateException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	notify() {key=Ljava/lang/Object;.notify()V|Ljava/lang/IllegalMonitorStateException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	hashCode() {key=Ljava/lang/Object;.hashCode()I} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	getClass() {key=Ljava/lang/Object;.getClass()Ljava/lang/Class;} [in Object [in Object.class [in java.lang [in " + jclPath +"]]]],\n" +
+		"	finalize() {key=Ljava/lang/Object;.finalize()V|Ljava/lang/Throwable;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	equals(java.lang.Object) {key=Ljava/lang/Object;.equals(Ljava/lang/Object;)Z} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	clone() {key=Ljava/lang/Object;.clone()Ljava/lang/Object;|Ljava/lang/CloneNotSupportedException;} [in Object [in Object.class [in java.lang [in " + jclPath +"]]]],\n" +
+		"}",
+		result.context);
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312603
+public void test0175() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[3];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src3/test/X.java",
+		"package test;\n" +
+		"import java.text.MessageFormat;\n" +
+		"public class X {\n" +
+		"    String fooBar = \"Hi\";" +
+		"	 String furchtbar= new String(String.format;\n" +
+		"}");
+
+	String str = this.workingCopies[0].getSource();
+	int tokenStart = str.lastIndexOf("format");
+	int tokenEnd = tokenStart + "format".length() - 1;
+	int cursorLocation = str.lastIndexOf("format") + "format".length();
+
+	CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation, true, true);
+	String jclPath = getExternalJCLPathString();
+	assertResults(
+		"completion offset="+(cursorLocation)+"\n" +
+		"completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" +
+		"completion token=\"format\"\n" +
+		"completion token kind=TOKEN_KIND_NAME\n" +
+		"expectedTypesSignatures=null\n" +
+		"expectedTypesKeys=null\n" +
+		"completion token location=UNKNOWN\n" +
+		"enclosingElement=X {key=Ltest/X;} [in [Working copy] X.java [in test [in src3 [in Completion]]]]\n" +
+		"visibleElements={\n" +
+		"	fooBar {key=Ltest/X;.fooBar)Ljava/lang/String;} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]],\n" +
+		"	wait(long, int) {key=Ljava/lang/Object;.wait(JI)V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	wait(long) {key=Ljava/lang/Object;.wait(J)V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	wait() {key=Ljava/lang/Object;.wait()V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	toString() {key=Ljava/lang/Object;.toString()Ljava/lang/String;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	notifyAll() {key=Ljava/lang/Object;.notifyAll()V|Ljava/lang/IllegalMonitorStateException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	notify() {key=Ljava/lang/Object;.notify()V|Ljava/lang/IllegalMonitorStateException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	hashCode() {key=Ljava/lang/Object;.hashCode()I} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	getClass() {key=Ljava/lang/Object;.getClass()Ljava/lang/Class;} [in Object [in Object.class [in java.lang [in " + jclPath +"]]]],\n" +
+		"	finalize() {key=Ljava/lang/Object;.finalize()V|Ljava/lang/Throwable;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	equals(java.lang.Object) {key=Ljava/lang/Object;.equals(Ljava/lang/Object;)Z} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	clone() {key=Ljava/lang/Object;.clone()Ljava/lang/Object;|Ljava/lang/CloneNotSupportedException;} [in Object [in Object.class [in java.lang [in " + jclPath +"]]]],\n" +
+		"}",
+		result.context);
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312603
+public void test0176() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[3];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src3/test/X.java",
+		"package test;\n" +
+		"import java.text.MessageFormat;\n" +
+		"public class X {\n" +
+		"    String fooBar = \"Hi\";" +
+		"	 String furchtbar= (fooBar = new String(String.format;\n" +
+		"}");
+
+	String str = this.workingCopies[0].getSource();
+	int tokenStart = str.lastIndexOf("format");
+	int tokenEnd = tokenStart + "format".length() - 1;
+	int cursorLocation = str.lastIndexOf("format") + "format".length();
+
+	CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation, true, true);
+	String jclPath = getExternalJCLPathString();
+	assertResults(
+		"completion offset="+(cursorLocation)+"\n" +
+		"completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" +
+		"completion token=\"format\"\n" +
+		"completion token kind=TOKEN_KIND_NAME\n" +
+		"expectedTypesSignatures=null\n" +
+		"expectedTypesKeys=null\n" +
+		"completion token location=UNKNOWN\n" +
+		"enclosingElement=X {key=Ltest/X;} [in [Working copy] X.java [in test [in src3 [in Completion]]]]\n" +
+		"visibleElements={\n" +
+		"	fooBar {key=Ltest/X;.fooBar)Ljava/lang/String;} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]],\n" +
+		"	wait(long, int) {key=Ljava/lang/Object;.wait(JI)V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	wait(long) {key=Ljava/lang/Object;.wait(J)V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	wait() {key=Ljava/lang/Object;.wait()V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	toString() {key=Ljava/lang/Object;.toString()Ljava/lang/String;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	notifyAll() {key=Ljava/lang/Object;.notifyAll()V|Ljava/lang/IllegalMonitorStateException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	notify() {key=Ljava/lang/Object;.notify()V|Ljava/lang/IllegalMonitorStateException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	hashCode() {key=Ljava/lang/Object;.hashCode()I} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	getClass() {key=Ljava/lang/Object;.getClass()Ljava/lang/Class;} [in Object [in Object.class [in java.lang [in " + jclPath +"]]]],\n" +
+		"	finalize() {key=Ljava/lang/Object;.finalize()V|Ljava/lang/Throwable;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	equals(java.lang.Object) {key=Ljava/lang/Object;.equals(Ljava/lang/Object;)Z} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
+		"	clone() {key=Ljava/lang/Object;.clone()Ljava/lang/Object;|Ljava/lang/CloneNotSupportedException;} [in Object [in Object.class [in java.lang [in " + jclPath +"]]]],\n" +
+		"}",
+		result.context);
+}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
index b052f0e..01b2b75 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
@@ -20,10 +20,12 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.core.CompletionContext;
 import org.eclipse.jdt.core.CompletionProposal;
 import org.eclipse.jdt.core.CompletionRequestor;
 import org.eclipse.jdt.core.IClassFile;
+import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
@@ -37,7 +39,7 @@
 public class CompletionTests extends AbstractJavaModelCompletionTests {
 
 static {
-//	TESTS_NAMES = new String[] { "testDeprecationCheck17"};
+//	TESTS_NAMES = new String[] { "testCompletionMethodDeclaration17"};
 }
 public static Test suite() {
 	return buildModelTestSuite(CompletionTests.class);
@@ -1897,7 +1899,7 @@
 	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
 
 	assertResults(
-			"zzz[FIELD_REF]{zzz, LCompletionAfterCase1;, I, zzz, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}",
+			"zzz[FIELD_REF]{zzz, LCompletionAfterCase1;, I, zzz, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}",
 			requestor.getResults());
 }
 public void testCompletionAfterCase2() throws JavaModelException {
@@ -1921,7 +1923,7 @@
 	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
 
 	assertResults(
-			"zzz[FIELD_REF]{zzz, LCompletionAfterCase2;, I, zzz, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}",
+			"zzz[FIELD_REF]{zzz, LCompletionAfterCase2;, I, zzz, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}",
 			requestor.getResults());
 }
 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=111882
@@ -1952,13 +1954,11 @@
 	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
 
 	assertResults(
-			"ZZZ2[FIELD_REF]{ZZZ2, Ltest.CompletionAfterCase2;, J, ZZZ2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ3[FIELD_REF]{ZZZ3, Ltest.CompletionAfterCase2;, D, ZZZ3, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ4[FIELD_REF]{ZZZ4, Ltest.CompletionAfterCase2;, Ljava.lang.Object;, ZZZ4, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ5[FIELD_REF]{ZZZ5, Ltest.CompletionAfterCase2;, [I, ZZZ5, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ6[FIELD_REF]{ZZZ6, Ltest.CompletionAfterCase2;, [Ljava.lang.Object;, ZZZ6, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ7[FIELD_REF]{ZZZ7, Ltest.CompletionAfterCase2;, S, ZZZ7, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ1[FIELD_REF]{ZZZ1, Ltest.CompletionAfterCase2;, I, ZZZ1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}",
+			"ZZZ2[FIELD_REF]{ZZZ2, Ltest.CompletionAfterCase2;, J, ZZZ2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
+			"ZZZ3[FIELD_REF]{ZZZ3, Ltest.CompletionAfterCase2;, D, ZZZ3, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
+			"ZZZ4[FIELD_REF]{ZZZ4, Ltest.CompletionAfterCase2;, Ljava.lang.Object;, ZZZ4, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
+			"ZZZ7[FIELD_REF]{ZZZ7, Ltest.CompletionAfterCase2;, S, ZZZ7, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
+			"ZZZ1[FIELD_REF]{ZZZ1, Ltest.CompletionAfterCase2;, I, ZZZ1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}",
 			requestor.getResults());
 }
 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=111882
@@ -1995,13 +1995,11 @@
 	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
 
 	assertResults(
-			"ZZZ2[FIELD_REF]{ZZZ2, Ltest.TestConstants;, J, ZZZ2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ3[FIELD_REF]{ZZZ3, Ltest.TestConstants;, D, ZZZ3, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ4[FIELD_REF]{ZZZ4, Ltest.TestConstants;, Ljava.lang.Object;, ZZZ4, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ5[FIELD_REF]{ZZZ5, Ltest.TestConstants;, [I, ZZZ5, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ6[FIELD_REF]{ZZZ6, Ltest.TestConstants;, [Ljava.lang.Object;, ZZZ6, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ7[FIELD_REF]{ZZZ7, Ltest.TestConstants;, S, ZZZ7, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
-			"ZZZ1[FIELD_REF]{ZZZ1, Ltest.TestConstants;, I, ZZZ1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}",
+			"ZZZ2[FIELD_REF]{ZZZ2, Ltest.TestConstants;, J, ZZZ2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
+			"ZZZ3[FIELD_REF]{ZZZ3, Ltest.TestConstants;, D, ZZZ3, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
+			"ZZZ4[FIELD_REF]{ZZZ4, Ltest.TestConstants;, Ljava.lang.Object;, ZZZ4, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
+			"ZZZ7[FIELD_REF]{ZZZ7, Ltest.TestConstants;, S, ZZZ7, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_QUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
+			"ZZZ1[FIELD_REF]{ZZZ1, Ltest.TestConstants;, I, ZZZ1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_QUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}",
 			requestor.getResults());
 }
 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=222080
@@ -2394,8 +2392,13 @@
 	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED;
 	int start1 = str.lastIndexOf("equal") + "".length();
 	int end1 = start1 + "equal".length();
+	int start2 = str.lastIndexOf("a.equal");
+	int end2 = start2 + "a.equal".length();
+	int start3 = str.lastIndexOf("a.");
+	int end3 = start3 + "a".length();
 	assertResults(
-			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), replace["+start1+", "+end1+"], token["+start1+", "+end1+"], " + (relevance1) + "}",
+			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), replace["+start1+", "+end1+"], token["+start1+", "+end1+"], " + (relevance1) + "}\n" +
+			"equalsFoo[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)a).equalsFoo(), Ltest.CompletionAfterInstanceOf;, ()V, Ltest.CompletionAfterInstanceOf;, equalsFoo, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
 			requestor.getResults());
 }
 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=193909
@@ -2529,8 +2532,13 @@
 	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED;
 	int start1 = str.lastIndexOf("equal") + "".length();
 	int end1 = start1 + "equal".length();
+	int start2 = str.lastIndexOf("a.equal");
+	int end2 = start2 + "a.equal".length();
+	int start3 = str.lastIndexOf("a.");
+	int end3 = start3 + "a".length();
 	assertResults(
-			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), replace["+start1+", "+end1+"], token["+start1+", "+end1+"], " + (relevance1) + "}",
+			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), replace["+start1+", "+end1+"], token["+start1+", "+end1+"], " + (relevance1) + "}\n" +
+			"equalsFoo[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)a).equalsFoo(), Ltest.CompletionAfterInstanceOf;, ()V, Ltest.CompletionAfterInstanceOf;, equalsFoo, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
 			requestor.getResults());
 }
 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=193909
@@ -2559,8 +2567,13 @@
 	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED;
 	int start1 = str.lastIndexOf("equal") + "".length();
 	int end1 = start1 + "equal".length();
+	int start2 = str.lastIndexOf("a.equal");
+	int end2 = start2 + "a.equal".length();
+	int start3 = str.lastIndexOf("a.");
+	int end3 = start3 + "a".length();
 	assertResults(
-			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), replace["+start1+", "+end1+"], token["+start1+", "+end1+"], " + (relevance1) + "}",
+			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), replace["+start1+", "+end1+"], token["+start1+", "+end1+"], " + (relevance1) + "}\n" +
+			"equalsFoo[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)a).equalsFoo(), Ltest.CompletionAfterInstanceOf;, ()V, Ltest.CompletionAfterInstanceOf;, equalsFoo, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
 			requestor.getResults());
 }
 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=193909
@@ -2591,8 +2604,13 @@
 	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED;
 	int start1 = str.lastIndexOf("equal") + "".length();
 	int end1 = start1 + "equal".length();
+	int start2 = str.lastIndexOf("a.equal");
+	int end2 = start2 + "a.equal".length();
+	int start3 = str.lastIndexOf("a.");
+	int end3 = start3 + "a".length();
 	assertResults(
-			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), replace["+start1+", "+end1+"], token["+start1+", "+end1+"], " + (relevance1) + "}",
+			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), replace["+start1+", "+end1+"], token["+start1+", "+end1+"], " + (relevance1) + "}\n" +
+			"equalsFoo[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)a).equalsFoo(), Ltest.CompletionAfterInstanceOf;, ()V, Ltest.CompletionAfterInstanceOf;, equalsFoo, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
 			requestor.getResults());
 }
 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=193909
@@ -4894,7 +4912,6 @@
 
 	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
 		assertEquals(
-			"element:a    completion:a    relevance:"+(R_DEFAULT + R_RESOLVED + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
 			"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
 			"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
 			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_VOID + R_NON_RESTRICTED)+"\n" +
@@ -4912,7 +4929,6 @@
 		assertEquals(
 			"element:A    completion:A    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
 			"element:CompletionEmptyTypeName2    completion:CompletionEmptyTypeName2    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
-			"element:a    completion:a    relevance:"+(R_DEFAULT + R_RESOLVED + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
 			"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
 			"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
 			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_VOID + R_NON_RESTRICTED)+"\n" +
@@ -4954,8 +4970,7 @@
 			"element:toString    completion:toString()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
 			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
 			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
-			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
-			"element:x    completion:x    relevance:"+(R_DEFAULT + R_RESOLVED + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED),
+			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
 			requestor.getResults());
 	} else {
 		assertEquals(
@@ -4974,8 +4989,7 @@
 			"element:toString    completion:toString()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
 			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_VOID + R_NON_RESTRICTED)+"\n" +
 			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_VOID + R_NON_RESTRICTED)+"\n" +
-			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_VOID + R_NON_RESTRICTED)+"\n" +
-			"element:x    completion:x    relevance:"+(R_DEFAULT + R_RESOLVED + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED),
+			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_VOID + R_NON_RESTRICTED),
 			requestor.getResults());
 	}
 }
@@ -8333,7 +8347,6 @@
 			"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
 			"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
 			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
-			"test[FIELD_REF]{test, Ltest.Test;, Z, test, null, " + (R_DEFAULT + R_RESOLVED + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
 			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
 			"false[KEYWORD]{false, null, null, false, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED) + "}\n" +
 			"true[KEYWORD]{true, null, null, true, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED) + "}",
@@ -12594,6 +12607,41 @@
 			"doSomething[METHOD_DECLARATION]{protected other.SuperClass2.Sub doSomething(), Lother.SuperClass2;, ()Lother.SuperClass2$Sub;, doSomething, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
 			requestor.getResults());
 }
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=325270
+public void testCompletionMethodDeclaration17() throws JavaModelException {
+	// add the needed jar on the classpath
+	IClasspathEntry[] classpath = this.currentProject.getRawClasspath();
+	try {
+		final int length = classpath.length;
+		IClasspathEntry[] newClasspath = new IClasspathEntry[length + 1];
+		System.arraycopy(classpath, 0, newClasspath, 1, length);
+		newClasspath[0] = JavaCore.newLibraryEntry(new Path("/Completion/bug325270.jar"), null, null);
+		this.currentProject.setRawClasspath(newClasspath, null);
+	
+		this.wc = getWorkingCopy(
+				"/Completion/src/CompletionMethodDeclaration17.java",
+				"class CompletionMethodDeclaration17 {\n" + 
+				"	void test() {\n" + 
+				"		new pkg.Foo1.Bar1(\n" + 
+				"	}\n" + 
+				"}" +
+		"}");
+	
+	
+		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+		String str = this.wc.getSource();
+		String completeBehind = "new pkg.Foo1.Bar1(";
+		int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+		this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
+	
+		assertResults(
+				"Bar1[METHOD_REF<CONSTRUCTOR>]{, Lpkg.Foo1$Bar1;, (II)V, Bar1, (a, b), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED)+ "}\n" +
+				"Foo1.Bar1[ANONYMOUS_CLASS_DECLARATION]{, Lpkg.Foo1$Bar1;, (II)V, null, (a, b), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED)+"}",
+				requestor.getResults());
+	} finally {
+		this.currentProject.setRawClasspath(classpath, null);
+	}
+}
 public void testCompletionMethodDeclaration2() throws JavaModelException {
 	ICompilationUnit superClass = null;
 	try {
@@ -21333,4 +21381,356 @@
 			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, replace[" + start1 + ", " + end1 + "], token[" + start1 + ", " + end1 +"], " + relevance1 + "}",
 			requestor.getResults());
 }
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310427
+// To verify that we don't get proposals for fields that have not yet been declared
+// inside a field declaration statement
+public void testBug310427a() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/test/Test.java",
+		"package test;"+
+		"public class Test {\n" +
+		"       int myVar1 = 1;\n" +
+		"		int myVar2 = 1;\n" +
+		"		int myVar3 = myVar;\n" +
+		"       int myVar4 = 1;\n" +
+		"		int myVar5 = 1;\n" +
+		"	}\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "int myVar3 = myVar";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	assertResults(
+			"myVar1[FIELD_REF]{myVar1, Ltest.Test;, I, myVar1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
+			"myVar2[FIELD_REF]{myVar2, Ltest.Test;, I, myVar2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}",
+			requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310427
+// To verify that we don't get proposals for the local variable in whose declaration
+// content assist is being invoked
+public void testBug310427b() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/test/Test.java",
+		"package test;"+
+		"public class Test {\n" +
+		"	public static void main() {\n" +
+		"		int myVar1 = 1;\n" +
+		"		int myVar2 = myVar;\n" +
+		"	}\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "int myVar2 = myVar";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	assertResults(
+			"myVar1[LOCAL_VARIABLE_REF]{myVar1, null, I, myVar1, null, 57}",
+			requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
+// To verify that array types aren't proposed inside case, and also
+// that finals have a higher priority in suggestions inside case expressions.
+public void testBug195346a() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/test/CompletionAfterCase2.java",
+		"package test;\n" +
+		"public class CompletionAfterCase2 {\n" +
+		"	static char[] AN_ARRAY = new char[10];\n" +
+		"	static int AN_INT_VALUE = 0;\n" +
+		"	static final int AN_INT_VALUE2 = 0;\n" +
+		"	static final char[] AN_ARRAY2 = {'a','b'};\n" +
+		"	static final int[] AN_INT_ARRAY = null;\n" +
+		"	static final Object[] ANOTHER_ARRAY = null;\n" +
+		"	void foo(int i, final int [] AN_ARRAY_PARAM){\n" +
+		"		final int AN_INT_VAR = 1;\n" +
+		"		final int[] AN_ARRAY_VAR = {1};\n" +
+		"		int AN_INT_VAR2 = 1;\n" +
+		"		switch(i) {\n" +
+		"			case AN\n" +
+		"		}\n" +
+		"	}\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "AN";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	assertResults(
+			"AN_INT_VALUE[FIELD_REF]{AN_INT_VALUE, Ltest.CompletionAfterCase2;, I, AN_INT_VALUE, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
+			"AN_INT_VAR2[LOCAL_VARIABLE_REF]{AN_INT_VAR2, null, I, AN_INT_VAR2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
+			"AN_INT_VALUE2[FIELD_REF]{AN_INT_VALUE2, Ltest.CompletionAfterCase2;, I, AN_INT_VALUE2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE + R_FINAL) + "}\n" +
+			"AN_INT_VAR[LOCAL_VARIABLE_REF]{AN_INT_VAR, null, I, AN_INT_VAR, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE + R_FINAL) + "}",
+			requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
+// To verify that array types aren't proposed inside case, and also
+// that finals have a higher priority in suggestions inside case expressions.
+public void testBug195346b() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/test/CompletionAfterCase2.java",
+		"package test;\n" +
+		"public class CompletionAfterCase2 {\n" +
+		"	class AN_INNER_CLASS {\n" +
+		"		static final int abc = 1;\n" +
+		"	}\n" +
+		"	static char[] AN_ARRAY = new char[10];\n" +
+		"	static int AN_INT_VALUE = 0;\n" +
+		"	static final int AN_INT_VALUE2 = 0;\n" +
+		"	static final char[] AN_ARRAY2 = {'a','b'};\n" +
+		"	static final int[] AN_INT_ARRAY = null;\n" +
+		"	static final Object[] ANOTHER_ARRAY = null;\n" +
+		"	void foo(int i, final int [] AN_ARRAY_PARAM){\n" +
+		"		final int AN_INT_VAR = 1;\n" +
+		"		final int[] AN_ARRAY_VAR = {1};\n" +
+		"		int AN_INT_VAR2 = 1;\n" +
+		"		switch(i) {\n" +
+		"			case CompletionAfterCase2.AN\n" +
+		"		}\n" +
+		"	}\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "AN";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	assertResults(
+			"CompletionAfterCase2.AN_INNER_CLASS[TYPE_REF]{AN_INNER_CLASS, test, Ltest.CompletionAfterCase2$AN_INNER_CLASS;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
+			"AN_INT_VALUE[FIELD_REF]{AN_INT_VALUE, Ltest.CompletionAfterCase2;, I, AN_INT_VALUE, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
+			"AN_INT_VALUE2[FIELD_REF]{AN_INT_VALUE2, Ltest.CompletionAfterCase2;, I, AN_INT_VALUE2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE + R_FINAL) + "}",
+			requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=304006
+// To verify that autocast works correctly after an instanceof even if there are other expressions in between
+// instanceof and the place where code assist is requested.
+public void testBug304006a() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/test/CompletionAfterInstanceOf.java",
+		"package test;\n" +
+		"public class CompletionAfterInstanceOf {\n" +
+		"	public int foo() { return 1; }\n" +
+		"	public int returnZero(){ return 0;}\n" +
+		"	void bar(Object a){\n" +
+		"       int i = 1;\n" +
+		"		if (a instanceof CompletionAfterInstanceOf) {" +
+		"			if (i == 1)\n" +
+		"				i =  a.r\n" +
+		"	}\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
+	requestor.allowAllRequiredProposals();
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "a.r";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE;
+	int start1 = str.lastIndexOf("r") + "".length();
+	int end1 = start1 + "r".length();
+	int start2 = str.lastIndexOf("a.r");
+	int end2 = start2 + "a.r".length();
+	int start3 = str.lastIndexOf("a.");
+	int end3 = start3 + "a".length();
+	
+	assertResults(
+			"expectedTypesSignatures={I}\n" +
+			"expectedTypesKeys={I}",
+			requestor.getContext());
+	assertResults(
+			"returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)a).returnZero(), Ltest.CompletionAfterInstanceOf;, ()I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
+			requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=304006
+// To verify that autocast works correctly after an instanceof even if there are other expressions in between
+// instanceof and the place where code assist is requested.
+public void testBug304006b() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/test/CompletionAfterInstanceOf.java",
+		"package test;\n" +
+		"public class CompletionAfterInstanceOf {\n" +
+		"	public int foo() { return 1; }\n" +
+		"	public int returnZero(){ return 0;}\n" +
+		"	void bar(Object a){\n" +
+		"       int i = 1;\n" +
+		"		if (a instanceof CompletionAfterInstanceOf) {" +
+		"			if (i == 1)\n" +
+		"				a.r\n" +
+		"	}\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
+	requestor.allowAllRequiredProposals();
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "a.r";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED;
+	int start1 = str.lastIndexOf("r") + "".length();
+	int end1 = start1 + "r".length();
+	int start2 = str.lastIndexOf("a.r");
+	int end2 = start2 + "a.r".length();
+	int start3 = str.lastIndexOf("a.");
+	int end3 = start3 + "a".length();
+	
+	assertResults(
+			"returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)a).returnZero(), Ltest.CompletionAfterInstanceOf;, ()I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
+			requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=304006
+// To verify that autocast works correctly even when the completion node
+// is preceeded by a number of unrelated instanceof expressions
+public void testBug304006c() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/test/CompletionAfterInstanceOf.java",
+		"package test;\n" +
+		"public class CompletionAfterInstanceOf {\n" +
+		"	public int foo() { return 1; }\n" +
+		"	public int returnZero(){ return 0;}\n" +
+		"	void bar(Object abc, Object xyz){\n" +
+		"       int i = 1, j;\n" +
+		"		if(i == 1)\n" +
+		"			if (abc instanceof CompletionAfterInstanceOf)\n" +
+		"				if(xyz instanceof CompletionAfterInstanceOf){\n" +
+		"					j = 1;\n" +
+		"					if(j == 1)\n" +
+		"						i = abc.r \n" +
+		"				}\n" +
+		"	}\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
+	requestor.allowAllRequiredProposals();
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "abc.r";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE;
+	int start1 = str.lastIndexOf("r") + "".length();
+	int end1 = start1 + "r".length();
+	int start2 = str.lastIndexOf("abc.r");
+	int end2 = start2 + "abc.r".length();
+	int start3 = str.lastIndexOf("abc.");
+	int end3 = start3 + "abc".length();
+	
+	assertResults(
+			"expectedTypesSignatures={I}\n" +
+			"expectedTypesKeys={I}",
+			requestor.getContext());
+	assertResults(
+			"returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)abc).returnZero(), Ltest.CompletionAfterInstanceOf;, ()I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
+			requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=304006
+// To verify that autocast works correctly even when the completion node is preceeded by a number 
+// of unrelated instanceof expressions. This case has errors in compilation unit. 
+public void testBug304006d() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/test/CompletionAfterInstanceOf.java",
+		"package test;\n" +
+		"public class CompletionAfterInstanceOf {\n" +
+		"	public int foo() { return 1; }\n" +
+		"	public int returnZero(){ return 0;}\n" +
+		"	void bar(Object abc, Object xyz){\n" +
+		"       int i = 1, j;\n" +
+		"		j = \n" +
+		"		if(i == 1)\n" +
+		"			if (abc instanceof CompletionAfterInstanceOf)\n" +
+		"				if(xyz instanceof CompletionAfterInstanceOf){\n" +
+		"					j = 1;\n" +
+		"					if(j == 1)\n" +
+		"						xyz.r \n" +
+		"				}\n" +
+		"	}\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
+	requestor.allowAllRequiredProposals();
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "xyz.r";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED;
+	int start1 = str.lastIndexOf("r") + "".length();
+	int end1 = start1 + "r".length();
+	int start2 = str.lastIndexOf("xyz.r");
+	int end2 = start2 + "xyz.r".length();
+	int start3 = str.lastIndexOf("xyz.");
+	int end3 = start3 + "xyz".length();
+	
+	assertResults(
+			"returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)xyz).returnZero(), Ltest.CompletionAfterInstanceOf;, ()I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
+			requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=304006
+// To verify that autocast works correctly after an instanceof even if there are other expressions in between
+// instanceof and the place where code assist is requested. This is a case with errors in the compilation unit.
+public void testBug304006e() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/test/CompletionAfterInstanceOf.java",
+		"package test;\n" +
+		"public class CompletionAfterInstanceOf {\n" +
+		"	public int foo() { return 1; }\n" +
+		"	public int returnZero(){ return 0;}\n" +
+		"	void bar(Object a){\n" +
+		"       int i = 1;\n" +
+		"       int i = \n" +
+		"		if (a instanceof CompletionAfterInstanceOf) {" +
+		"			if (i == 1)\n" +
+		"				i =  a.r\n" +
+		"	}\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
+	requestor.allowAllRequiredProposals();
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "a.r";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE;
+	int start1 = str.lastIndexOf("r") + "".length();
+	int end1 = start1 + "r".length();
+	int start2 = str.lastIndexOf("a.r");
+	int end2 = start2 + "a.r".length();
+	int start3 = str.lastIndexOf("a.");
+	int end3 = start3 + "a".length();
+	
+	assertResults(
+			"expectedTypesSignatures={I}\n" +
+			"expectedTypesKeys={I}",
+			requestor.getContext());
+	assertResults(
+			"returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)a).returnZero(), Ltest.CompletionAfterInstanceOf;, ()I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
+			requestor.getResults());
+}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java
index 25ec44b..a067924 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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,9 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 
+import junit.framework.ComparisonFailure;
+import junit.framework.Test;
+
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -41,8 +44,6 @@
 import org.eclipse.jdt.internal.core.JavaModelManager;
 import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
 
-import junit.framework.*;
-
 public class CompletionTests2 extends ModifyingResourceTests implements RelevanceConstants {
 
 	public static class CompletionContainerInitializer implements ContainerInitializer.ITestInitializer {
@@ -5284,4 +5285,310 @@
 		deleteProject("P");
 	}
 }
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500
+public void testBug151500a() throws Exception {
+	try {
+		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4");
+		createJar(
+				new String[] {
+						"foo/Foo.java",
+						"package foo;\n" +
+						"public class Foo {\n"+
+						"  public Foo(int p1) {}\n"+
+						"  public Bar bar = new Bar(1,2);\n"+
+						"  public class Bar {\n" +
+						"    int param1;\n" +
+						"	 int param2;\n" +
+						"	 public Bar (int a, int b) {\n" +
+						"		param1 = a;\n" +
+						"		param2 = b;\n" +
+						"	 }\n" +
+						"	 public void someMethod(String paramName) {}\n"+
+						"  }\n"+
+						"}"
+				},
+				p.getProject().getLocation().append("lib151500.jar").toOSString(),
+				new String[]{getExternalJCLPathString("1.3")},
+				"1.3");
+		
+		refresh(p);
+		
+		waitUntilIndexesReady();
+		
+		this.workingCopies = new ICompilationUnit[1];
+		this.workingCopies[0] = getWorkingCopy(
+				"/P/src/test/Test.java",
+				"package test;\n"+
+				"public class Test {\n" +
+				"  void m() {\n" +
+				"    foo.Foo f = new Foo(1);\n" +
+				"	 f.bar.s\n" +
+				"  }\n" +
+				"}");
+
+		// do completion
+		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
+		requestor.allowAllRequiredProposals();
+		NullProgressMonitor monitor = new NullProgressMonitor();
+
+	    String str = this.workingCopies[0].getSource();
+	    String completeBehind = "f.bar.s";
+	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
+	    
+	    assertResults(
+			"someMethod[METHOD_REF]{someMethod(), Lfoo.Foo$Bar;, (Ljava.lang.String;)V, someMethod, (paramName), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_STATIC)+ "}",
+			requestor.getResults());
+	} finally {
+		deleteProject("P");
+	}
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500
+public void testBug151500b() throws Exception {	
+	try {
+		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4");
+		createJar(
+				new String[] {
+						"foo/Foo.java",
+						"package foo;\n" +
+						"public class Foo {\n"+
+						"  public Foo(int p1) {}\n"+
+						"  public Bar bar = new Bar(1,2);\n"+
+						"  public class Bar {\n" +
+						"    int param1;\n" +
+						"	 int param2;\n" +
+						"	 public Bar (int a, int b) {\n" +
+						"		param1 = a;\n" +
+						"		param2 = b;\n" +
+						"	 }\n" +
+						"	 public void someMethod(String paramName) {}\n"+
+						"  }\n"+
+						"}"
+				},
+				p.getProject().getLocation().append("lib151500.jar").toOSString(),
+				new String[]{getExternalJCLPathString("1.3")},
+				"1.3");
+		
+		refresh(p);
+		
+		waitUntilIndexesReady();
+		
+		this.workingCopies = new ICompilationUnit[1];
+		this.workingCopies[0] = getWorkingCopy(
+				"/P/src/test/Test.java",
+				"package test;\n"+
+				"public class Test {\n" +
+				"  void m() {\n" +
+				"    new foo.Foo(1).new B;\n" +
+				"  }\n" +
+				"}");
+
+		// do completion
+		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
+		requestor.allowAllRequiredProposals();
+		NullProgressMonitor monitor = new NullProgressMonitor();
+
+	    String str = this.workingCopies[0].getSource();
+	    String completeBehind = "new foo.Foo(1).new B";
+	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
+	    
+	    assertResults(
+	    		"Bar[CONSTRUCTOR_INVOCATION]{(), Lfoo.Foo$Bar;, (II)V, Bar, (a, b), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}\n" +
+	    		"   Foo.Bar[TYPE_REF]{Bar, foo, Lfoo.Foo$Bar;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}",
+			requestor.getResults());
+	} finally {
+		deleteProject("P");
+	}
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500
+public void testBug151500c() throws Exception {	
+	try {
+		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4");
+		createJar(
+				new String[] {
+						"foo/Foo.java",
+						"package foo;\n" +
+						"public class Foo {\n"+
+						"  public Foo(int p1) {}\n"+
+						"  public Bar bar = new Bar(1,2);\n"+
+						"  public class Bar {\n" +
+						"    int param1;\n" +
+						"	 int param2;\n" +
+						"	 public Bar (int a, int b) {\n" +
+						"		param1 = a;\n" +
+						"		param2 = b;\n" +
+						"	 }\n" +
+						"	 public void someMethod(String paramName) {}\n"+
+						"  }\n"+
+						"}"
+				},
+				p.getProject().getLocation().append("lib151500.jar").toOSString(),
+				new String[]{getExternalJCLPathString("1.3")},
+				"1.3");
+		
+		refresh(p);
+		
+		waitUntilIndexesReady();
+		
+		this.workingCopies = new ICompilationUnit[1];
+		this.workingCopies[0] = getWorkingCopy(
+				"/P/src/test/Test.java",
+				"package test;\n"+
+				"public class Test {\n" +
+				"  void m() {\n" +
+				"    new foo.Foo.B;\n" +
+				"  }\n" +
+				"}");
+
+		// do completion
+		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
+		requestor.allowAllRequiredProposals();
+		NullProgressMonitor monitor = new NullProgressMonitor();
+
+	    String str = this.workingCopies[0].getSource();
+	    String completeBehind = "new foo.Foo.B";
+	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
+	    
+	    assertResults(
+	    		"Bar[CONSTRUCTOR_INVOCATION]{(), Lfoo.Foo$Bar;, (II)V, Bar, (a, b), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
+	    		"   Foo.Bar[TYPE_REF]{Bar, foo, Lfoo.Foo$Bar;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
+			requestor.getResults());
+	} finally {
+		deleteProject("P");
+	}
+}
+// types in enum package of org.apache.commons.lang.jar should not be proposed for
+// 1.5 projects. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=317264
+public void testBug317264a() throws CoreException {
+	IJavaProject project = null;
+	try
+	{
+		project = createJavaProject("P2", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/Completion/b317264/org.apache.commons.lang_2.modified.jar"), null, null));
+		
+		createFile(
+				"/P2/X.java",
+				"import org.apache.commons.lang.*;\n"+
+				"public class X {\n"+
+				"  public void foo() {\n"+
+				"    enu\n"+
+				"  }\n"+
+				"}");
+		waitUntilIndexesReady();
+		
+		ICompilationUnit cu= getCompilationUnit("P2", "", "", "X.java");
+
+		String str = cu.getSource();
+		String completeBehind = "enu";
+		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
+		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+		cu.codeComplete(cursorLocation, requestor);
+		assertResults(
+				"Enum[TYPE_REF]{Enum, java.lang, Ljava.lang.Enum;, null, null, 17}",
+				requestor.getResults());
+				
+	} finally {
+		deleteProject(project);
+	}
+}
+// types in enum package of org.apache.commons.lang.jar should be proposed for 1.4 projects
+public void testBug317264b() throws CoreException {
+	IJavaProject project = null;
+	try
+	{
+		project = createJavaProject("P2");
+		addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/Completion/b317264/org.apache.commons.lang_2.modified.jar"), null, null));
+		
+		createFile(
+				"/P2/X.java",
+				"import org.apache.commons.lang.*;\n"+
+				"public class X {\n"+
+				"  public void foo() {\n"+
+				"    enu\n"+
+				"  }\n"+
+				"}");
+		waitUntilIndexesReady();
+		
+		ICompilationUnit cu= getCompilationUnit("P2", "", "", "X.java");
+
+		String str = cu.getSource();
+		String completeBehind = "enu";
+		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
+		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+		cu.codeComplete(cursorLocation, requestor);
+		assertResults(
+				"Enum[TYPE_REF]{org.apache.commons.lang.enum.Enum, org.apache.commons.lang.enum, Lorg.apache.commons.lang.enum.Enum;, null, null, 14}",
+				requestor.getResults());
+				
+	} finally {
+		deleteProject(project);
+	}
+}
+// enum package of org.apache.commons.lang.jar should not be proposed for 1.5 projects
+public void testBug317264c() throws CoreException {
+	IJavaProject project = null;
+	try
+	{
+		project = createJavaProject("P2", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/Completion/b317264/org.apache.commons.lang_2.modified.jar"), null, null));
+		
+		createFile(
+				"/P2/X.java",
+				"import org.apache.commons.lang.enu;\n"+
+				"public class X {\n"+
+				"  public void foo() {\n"+   
+				"  }\n"+
+				"}");
+		waitUntilIndexesReady();
+		
+		ICompilationUnit cu= getCompilationUnit("P2", "", "", "X.java");
+
+		String str = cu.getSource();
+		String completeBehind = "lang.enu";
+		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
+		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+		cu.codeComplete(cursorLocation, requestor);
+		assertResults("", requestor.getResults());
+				
+	} finally {
+		deleteProject(project);
+	}
+}
+// enum package of org.apache.commons.lang.jar should be proposed for 1.4 projects
+public void testBug317264d() throws CoreException {
+	IJavaProject project = null;
+	try
+	{
+		project = createJavaProject("P2");
+		addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/Completion/b317264/org.apache.commons.lang_2.modified.jar"), null, null));
+		
+		createFile(
+				"/P2/X.java",
+				"import org.apache.commons.lang.enu;\n"+
+				"public class X {\n"+
+				"  public void foo() {\n"+   
+				"  }\n"+
+				"}");
+		waitUntilIndexesReady();
+		
+		ICompilationUnit cu= getCompilationUnit("P2", "", "", "X.java");
+
+		String str = cu.getSource();
+		String completeBehind = "lang.enu";
+		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
+		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+		cu.codeComplete(cursorLocation, requestor);
+		assertResults(
+				"org.apache.commons.lang.enum[PACKAGE_REF]{org.apache.commons.lang.enum.*;, org.apache.commons.lang.enum, null, null, null, 24}",
+				requestor.getResults());
+				
+	} finally {
+		deleteProject(project);
+	}
+}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
index 2850760..8328189 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
@@ -6602,7 +6602,6 @@
 	            result.context);
 
 	    assertResults(
-	            "ZZType.ZZAnnotation[TYPE_REF]{p.ZZType.ZZAnnotation, p, Lp.ZZType$ZZAnnotation;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_INTERFACE + R_NON_RESTRICTED) + "}\n" +
 				"ZZType.ZZInterface[TYPE_REF]{p.ZZType.ZZInterface, p, Lp.ZZType$ZZInterface;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_INTERFACE + R_NON_RESTRICTED) + "}",
 	            result.proposals);
 	} finally {
@@ -13815,4 +13814,60 @@
 			"\ud842\udf9fabc[LABEL_REF]{\ud842\udf9fabc, null, null, \ud842\udf9fabc, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
 			requestor.getResults());
 }
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423
+// Annotation types are not proposed after 'implements' in a Single type ref
+public void testBug310423a() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/label/Test.java",
+		"import java.lang.annotation.Annotation;\n" +
+		"interface In {}\n" +
+		"interface Inn {\n" +
+		"	interface Inn2 {}\n" +
+		"	@interface IAnnot {}\n" +
+		"}\n" +
+		"@interface InnAnnot {}\n"+
+		"public class Test implements {\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "implements";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length() + 1;
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	assertResults(
+			"Inn.Inn2[TYPE_REF]{label.Inn.Inn2, label, Llabel.Inn$Inn2;, null, null, 44}\n" +
+			"In[TYPE_REF]{In, label, Llabel.In;, null, null, 47}\n" +
+			"Inn[TYPE_REF]{Inn, label, Llabel.Inn;, null, null, 47}",
+			requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423
+// Annotation types are not proposed after 'implements' in a Qualified type ref
+public void testBug310423b() throws JavaModelException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy(
+		"/Completion/src/label/Test.java",
+		"interface In{}\n" +
+		"interface Inn{\n" +
+		"	interface Inn2{}\n" +
+		"	interface Inn3{}\n" +
+		"	@interface IAnnot {}\n" +
+		"}"+
+		"public class Test implements Inn. {\n" +
+		"}\n");
+
+	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+	String str = this.workingCopies[0].getSource();
+	String completeBehind = "Inn.";
+	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length() + 1;
+	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+	assertResults(
+			"Inn.Inn2[TYPE_REF]{Inn2, label, Llabel.Inn$Inn2;, null, null, 44}\n" +
+			"Inn.Inn3[TYPE_REF]{Inn3, label, Llabel.Inn$Inn3;, null, null, 44}",
+			requestor.getResults());
+}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java
index 802967d..9641efb 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -476,6 +476,75 @@
 	}
 
 	/*
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=150980
+	 */
+	public void testNameRange09() throws CoreException { // was testNameRangeAnonymous
+		try {
+			String cuSource =
+				"package p . q . r. s ;\n" +
+				"public class Y {\n" +
+				"  void foo() {\n" +
+				"    Y y = new Y() {};\n" +
+				"    class C {\n" +
+				"    }\n"+
+				"  }\n" +
+				"}";
+			createFolder("/P/p/q/r/s/");
+			createFile("/P/p/q/r/s/Y.java", cuSource);
+			final IPackageDeclaration[] packageDeclarations = getCompilationUnit("/P/p/q/r/s/Y.java").getPackageDeclarations();
+			assertEquals("Wrong size", 1, packageDeclarations.length);
+
+			String actualSource = getNameSource(cuSource, packageDeclarations[0]);
+			String expectedSource = "p . q . r. s";
+			assertSourceEquals("Unexpected source'", expectedSource, actualSource);
+		} finally {
+			deleteFile("/P/p/q/r/s/Y.java");
+		}
+	}
+
+	/*
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=150980
+	 */
+	public void testNameRange10() throws CoreException { // was testNameRangeAnonymous
+		try {
+			String cuSource =
+				"import java . lang . * ;\n" +
+				"public class Y {\n" +
+				"}";
+			createFile("/P/Y.java", cuSource);
+			final IImportDeclaration[] imports = getCompilationUnit("/P/Y.java").getImports();
+			assertEquals("Wrong size", 1, imports.length);
+
+			String actualSource = getNameSource(cuSource, imports[0]);
+			String expectedSource = "java . lang . *";
+			assertSourceEquals("Unexpected source'", expectedSource, actualSource);
+		} finally {
+			deleteFile("/P/Y.java");
+		}
+	}
+
+	/*
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=150980
+	 */
+	public void testNameRange11() throws CoreException { // was testNameRangeAnonymous
+		try {
+			String cuSource =
+				"import java . lang  .  Object  ;\n" +
+				"public class Y {\n" +
+				"}";
+			createFile("/P/Y.java", cuSource);
+			final IImportDeclaration[] imports = getCompilationUnit("/P/Y.java").getImports();
+			assertEquals("Wrong size", 1, imports.length);
+
+			String actualSource = getNameSource(cuSource, imports[0]);
+			String expectedSource = "java . lang  .  Object";
+			assertSourceEquals("Unexpected source'", expectedSource, actualSource);
+		} finally {
+			deleteFile("/P/Y.java");
+		}
+	}
+
+	/*
 	 * Ensures that the source range for an annotation on a local variable is correct.
 	 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=209823)
 	 */
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 cf2f540..fd6ef0d 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
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     Stephan Herrmann <stephan@cs.tu-berlin.de> - inconsistent initialization of classpath container backed by external class folder, see https://bugs.eclipse.org/320618
  *******************************************************************************/
 package org.eclipse.jdt.core.tests.model;
 
@@ -35,6 +36,9 @@
 public JavaProjectTests(String name) {
 	super(name);
 }
+static {
+//	TESTS_NAMES = new String[] { "testAddExternalLibFolder6" };
+}
 public static Test suite() {
 	TestSuite suite = (TestSuite) buildModelTestSuite(JavaProjectTests.class);
 
@@ -170,6 +174,71 @@
 }
 
 /*
+ * Ensures that a type from a classpath container pointing to an external folder can be resolved
+ * Bug 320618 -  inconsistent initialization of classpath container backed by external class folder
+ */
+public void testAddExternalLibFolder6() throws CoreException, IOException {
+	IWorkspace workspace = null;
+	try {
+		simulateExitRestart();
+
+		// create a class folder outside the testing workspace:
+		createExternalFolder("TestContainer/p");
+		workspace = ResourcesPlugin.getWorkspace();
+		File workspaceLocation = new File(workspace.getRoot().getLocation().toOSString());
+		File classFileSrc = new File(workspaceLocation, "JavaProjectLibTests/lib/p/Y.class");
+		File classFileDst = new File(workspaceLocation.getParentFile().getCanonicalFile(), "TestContainer/p/Y.class"); // canonicalize the external path as this is not done on case sensitive platforms when creating a new lib entry
+		copy(classFileSrc, classFileDst);
+
+		// setup a project depending on the classpath container:
+		IJavaProject javaProject = setUpJavaProject("ExternalContainer");
+		IProject p = javaProject.getProject();
+		
+		// build should find no errors:
+		p.build(IncrementalProjectBuilder.FULL_BUILD, null);
+		IMarker[] markers = p.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
+		for (int i=0; i<markers.length; i++)
+			System.out.println("unexpected marker: "+markers[i].getType()+": "+markers[i].getAttribute(IMarker.MESSAGE));
+		assertEquals("Unexpected markers", markers.length, 0);
+		
+	} finally {
+		deleteExternalResource("TestContainer");
+		deleteProject("ExternalContainer");
+	}
+	workspace.save(true, null);
+	// second go most be unaffected by previously used external links:
+	// (tests ExternalFoldersManager.cleanUp())
+	try {
+		// *don't* reset: simulateExitRestart();
+
+		// from hereon same as before:
+
+		// create a class folder outside the testing workspace:
+		createExternalFolder("TestContainer/p");
+		workspace = ResourcesPlugin.getWorkspace();
+		File workspaceLocation = new File(workspace.getRoot().getLocation().toOSString());
+		File classFileSrc = new File(workspaceLocation, "JavaProjectLibTests/lib/p/Y.class");
+		File classFileDst = new File(workspaceLocation.getParentFile().getCanonicalFile(), "TestContainer/p/Y.class"); // canonicalize the external path as this is not done on case sensitive platforms when creating a new lib entry
+		copy(classFileSrc, classFileDst);
+
+		// setup a project depending on the classpath container:
+		IJavaProject javaProject = setUpJavaProject("ExternalContainer");
+		IProject p = javaProject.getProject();
+		
+		// build should find no errors:
+		p.build(IncrementalProjectBuilder.FULL_BUILD, null);
+		IMarker[] markers = p.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
+		for (int i=0; i<markers.length; i++)
+			System.out.println("unexpected marker: "+markers[i].getType()+": "+markers[i].getAttribute(IMarker.MESSAGE));
+		assertEquals("Unexpected markers", markers.length, 0);
+		
+	} finally {
+		deleteExternalResource("TestContainer");
+		deleteProject("ExternalContainer");
+	}
+}
+
+/*
  * Ensures that adding a library entry for an existing empty external ZIP archive updates the model
  */
 public void testAddZIPArchive1() throws Exception {
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 35e588f..3f7784f 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
@@ -40,6 +40,7 @@
 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;
@@ -8784,6 +8785,7 @@
 		"lib/b166348.jar  [No source]\n" +
 		"lib/b166348.jar pack [No source]\n" +
 		"lib/b166348.jar test [No source]\n" +
+		"lib/b317264 b317264\n" +
 		"lib/b86293.jar  [No source]\n" +
 		"lib/b87627.jar  [No source]\n" +
 		"lib/b87627.jar b87627 [No source]\n" +
@@ -10964,13 +10966,17 @@
         }
 	}
 	// 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.getOptions().get(JavaCore.COMPILER_TASK_TAGS));
-	System.out.println("		+ Task priorities:     " + JavaCore.getOptions().get(JavaCore.COMPILER_TASK_PRIORITIES));
-	System.out.println("		+ Forbidden reference: " + JavaCore.getOptions().get(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
+	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));
 	printPreference();
+	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();
@@ -11015,19 +11021,21 @@
 
 		// print statement to debug random failures of this test
 		System.out.println("	- Options before first exit:");
-		System.out.println("		+ Task tags:           " + JavaCore.getOptions().get(JavaCore.COMPILER_TASK_TAGS));
-		System.out.println("		+ Task priorities:     " + JavaCore.getOptions().get(JavaCore.COMPILER_TASK_PRIORITIES));
-		System.out.println("		+ Forbidden reference: " + JavaCore.getOptions().get(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
+		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));
 		printPreference();
+		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.getOptions().get(JavaCore.COMPILER_TASK_TAGS));
-		System.out.println("		+ Task priorities:     " + JavaCore.getOptions().get(JavaCore.COMPILER_TASK_PRIORITIES));
-		System.out.println("		+ Forbidden reference: " + JavaCore.getOptions().get(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
+		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));
 		printPreference();
+		System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2));
 		waitUntilIndexesReady();
 
 		// Search for the new type with new extension
@@ -11049,18 +11057,19 @@
 		
 		// print statement to debug random failures of this test
 		System.out.println("	- Options before second exit:");
-		System.out.println("		+ Task tags:           " + JavaCore.getOptions().get(JavaCore.COMPILER_TASK_TAGS));
-		System.out.println("		+ Task priorities:     " + JavaCore.getOptions().get(JavaCore.COMPILER_TASK_PRIORITIES));
-		System.out.println("		+ Forbidden reference: " + JavaCore.getOptions().get(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
+		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));
 		printPreference();
+		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.getOptions().get(JavaCore.COMPILER_TASK_TAGS));
-		System.out.println("		+ Task priorities:     " + JavaCore.getOptions().get(JavaCore.COMPILER_TASK_PRIORITIES));
-		System.out.println("		+ Forbidden reference: " + JavaCore.getOptions().get(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
+		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));
 		printPreference();
 		waitUntilIndexesReady();
 
@@ -11075,21 +11084,24 @@
 				null);
 		assertSearchResults("No search results expected", "", collector);
 		System.out.println("	- Options after search:");
-		System.out.println("		+ Task tags:           " + JavaCore.getOptions().get(JavaCore.COMPILER_TASK_TAGS));
-		System.out.println("		+ Task priorities:     " + JavaCore.getOptions().get(JavaCore.COMPILER_TASK_PRIORITIES));
-		System.out.println("		+ Forbidden reference: " + JavaCore.getOptions().get(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
+		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));
 		printPreference();
+		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.getOptions().get(JavaCore.COMPILER_TASK_TAGS));
-		System.out.println("		+ Task priorities:     " + JavaCore.getOptions().get(JavaCore.COMPILER_TASK_PRIORITIES));
-		System.out.println("		+ Forbidden reference: " + JavaCore.getOptions().get(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE));
+		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:");
 		printPreference();
-		System.out.println("================================================================================");
+		System.out.println(Util.indentString(new CompilerOptions(JavaCore.getDefaultOptions()).toString(), 2));
 	}
 }
 private void printPreference() {
@@ -11883,4 +11895,463 @@
 		deleteFolder("/JavaSearchBugs/src/java");
 	}
 }
+
+/**
+ * @bug 313668: [search] Call hierarchy doesn't show all calls of the method in workspace
+ * @test Search for references to method should even return hierarchy sibling's reference.
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=313668"
+ */
+public void testBug313668() throws CoreException {
+	boolean autoBuild = getWorkspace().isAutoBuilding();
+	IWorkspaceDescription preferences = getWorkspace().getDescription();
+	IJavaProject commonProject = null, clientProject = null, serverProject = null;
+	try {
+		// ensure that the workspace auto-build is ON
+		preferences.setAutoBuilding(true);
+		getWorkspace().setDescription(preferences);
+		
+		// create the common project and create an interface
+		commonProject = createJavaProject("common");	
+		createFolder("/common/com/db");
+		createFile("/common/com/db/Repo.java", 
+				"package com.db;\n" +
+				"public interface Repo {\n"+
+				"public void find();\n}");
+
+		// create the client project, create the class and the reference
+		clientProject = createJavaProject("client");
+		IClasspathEntry entry =  JavaCore.newProjectEntry(new Path("/common"));
+		addClasspathEntry(clientProject, entry);
+		createFolder("/client/com/db");
+		createFile("/client/com/db/ClientRepo.java", 
+				"package com.db;\n" +
+				"public class ClientRepo implements Repo {\n"+
+				"public void find(){};\n}");
+		createFile("/client/com/db/CallerClient.java", 
+				"package com.db;\n" +
+				"public class CallerClient{\n"+
+				"public static void main(String[] args) {\n"+
+				"Repo r = null;\n"+
+				"r.find();}}\n");
+	
+		// create the server project, create the class and the reference
+		serverProject = createJavaProject("server");
+		entry =  JavaCore.newProjectEntry(new Path("/common"));
+		addClasspathEntry(serverProject, entry);
+		createFolder("/server/com/db");
+		createFile("/server/com/db/ServerRepo.java", 
+				"package com.db;\n" +
+				"public class ServerRepo implements Repo{\n"+
+				"public void find(){};\n");
+		createFile("/server/com/db/CallerServer.java", 
+				"package com.db;\n" +
+				"public class CallerServer {\n"+
+				"public static void main(String[] args) {\n"+
+				"Repo r = null;\n"+
+				"r.find();}}\n");
+
+		waitUntilIndexesReady();
+				
+		// search
+		IType type = getCompilationUnit("/server/com/db/ServerRepo.java").getType("ServerRepo");
+		IMethod method = type.getMethod("find", new String[]{});
+		search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector);
+		assertSearchResults(
+				"com/db/CallerClient.java void com.db.CallerClient.main(String[]) [find()] EXACT_MATCH\n"+
+				"com/db/CallerServer.java void com.db.CallerServer.main(String[]) [find()] EXACT_MATCH");
+	}
+	finally {
+		// put back initial setup
+		preferences.setAutoBuilding(autoBuild);
+		getWorkspace().setDescription(preferences);
+
+		// delete projects
+		deleteProject(commonProject);
+		deleteProject(clientProject);
+		deleteProject(serverProject);
+	}
+}
+/**
+ * @bug 317264: Refactoring is impossible with commons.lang added to project
+ * @test types in enum package of org.apache.commons.lang.jar should not be reported for 1.5 projects
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=317264"
+ */
+public void testBug317264a() throws CoreException {
+	IJavaProject project = null;
+	try
+	{
+		project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b317264/org.apache.commons.lang_2.modified.jar"), null, null));
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		
+		waitUntilIndexesReady();
+		TypeNameMatchCollector collector = new TypeNameMatchCollector();
+		new SearchEngine().searchAllTypeNames(
+				"org.apache.commons.lang.enum".toCharArray(),
+				SearchPattern.R_EXACT_MATCH,
+				"".toCharArray(),
+				SearchPattern.R_PREFIX_MATCH,
+				IJavaSearchConstants.TYPE,
+				scope,
+				collector,
+				IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
+				null);
+		assertSearchResults("Unexpected search results!", "", collector);		
+	} finally {
+		deleteProject(project);
+	}
+}
+// types in enum package of org.apache.commons.lang.jar should be reported for 1.4 projects
+public void testBug317264b() throws CoreException {
+	IJavaProject project = null;
+	try
+	{
+		project = createJavaProject("P");
+		addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b317264/org.apache.commons.lang_2.modified.jar"), null, null));
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		
+		waitUntilIndexesReady();
+		TypeNameMatchCollector collector = new TypeNameMatchCollector();
+		new SearchEngine().searchAllTypeNames(
+				"org.apache.commons.lang.enum".toCharArray(),
+				SearchPattern.R_EXACT_MATCH,
+				"".toCharArray(),
+				SearchPattern.R_PREFIX_MATCH,
+				IJavaSearchConstants.TYPE,
+				scope,
+				collector,
+				IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
+				null);
+		assertSearchResults("Unexpected search results!",
+				"Enum (not open) [in Enum.class [in org.apache.commons.lang.enum [in /JavaSearchBugs/lib/b317264/org.apache.commons.lang_2.modified.jar [in P]]]]",
+				collector);		
+	} finally {
+		deleteProject(project);
+	}
+}
+
+// types in enum package of org.apache.commons.lang.jar should not be reported for 1.5 projects
+public void testBug317264c() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b317264/org.apache.commons.lang_2.modified.jar"), null, null));
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		search("org.apache.commons.lang.enum*", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, scope, this.resultCollector);
+		assertSearchResults("Unexpected search results!", "", this.resultCollector);		
+	} finally {
+		deleteProject("P");
+	}
+}
+
+// types in enum package of org.apache.commons.lang.jar should be reported for 1.4 projects
+public void testBug317264d() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P");
+		addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b317264/org.apache.commons.lang_2.modified.jar"), null, null));
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		search("org.apache.commons.lang.enum.*", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, scope, this.resultCollector);
+		assertSearchResults("Unexpected search results!", 
+				"lib/b317264/org.apache.commons.lang_2.modified.jar org.apache.commons.lang.enum.Enum EXACT_MATCH",
+				this.resultCollector);		
+	} finally {
+		deleteProject("P");
+	}
+}
+
+// enum package of org.apache.commons.lang.jar should not be reported for 1.5 projects
+public void testBug317264e() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b317264/org.apache.commons.lang_2.modified.jar"), null, null));
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		search("org.apache.commons.lang.enum*", IJavaSearchConstants.PACKAGE, IJavaSearchConstants.DECLARATIONS, scope, this.resultCollector);
+		assertSearchResults("Unexpected search results!",  "", this.resultCollector);		
+	} finally {
+		deleteProject("P");
+	}
+}
+
+//enum package of org.apache.commons.lang.jar should be reported for 1.4 projects
+public void testBug317264f() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P");
+		addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b317264/org.apache.commons.lang_2.modified.jar"), null, null));
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		search("org.apache.commons.lang.enum*", IJavaSearchConstants.PACKAGE, IJavaSearchConstants.DECLARATIONS, scope, this.resultCollector);
+		assertSearchResults("Unexpected search results!", 
+				"lib/b317264/org.apache.commons.lang_2.modified.jar org.apache.commons.lang.enum [No source] EXACT_MATCH",
+				this.resultCollector);		
+	} finally {
+		deleteProject("P");
+	}
+}
+
+/**
+ * @bug 322979: [search] use of IJavaSearchConstants.IMPLEMENTORS yields surprising results
+ * @test search of implementors does no longer report matches in type arguments
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=322979"
+ */
+public void testBug322979a() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		createFile("/P/Test.java", 
+			"public class Test extends Object implements Comparable<Object>{\n"+
+		    "public int compareTo(Object o) {\n"+
+		        "return 0;\n"+
+		    "}\n"+
+			"}\n");
+		waitUntilIndexesReady();
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		this.resultCollector.showAccuracy(true);
+		this.resultCollector.showSelection();
+		search("Object", TYPE, IMPLEMENTORS, scope);
+		assertSearchResults(
+			"Test.java Test [public class Test extends !|Object|! implements Comparable<Object>{] EXACT_MATCH"
+		);
+	} finally {
+		deleteProject("P");
+	}
+}
+
+public void testBug322979b() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		createFile("/P/Test.java", 
+			"public class Test extends java.lang.Object implements Comparable<Object>{\n"+
+		    "public int compareTo(Object o) {\n"+
+		        "return 0;\n"+
+		    "}\n"+
+			"}\n");
+		waitUntilIndexesReady();
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		IType type = getClassFile("P", getExternalJCLPathString("1.5"), "java.lang", "Object.class").getType();
+		this.resultCollector.showAccuracy(true);
+		this.resultCollector.showSelection();
+		search(type, IMPLEMENTORS, scope);
+		assertSearchResults(
+			"Test.java Test [public class Test extends !|java.lang.Object|! implements Comparable<Object>{] EXACT_MATCH"
+		);
+	} finally {
+		deleteProject("P");
+	}
+}
+
+public void testBug322979c() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		createFile("/P/Test.java", 
+			"public class Test extends Object implements I01a<Object>, I01b<String>, I01c<Object> {\n" + 
+			"}\n" + 
+			"interface I01a<T> {}\n" + 
+			"interface I01b<T> {}\n" + 
+			"interface I01c<T> {}\n"
+		);
+		waitUntilIndexesReady();
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		this.resultCollector.showSelection();
+		search("java.lang.Object", TYPE, IMPLEMENTORS, scope);
+		assertSearchResults(
+			"Test.java Test [public class Test extends !|Object|! implements I01a<Object>, I01b<String>, I01c<Object> {] EXACT_MATCH"
+		);
+	} finally {
+		deleteProject("P");
+	}
+}
+
+public void testBug322979d() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		createFile("/P/Test.java", 
+			"public class Test extends Object implements I01<\n" + 
+			"	I02<\n" + 
+			"		I03<Object,\n" + 
+			"			I02<Object, I01<Object>>,\n" + 
+			"			I03<Object, I01<Object>, I02<Object, I01<Object>>>\n" + 
+			"			>,\n" + 
+			"		I01<Object>>> {\n" + 
+			"}\n" + 
+			"interface I01<T> {}\n" + 
+			"interface I02<T, U> {}\n" + 
+			"interface I03<T, U, V> {}\n"
+		);
+		waitUntilIndexesReady();
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		this.resultCollector.showSelection();
+		search("Object", TYPE, IMPLEMENTORS, scope);
+		assertSearchResults(
+			"Test.java Test [public class Test extends !|Object|! implements I01<] EXACT_MATCH"
+		);
+	} finally {
+		deleteProject("P");
+	}
+}
+
+public void testBug322979e() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		createFile("/P/Test.java", 
+			"public class Test extends Object implements I01<\n" + 
+			"	I02<\n" + 
+			"		I03<Object,\n" + 
+			"			I02<Object, I01<Object>>,\n" + 
+			"			I03<Object, I01<Object>, I02<Object, I01<Object>>>\n" + 
+			"			>,\n" + 
+			"		I01<Object>>> {\n" + 
+			"}\n" + 
+			"interface I01<T> {}\n" + 
+			"interface I02<T, U> {}\n" + 
+			"interface I03<T, U, V> {}\n"
+		);
+		waitUntilIndexesReady();
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		this.resultCollector.showSelection();
+		search("Object", TYPE, REFERENCES, scope);
+		assertSearchResults(
+			"Test.java Test [public class Test extends !|Object|! implements I01<] EXACT_MATCH\n" + 
+			"Test.java Test [		I03<!|Object|!,] EXACT_MATCH\n" + 
+			"Test.java Test [			I02<!|Object|!, I01<Object>>,] EXACT_MATCH\n" + 
+			"Test.java Test [			I02<Object, I01<!|Object|!>>,] EXACT_MATCH\n" + 
+			"Test.java Test [			I03<!|Object|!, I01<Object>, I02<Object, I01<Object>>>] EXACT_MATCH\n" + 
+			"Test.java Test [			I03<Object, I01<!|Object|!>, I02<Object, I01<Object>>>] EXACT_MATCH\n" + 
+			"Test.java Test [			I03<Object, I01<Object>, I02<!|Object|!, I01<Object>>>] EXACT_MATCH\n" + 
+			"Test.java Test [			I03<Object, I01<Object>, I02<Object, I01<!|Object|!>>>] EXACT_MATCH\n" + 
+			"Test.java Test [		I01<!|Object|!>>> {] EXACT_MATCH\n" + 
+			""+ getExternalJCLPathString("1.5") + " java.lang.Object java.lang.Object.clone() EXACT_MATCH\n" + 
+			""+ getExternalJCLPathString("1.5") + " boolean java.lang.Object.equals(java.lang.Object) EXACT_MATCH\n" + 
+			""+ getExternalJCLPathString("1.5") + " java.lang.Class<? extends java.lang.Object> java.lang.Object.getClass() EXACT_MATCH"
+		);
+	} finally {
+		deleteProject("P");
+	}
+}
+
+public void testBug322979f() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		createFile("/P/Test.java", 
+			"public class Test extends Object implements I01<\n" + 
+			"	I02<\n" + 
+			"		I03<Object,\n" + 
+			"			I02<Object, I01<Object>>,\n" + 
+			"			I03<Object, I01<Object>, I02<Object, I01<Object>>>\n" + 
+			"			>,\n" + 
+			"		I01<Object>>> {\n" + 
+			"}\n" + 
+			"interface I01<T> {}\n" + 
+			"interface I02<T, U> {}\n" + 
+			"interface I03<T, U, V> {}\n"
+		);
+		waitUntilIndexesReady();
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		this.resultCollector.showSelection();
+		search("Object", TYPE, REFERENCES | SUPERTYPE_TYPE_REFERENCE, scope);
+		assertSearchResults(
+			"Test.java Test [public class Test extends !|Object|! implements I01<] EXACT_MATCH"
+		);
+	} finally {
+		deleteProject("P");
+	}
+}
+
+public void testBug322979g() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		createFile("/P/Test.java", 
+			"public class Test extends Object implements I<A<Object>.B<I<Object>>.C<I<A<Object>.B<Object>.C<Object>>>> {\n" + 
+			"}\n" + 
+			"interface I<T> {\n" + 
+			"}\n" + 
+			"class A<T> {\n" + 
+			"	class B<U> {\n" + 
+			"		class C<V> {}\n" + 
+			"	}\n" + 
+			"}\n"
+		);
+		waitUntilIndexesReady();
+		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		this.resultCollector.showSelection();
+		search("Object", TYPE, IMPLEMENTORS, scope);
+		assertSearchResults(
+			"Test.java Test [public class Test extends !|Object|! implements I<A<Object>.B<I<Object>>.C<I<A<Object>.B<Object>.C<Object>>>> {] EXACT_MATCH"
+		);
+	} finally {
+		deleteProject("P");
+	}
+}
+public void testBug322979h() throws CoreException {
+	try
+	{
+		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+		createFile("/P/Test.java", 
+			"public class Test extends Object implements I1<String>, I2<Object>{\n"+
+		    "}\n"+
+		    "Interface I1<T> {}\n"+
+			"Interface I2<T> {}\n");
+		waitUntilIndexesReady();
+		int mask = IJavaSearchScope.SOURCES ;
+		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+		this.resultCollector.showAccuracy(true);
+		this.resultCollector.showSelection();
+		SearchPattern leftPattern = SearchPattern.createPattern(
+				"Object",
+				TYPE,
+				IMPLEMENTORS,
+				EXACT_RULE);
+		SearchPattern rightPattern = SearchPattern.createPattern(
+				"String",
+				TYPE,
+				REFERENCES,
+				EXACT_RULE);
+		search(SearchPattern.createOrPattern(leftPattern, rightPattern), scope, this.resultCollector);
+		assertSearchResults(
+			"Test.java Test [public class Test extends !|Object|! implements I1<String>, I2<Object>{] EXACT_MATCH\n" + 
+			"Test.java Test [public class Test extends Object implements I1<!|String|!>, I2<Object>{] EXACT_MATCH"
+		);
+	} finally {
+		deleteProject("P");
+	}
+}
+
+/**
+ * @bug 324109: [search] Java search shows incorrect results as accurate matches
+ * @test search of method declaration off missing types should report potential matches and not accurate.
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324109"
+ */
+public void testBug324109() throws CoreException {
+	this.workingCopies = new ICompilationUnit[1];
+	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b324109/X.java",
+		"package b324109;\n" +
+		"public class X extends A {\n" +
+		" public void run() {}\n" +
+		"}"
+	);
+	search("Worker.run()", METHOD, DECLARATIONS);
+	assertSearchResults(
+		"src/b324109/X.java void b324109.X.run() [run] POTENTIAL_MATCH"
+	);
+}
 }
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java
index bd52439..7e3909b 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java
@@ -481,9 +481,9 @@
 	IType type = getCompilationUnit("/P/src/p/X.java").getType("X");
 	IMethod method = type.getMethod("foo", new String[]{});
 
-	ILocalVariable localVar = new LocalVariable((JavaElement)method, "var", 1, 2, 3, 4, "Z", null);
+	ILocalVariable localVar = new LocalVariable((JavaElement)method, "var", 1, 2, 3, 4, "Z", null, 0, true);
 	assertMemento(
-		"=P/src<p{X.java[X~foo@var!1!2!3!4!Z",
+		"=P/src<p{X.java[X~foo@var!1!2!3!4!Z!0!true",
 		localVar);
 }
 /**
@@ -493,9 +493,9 @@
 	IType type = getClassFile("/P/src/p/X.class").getType();
 	IMethod method = type.getMethod("foo", new String[]{"I"});
 
-	ILocalVariable localVar = new LocalVariable((JavaElement)method, "var", 1, 2, 3, 4, "Z", null);
+	ILocalVariable localVar = new LocalVariable((JavaElement)method, "var", 1, 2, 3, 4, "Z", null,0, false);
 	assertMemento(
-		"=P/src<p(X.class[X~foo~I@var!1!2!3!4!Z",
+		"=P/src<p(X.class[X~foo~I@var!1!2!3!4!Z!0!false",
 		localVar);
 }
 /**
@@ -505,9 +505,9 @@
 	IType type = getCompilationUnit("/P/src/p/X.java").getType("X");
 	IInitializer initializer = type.getInitializer(1);
 
-	ILocalVariable localVar = new LocalVariable((JavaElement)initializer, "var", 1, 2, 3, 4, "Z", null);
+	ILocalVariable localVar = new LocalVariable((JavaElement)initializer, "var", 1, 2, 3, 4, "Z", null, 0, false);
 	assertMemento(
-		"=P/src<p{X.java[X|1@var!1!2!3!4!Z",
+		"=P/src<p{X.java[X|1@var!1!2!3!4!Z!0!false",
 		localVar);
 }
 /**
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
index 33d3114..4179e1b 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
@@ -4532,4 +4532,313 @@
 			ast
 		);
 }
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
+public void testGenericAPIUsageFromA14Project() throws CoreException {
+	IJavaProject project14 = null;
+	IJavaProject project15 = null;
+	try {
+		project15 = createJavaProject("Reconciler15API", new String[] {"src"}, new String[] {"JCL_LIB"}, "bin");
+		createFolder("/Reconciler15API/src/p2");
+		createFile(
+			"/Reconciler15API/src/p2/BundleContext.java",
+			"package p2;\n" +
+			"public class BundleContext {\n" +
+			"  public <S> S getService(S s) {\n" +
+			"      return null;\n" +
+			"  }\n" +
+			"}"
+		);
+		project15.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
+		project15.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
+		project15.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
+		
+		project14 = createJavaProject("Reconciler1415", new String[] {"src"}, new String[] {"JCL_LIB"}, "bin");
+		project14.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4);
+		project14.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
+		project14.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4);
+		
+		IClasspathEntry[] oldClasspath = project14.getRawClasspath();
+		int oldLength = oldClasspath.length;
+		IClasspathEntry[] newClasspath = new IClasspathEntry[oldLength+1];
+		System.arraycopy(oldClasspath, 0, newClasspath, 0, oldLength);
+		newClasspath[oldLength] = JavaCore.newProjectEntry(new Path("/Reconciler15API"));
+		project14.setRawClasspath(newClasspath, null);
+		
+		createFolder("/Reconciler1415/src/p1");
+		String source = 
+			"package p1;\n" +
+			"import p2.BundleContext;\n" +
+			"public class X {\n" +
+			"  public static void main(BundleContext context, String string) {\n" +
+			"  String s = (String) context.getService(string); \n" +
+			"  }\n" +
+			"}";
+
+		createFile(
+			"/Reconciler1415/src/p1/X.java",
+			source
+		);
+		
+		this.workingCopies = new ICompilationUnit[1];
+		char[] sourceChars = source.toCharArray();
+		this.problemRequestor.initialize(sourceChars);
+		this.workingCopies[0] = getCompilationUnit("/Reconciler1415/src/p1/X.java").getWorkingCopy(this.wcOwner, null);
+		assertProblems(
+			"Unexpected problems",
+			"----------\n" + 
+			"1. WARNING in /Reconciler1415/src/p1/X.java (at line 5)\n" + 
+			"	String s = (String) context.getService(string); \n" + 
+			"	       ^\n" + 
+			"The local variable s is never read\n" + 
+			"----------\n"
+		);
+	} finally {
+		if (project14 != null)
+			deleteProject(project14);
+		if (project15 != null)
+			deleteProject(project15);
+	}
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259 (same as above, but with a JSR14 target)
+public void testGenericAPIUsageFromA14Project2() throws CoreException {
+	IJavaProject project14 = null;
+	IJavaProject project15 = null;
+	try {
+		project15 = createJavaProject("Reconciler15API", new String[] {"src"}, new String[] {"JCL_LIB"}, "bin");
+		createFolder("/Reconciler15API/src/p2");
+		createFile(
+			"/Reconciler15API/src/p2/BundleContext.java",
+			"package p2;\n" +
+			"public class BundleContext {\n" +
+			"  public <S> S getService(S s) {\n" +
+			"      return null;\n" +
+			"  }\n" +
+			"}"
+		);
+		project15.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
+		project15.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
+		project15.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4);
+		
+		project14 = createJavaProject("Reconciler1415", new String[] {"src"}, new String[] {"JCL_LIB"}, "bin");
+		project14.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4);
+		project14.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
+		project14.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4);
+		
+		IClasspathEntry[] oldClasspath = project14.getRawClasspath();
+		int oldLength = oldClasspath.length;
+		IClasspathEntry[] newClasspath = new IClasspathEntry[oldLength+1];
+		System.arraycopy(oldClasspath, 0, newClasspath, 0, oldLength);
+		newClasspath[oldLength] = JavaCore.newProjectEntry(new Path("/Reconciler15API"));
+		project14.setRawClasspath(newClasspath, null);
+		
+		createFolder("/Reconciler1415/src/p1");
+		String source = 
+			"package p1;\n" +
+			"import p2.BundleContext;\n" +
+			"public class X {\n" +
+			"  public static void main(BundleContext context, String string) {\n" +
+			"  String s = (String) context.getService(string); \n" +
+			"  }\n" +
+			"}";
+
+		createFile(
+			"/Reconciler1415/src/p1/X.java",
+			source
+		);
+		
+		this.workingCopies = new ICompilationUnit[1];
+		char[] sourceChars = source.toCharArray();
+		this.problemRequestor.initialize(sourceChars);
+		this.workingCopies[0] = getCompilationUnit("/Reconciler1415/src/p1/X.java").getWorkingCopy(this.wcOwner, null);
+		assertProblems(
+			"Unexpected problems",
+			"----------\n" + 
+			"1. WARNING in /Reconciler1415/src/p1/X.java (at line 5)\n" + 
+			"	String s = (String) context.getService(string); \n" + 
+			"	       ^\n" + 
+			"The local variable s is never read\n" + 
+			"----------\n"
+		);
+	} finally {
+		if (project14 != null)
+			deleteProject(project14);
+		if (project15 != null)
+			deleteProject(project15);
+	}
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=323633
+public void testGenericAPIUsageFromA14Project3() throws CoreException {
+	IJavaProject project14 = null;
+	IJavaProject project15 = null;
+	try {
+		project15 = createJavaProject("Reconciler15API", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin");
+		createFolder("/Reconciler15API/src/p2");
+		createFile(
+			"/Reconciler15API/src/p2/X.java",
+			"package p2;\n" +
+			"import java.util.Collection;\n" +
+			"import java.util.Iterator;\n" +
+			"public class X<E> implements Collection<E>{\n" +
+			"   public static X getX() {\n" +
+			"        	return new X();\n" +
+			"	}\n" +
+			"	public int size() {\n" +
+			"		return 0;\n" +
+			"	}\n" +
+			"	public boolean isEmpty() {\n" +
+			"		return false;\n" +
+			"	}\n" +
+			"	public boolean contains(Object o) {\n" +
+			"		return false;\n" +
+			"	}\n" +
+			"	public Iterator<E> iterator() {\n" +
+			"		return null;\n" +
+			"	}\n" +
+			"	public Object[] toArray() {\n" +
+			"		return null;\n" +
+			"	}\n" +
+			"	public <T> T[] toArray(T[] a) {\n" +
+			"		return null;\n" +
+			"	}\n" +
+			"	public boolean add(E e) {\n" +
+			"		return false;\n" +
+			"	}\n" +
+			"	public boolean remove(Object o) {\n" +
+			"		return false;\n" +
+			"	}\n" +
+			"	public boolean containsAll(Collection<?> c) {\n" +
+			"		return false;\n" +
+			"	}\n" +
+			"	public boolean addAll(Collection<? extends E> c) {\n" +
+			"		return false;\n" +
+			"	}\n" +
+			"	public boolean removeAll(Collection<?> c) {\n" +
+			"		return false;\n" +
+			"	}\n" +
+			"	public boolean retainAll(Collection<?> c) {\n" +
+			"		return false;\n" +
+			"	}\n" +
+			"	public void clear() {\n" +
+			"	}\n" +
+			"}\n"
+		);
+		project15.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
+		project15.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
+		project15.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
+		
+		project14 = createJavaProject("Reconciler1415", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin");
+		project14.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4);
+		project14.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
+		project14.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4);
+		
+		IClasspathEntry[] oldClasspath = project14.getRawClasspath();
+		int oldLength = oldClasspath.length;
+		IClasspathEntry[] newClasspath = new IClasspathEntry[oldLength+1];
+		System.arraycopy(oldClasspath, 0, newClasspath, 0, oldLength);
+		newClasspath[oldLength] = JavaCore.newProjectEntry(new Path("/Reconciler15API"));
+		project14.setRawClasspath(newClasspath, null);
+		
+		createFolder("/Reconciler1415/src/p1");
+		String source = 
+			"package p1;\n" +
+			"import java.util.Collection;\n" +
+			"public class X {\n" +
+			"  public static void main(String string) {\n" +
+			"  Collection c = p2.X.getX(); \n" +
+			"  }\n" +
+			"}";
+
+		createFile(
+			"/Reconciler1415/src/p1/X.java",
+			source
+		);
+		
+		this.workingCopies = new ICompilationUnit[1];
+		char[] sourceChars = source.toCharArray();
+		this.problemRequestor.initialize(sourceChars);
+		this.workingCopies[0] = getCompilationUnit("/Reconciler1415/src/p1/X.java").getWorkingCopy(this.wcOwner, null);
+		assertProblems(
+			"Unexpected problems",
+			"----------\n" + 
+			"1. WARNING in /Reconciler1415/src/p1/X.java (at line 5)\n" + 
+			"	Collection c = p2.X.getX(); \n" + 
+			"	           ^\n" + 
+			"The local variable c is never read\n" + 
+			"----------\n"
+		);
+	} finally {
+		if (project14 != null)
+			deleteProject(project14);
+		if (project15 != null)
+			deleteProject(project15);
+	}
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=323633 (variation: 15 uses 14)
+public void testGenericAPIUsageFromA14Project4() throws CoreException {
+	IJavaProject project14 = null;
+	IJavaProject project15 = null;
+	try {
+		project14 = createJavaProject("Reconciler1415", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin");
+		createFolder("/Reconciler1415/src/p1");
+		String source = 
+			"package p1;\n" +
+			"import java.lang.Comparable;\n" +
+			"public class X implements Comparable {\n" +
+			"  public static X getX() {\n" +
+			"      return new X();\n" +
+			"  }\n" +
+			"}";
+
+		createFile(
+			"/Reconciler1415/src/p1/X.java",
+			source
+		);
+
+		project14.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4);
+		project14.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
+		project14.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4);
+
+		project15 = createJavaProject("Reconciler15API", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin");
+		createFolder("/Reconciler15API/src/p2");
+		String otherSource = "package p2;\n" +
+		                     "public class X { \n" +
+		                     " private p1.X x = p1.X.getX();\n" +
+		                     " Comparable<String> y = null;\n" +
+		                     "}\n";   
+		                 
+		createFile(
+			"/Reconciler15API/src/p2/X.java",
+			otherSource
+		);
+		project15.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
+		project15.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
+		project15.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
+		
+		IClasspathEntry[] oldClasspath = project15.getRawClasspath();
+		int oldLength = oldClasspath.length;
+		IClasspathEntry[] newClasspath = new IClasspathEntry[oldLength+1];
+		System.arraycopy(oldClasspath, 0, newClasspath, 0, oldLength);
+		newClasspath[oldLength] = JavaCore.newProjectEntry(new Path("/Reconciler1415"));
+		project15.setRawClasspath(newClasspath, null);
+				
+		this.workingCopies = new ICompilationUnit[1];
+		char[] sourceChars = otherSource.toCharArray();
+		this.problemRequestor.initialize(sourceChars);
+		this.workingCopies[0] = getCompilationUnit("/Reconciler15API/src/p2/X.java").getWorkingCopy(this.wcOwner, null);
+		assertProblems(
+			"Unexpected problems",
+			"----------\n" + 
+			"1. WARNING in /Reconciler15API/src/p2/X.java (at line 3)\n" + 
+			"	private p1.X x = p1.X.getX();\n" + 
+			"	             ^\n" + 
+			"The field X.x is never read locally\n" + 
+			"----------\n"
+		);
+	} finally {
+		if (project14 != null)
+			deleteProject(project14);
+		if (project15 != null)
+			deleteProject(project15);
+	}
+}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java
index 63a5bdf..01a45e8 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java
@@ -1447,6 +1447,7 @@
 			"Unexpected type",
 			"QTestString;",
 			((ILocalVariable)elements[0]).getTypeSignature());
+	assertFalse(((ILocalVariable)elements[0]).isParameter());
 }
 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
 public void testDuplicateLocals2() throws JavaModelException {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java
index 1d278ea..9ff2627 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -314,4 +314,85 @@
 			"X.test X [X]",
 			requestor);
 	}
+	
+	/*
+	 * Ensures that a simple search that forwards queries to the default participant works as expected even after restart
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=308402
+	 */
+	public void testSearchAfterRestart() throws CoreException {
+		createFile(
+			"/P/X.test",
+			"public class X {\n" +
+			"}"
+		);
+
+		// index file
+		TestSearchParticipant participant = new TestSearchParticipant();
+		TestSearchDocument document = new TestSearchDocument("/P/X.test", participant);
+		participant.scheduleDocumentIndexing(document, getIndexLocation());
+		waitUntilIndexesReady();
+		try {
+			Thread.sleep(5000); // wait for the indexes to go into the disk
+		} catch (InterruptedException e) {
+			// ignore
+		}
+		simulateExit();
+		simulateRestart();
+		waitUntilIndexesReady();
+	
+		// search for declaration of X
+		SearchPattern pattern = SearchPattern.createPattern("X", IJavaSearchConstants.DECLARATIONS, IJavaSearchConstants.TYPE, SearchPattern.R_EXACT_MATCH);
+		IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
+		SearchRequestor requestor =  new TestResultCollector();
+		new SearchEngine().search(pattern, new SearchParticipant[] {participant}, scope, requestor, null);
+		assertSearchResults(
+			"X.test X [X]",
+			requestor);
+		
+	}
+	
+	/*
+	 * Ensures that a simple search that forwards queries to the default participant works as expected even after restart
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=308402
+	 */
+	public void testSearchAfterRemoveAndRestart() throws CoreException {
+		createFile(
+			"/P/X.test",
+			"public class X {\n" +
+			"}"
+		);
+
+		// index file
+		TestSearchParticipant participant = new TestSearchParticipant();
+		TestSearchDocument document = new TestSearchDocument("/P/X.test", participant);
+		participant.scheduleDocumentIndexing(document, getIndexLocation());
+		waitUntilIndexesReady();
+		
+		// search for declaration of X
+		SearchPattern pattern = SearchPattern.createPattern("X", IJavaSearchConstants.DECLARATIONS, IJavaSearchConstants.TYPE, SearchPattern.R_EXACT_MATCH);
+		IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
+		SearchRequestor requestor =  new TestResultCollector();
+		new SearchEngine().search(pattern, new SearchParticipant[] {participant}, scope, requestor, null);
+		
+		// remove the index
+		participant.removeIndex(getIndexLocation());
+		assertSearchResults(
+			"X.test X [X]",
+			requestor);
+		try {
+			Thread.sleep(5000); // wait for the indexes to go into the disk
+		} catch (InterruptedException e) {
+			// ignore
+		}
+		requestor =  new TestResultCollector();
+		new SearchEngine().search(pattern, new SearchParticipant[] {participant}, scope, requestor, null);
+		assertSearchResults("", requestor);
+		
+		simulateExit();
+		simulateRestart();
+		waitUntilIndexesReady();
+		requestor =  new TestResultCollector();
+		new SearchEngine().search(pattern, new SearchParticipant[] {participant}, scope, requestor, null);
+		assertSearchResults("", requestor);	
+	}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java
index b8edc01..e609caa 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java
@@ -913,7 +913,7 @@
  * Test LocalVarDeclarationPattern creation
  */
 public void testSearchPatternCreation30() {
-	ILocalVariable localVar = new LocalVariable((JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),  "var", 1, 2, 3, 4, "Z", null);
+	ILocalVariable localVar = new LocalVariable((JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),  "var", 1, 2, 3, 4, "Z", null, 0, false);
 	SearchPattern searchPattern = createPattern(
 			localVar,
 			IJavaSearchConstants.DECLARATIONS);
@@ -927,7 +927,7 @@
  * Test LocalVarReferencePattern creation
  */
 public void testSearchPatternCreation31() {
-	ILocalVariable localVar = new LocalVariable((JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),  "var", 1, 2, 3, 4, "Z", null);
+	ILocalVariable localVar = new LocalVariable((JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),  "var", 1, 2, 3, 4, "Z", null, 0, false);
 	SearchPattern searchPattern = createPattern(
 			localVar,
 			IJavaSearchConstants.REFERENCES);
@@ -941,7 +941,7 @@
  * Test LocalVarCombinedPattern creation
  */
 public void testSearchPatternCreation32() {
-	ILocalVariable localVar = new LocalVariable((JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),  "var", 1, 2, 3, 4, "Z", null);
+	ILocalVariable localVar = new LocalVariable((JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),  "var", 1, 2, 3, 4, "Z", null, 0, false);
 	SearchPattern searchPattern = createPattern(
 			localVar,
 			IJavaSearchConstants.ALL_OCCURRENCES);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java
index 66df5d2..cd9e0d4 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -10,12 +10,14 @@
  *******************************************************************************/
 package org.eclipse.jdt.core.tests.model;
 
+import java.io.File;
 import java.io.IOException;
 
 import junit.framework.Test;
 
 import org.eclipse.core.resources.*;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.core.*;
@@ -1334,6 +1336,108 @@
 	}
 }
 /**
+ * @bug 316654: ITypeHierarchyChangedListener receive spurious callbacks
+ * 
+ * Test that a non-Java resource added to a folder package fragment root doesn't
+ * result in a type hierarchy changed event.
+ * 
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654"
+ * @throws CoreException
+ */
+public void testBug316654() throws CoreException {
+	IJavaProject project = getJavaProject("TypeHierarchyNotification");
+	ICompilationUnit cu = getCompilationUnit("TypeHierarchyNotification", "src", "p", "X.java");
+	IType type= cu.getType("X");
+	ITypeHierarchy h = type.newTypeHierarchy(project, null);
+	h.addTypeHierarchyChangedListener(this);
+	IPath filePath = project.getProject().getFullPath().append("src").append("simplefile.txt");
+	try {
+		createFile(filePath.toOSString(), "A simple text file");
+		assertTrue("Should not receive change", !this.changeReceived);
+	} finally {
+		deleteFile(filePath.toOSString());
+		h.removeTypeHierarchyChangedListener(this);
+	}
+}
+/**
+ * Additional test - Test that a relevant Java source resource change results in a type hierarchy 
+ * change event.  
+ * 
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654"
+ * @throws CoreException
+ */
+public void testBug316654_a() throws CoreException {
+	IJavaProject project = getJavaProject("TypeHierarchyNotification");
+	ICompilationUnit cu = getCompilationUnit("TypeHierarchyNotification", "src", "p", "X.java");
+	IType type= cu.getType("X");
+	ITypeHierarchy h = type.newTypeHierarchy(project, null);
+	h.addTypeHierarchyChangedListener(this);
+	IPath filePath = project.getProject().getFullPath().append("src").append("p").append("Y.java");
+	try {
+		createFile(filePath.toOSString(), 
+					"package p;\n" +
+					"class Y extends X{\n" +
+					"}");
+		assertOneChange(h);
+	} finally {
+		deleteFile(filePath.toOSString());
+		h.removeTypeHierarchyChangedListener(this);
+	}
+}
+/**
+ * Additional test - Test that a relevant external archive change results in a type hierarchy 
+ * change event.  
+ * 
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654"
+ * @throws CoreException
+ */
+public void testBug316654_b() throws CoreException {
+	IJavaProject project = getJavaProject("TypeHierarchyNotification");
+	refreshExternalArchives(project);
+	File jarFile = new File(getExternalJCLPathString());
+	long oldTimestamp = jarFile.lastModified();
+	assertTrue("File does not exist", jarFile.exists());
+
+	IType throwableClass = getClassFile("TypeHierarchyNotification", getExternalJCLPathString(), "java.lang", "Throwable.class").getType();
+	ITypeHierarchy h = throwableClass.newTypeHierarchy(project, null);
+	h.addTypeHierarchyChangedListener(this);
+	reset();
+	
+	try {
+		jarFile.setLastModified(System.currentTimeMillis());
+		refreshExternalArchives(project);
+		assertOneChange(h);
+	} finally {
+		jarFile.setLastModified(oldTimestamp);
+		h.removeTypeHierarchyChangedListener(this);
+	}
+}
+/**
+ * Additional test - Test that a relevant archive change results in a type hierarchy 
+ * change event.
+ * 
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654"
+ * @throws CoreException
+ */
+public void testBug316654_c() throws CoreException {
+	IJavaProject project = getJavaProject("TypeHierarchyNotification");
+	IPath jarPath = project.getPath().append("test316654.jar"); 
+	IFile jarFile = getFile(jarPath.toOSString());
+
+	IType type = getClassFile("TypeHierarchyNotification", jarPath.toOSString(), "a", "A.class").getType();
+	ITypeHierarchy h = type.newTypeHierarchy(project, null);
+	h.addTypeHierarchyChangedListener(this);
+	reset();
+	
+	try {
+		jarFile.touch(null);
+		refresh(project);
+		assertOneChange(h);
+	} finally {
+		h.removeTypeHierarchyChangedListener(this);
+	}
+}
+/**
  * Make a note of the change
  */
 public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingInsertBoundTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingInsertBoundTest.java
index fc49879..1e6d612 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingInsertBoundTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingInsertBoundTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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,7 +19,6 @@
 
 import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.jdt.core.IPackageFragment;
-
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -522,8 +521,15 @@
 		buf.append("public class C {\n");
 		buf.append("//c1\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    public void foo2();\n");
 		buf.append("\n");
+		buf.append("//c3\n");
+		buf.append("\n");
+		buf.append("\n");
 		buf.append("//c4\n");
 		buf.append("}\n");
 
@@ -573,6 +579,10 @@
 		buf.append("\n");
 		buf.append("//c2\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c3\n");
+		buf.append("\n");
 		buf.append("    public void foo3();\n");
 		buf.append("\n");
 		buf.append("//c4\n");
@@ -623,6 +633,12 @@
 		buf.append("\n");
 		buf.append("    public void foo1();\n");
 		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
+		buf.append("\n");
+		buf.append("//c3\n");
+		buf.append("\n");
+		buf.append("\n");
 		buf.append("//c4\n");
 		buf.append("}\n");
 
@@ -668,6 +684,17 @@
 		buf= new StringBuffer();
 		buf.append("package test1;\n");
 		buf.append("public class C {\n");
+		buf.append("//c1\n");
+		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c3\n");
+		buf.append("\n");
+		buf.append("    \n");
 		buf.append("\n");
 		buf.append("//c4\n");
 		buf.append("}\n");
@@ -726,6 +753,10 @@
 		buf.append("\n");
 		buf.append("    void new1();\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    public void foo2();\n");
 		buf.append("\n");
 		buf.append("//c3\n");
@@ -797,6 +828,10 @@
 		buf.append("\n");
 		buf.append("    void new2();\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    public void foo2();\n");
 		buf.append("\n");
 		buf.append("//c3\n");
@@ -868,6 +903,10 @@
 		buf.append("\n");
 		buf.append("    void new2();\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c3\n");
+		buf.append("\n");
 		buf.append("    public void foo3();\n");
 		buf.append("\n");
 		buf.append("//c4\n");
@@ -928,6 +967,10 @@
 		buf.append("\n");
 		buf.append("    int new1;\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    public int x2;\n");
 		buf.append("\n");
 		buf.append("//c3\n");
@@ -998,6 +1041,10 @@
 		buf.append("\n");
 		buf.append("    int new2;\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    public int x2;\n");
 		buf.append("\n");
 		buf.append("//c3\n");
@@ -1069,6 +1116,10 @@
 		buf.append("\n");
 		buf.append("    int new2;\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c3\n");
+		buf.append("\n");
 		buf.append("    public int x3;\n");
 		buf.append("\n");
 		buf.append("//c4\n");
@@ -1131,6 +1182,10 @@
 		buf.append("\n");
 		buf.append("    void new1();\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    public void foo2();\n");
 		buf.append("\n");
 		buf.append("//c3\n");
@@ -1196,6 +1251,10 @@
 		buf.append("\n");
 		buf.append("    int new1;\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    public int x2;\n");
 		buf.append("\n");
 		buf.append("//c3\n");
@@ -1269,6 +1328,10 @@
 		buf.append("\n");
 		buf.append("    void new2();\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    public void foo2();\n");
 		buf.append("\n");
 		buf.append("//c3\n");
@@ -1343,6 +1406,10 @@
 		buf.append("\n");
 		buf.append("    int new2;\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    public int x2;\n");
 		buf.append("\n");
 		buf.append("//c3\n");
@@ -1409,6 +1476,14 @@
 		buf.append("\n");
 		buf.append("    void new1();\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c3\n");
+		buf.append("\n");
 		buf.append("    void new2();\n");
 		buf.append("\n");
 		buf.append("//c4\n");
@@ -1468,6 +1543,14 @@
 		buf.append("\n");
 		buf.append("    int new1;\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c3\n");
+		buf.append("\n");
 		buf.append("    int new2;\n");
 		buf.append("\n");
 		buf.append("//c4\n");
@@ -1530,8 +1613,16 @@
 		buf.append("\n");
 		buf.append("    void new1();\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    void new2();\n");
 		buf.append("\n");
+		buf.append("//c3\n");
+		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
 		buf.append("//c4\n");
 		buf.append("}\n");
 
@@ -1591,8 +1682,16 @@
 		buf.append("\n");
 		buf.append("    int new1;\n");
 		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("//c2\n");
+		buf.append("\n");
 		buf.append("    int new2;\n");
 		buf.append("\n");
+		buf.append("//c3\n");
+		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
 		buf.append("//c4\n");
 		buf.append("}\n");
 
@@ -1650,10 +1749,14 @@
 		rewrite.remove(f1, null);
 
 		String preview= evaluateRewrite(cu, rewrite);
-
+		// Note that c1 is absent because source range has been calculated from c1
 		buf= new StringBuffer();
 		buf.append("package test1;\n");
 		buf.append("public class C {\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("    //c2\n");
+		buf.append("\n");
 		buf.append("    public int x2;\n");
 		buf.append("\n");
 		buf.append("    //c3\n");
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingInsertTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingInsertTest.java
index 96b6dca..47a6898 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingInsertTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingInsertTest.java
@@ -516,4 +516,112 @@
 		buf.append("}\n");
 		assertEqualString(preview, buf.toString());
 	}
+	/**
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=317468
+	 */
+	public void test0013() throws Exception {
+		IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0013", false, null);
+		StringBuffer buf= new StringBuffer();
+		buf.append("package test0013;\n");
+		buf.append("public enum X {\n");
+		buf.append("	A, B,\n");
+		buf.append("}\n");
+		ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null);
+
+		CompilationUnit astRoot= createCU(cu, false, AST.JLS3);
+
+		astRoot.recordModifications();
+
+		AST ast = astRoot.getAST();
+
+		final List types = astRoot.types();
+		VariableDeclarationFragment fragment = ast.newVariableDeclarationFragment();
+		fragment.setName(ast.newSimpleName("field"));
+		final FieldDeclaration fieldDeclaration = ast.newFieldDeclaration(fragment);
+		fieldDeclaration.setType(ast.newPrimitiveType(PrimitiveType.INT));
+		((AbstractTypeDeclaration) types.get(0)).bodyDeclarations().add(fieldDeclaration);
+
+		String preview = evaluateRewrite(cu, astRoot);
+
+		buf= new StringBuffer();
+		buf.append("package test0013;\n");
+		buf.append("public enum X {\n");
+		buf.append("	A, B,;\n");
+		buf.append("\n");
+		buf.append("    int field;\n");
+		buf.append("}\n");
+		assertEqualString(preview, buf.toString());
+	}
+	/**
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=317468
+	 */
+	public void test0014() throws Exception {
+		IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0014", false, null);
+		StringBuffer buf= new StringBuffer();
+		buf.append("package test0014;\n");
+		buf.append("public enum X {\n");
+		buf.append("	;\n");
+		buf.append("}\n");
+		ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null);
+
+		CompilationUnit astRoot= createCU(cu, false, AST.JLS3);
+
+		astRoot.recordModifications();
+
+		AST ast = astRoot.getAST();
+
+		final List types = astRoot.types();
+		VariableDeclarationFragment fragment = ast.newVariableDeclarationFragment();
+		fragment.setName(ast.newSimpleName("field"));
+		final FieldDeclaration fieldDeclaration = ast.newFieldDeclaration(fragment);
+		fieldDeclaration.setType(ast.newPrimitiveType(PrimitiveType.INT));
+		((AbstractTypeDeclaration) types.get(0)).bodyDeclarations().add(fieldDeclaration);
+
+		String preview = evaluateRewrite(cu, astRoot);
+
+		buf= new StringBuffer();
+		buf.append("package test0014;\n");
+		buf.append("public enum X {\n");
+		buf.append("	;\n");
+		buf.append("\n");
+		buf.append("    int field;\n");
+		buf.append("}\n");
+		assertEqualString(preview, buf.toString());
+	}
+	/**
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=317468
+	 */
+	public void test0015() throws Exception {
+		IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0015", false, null);
+		StringBuffer buf= new StringBuffer();
+		buf.append("package test0015;\n");
+		buf.append("public enum X {\n");
+		buf.append("	A, B,;\n");
+		buf.append("}\n");
+		ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null);
+
+		CompilationUnit astRoot= createCU(cu, false, AST.JLS3);
+
+		astRoot.recordModifications();
+
+		AST ast = astRoot.getAST();
+
+		final List types = astRoot.types();
+		VariableDeclarationFragment fragment = ast.newVariableDeclarationFragment();
+		fragment.setName(ast.newSimpleName("field"));
+		final FieldDeclaration fieldDeclaration = ast.newFieldDeclaration(fragment);
+		fieldDeclaration.setType(ast.newPrimitiveType(PrimitiveType.INT));
+		((AbstractTypeDeclaration) types.get(0)).bodyDeclarations().add(fieldDeclaration);
+
+		String preview = evaluateRewrite(cu, astRoot);
+
+		buf= new StringBuffer();
+		buf.append("package test0015;\n");
+		buf.append("public enum X {\n");
+		buf.append("	A, B,;\n");
+		buf.append("\n");
+		buf.append("    int field;\n");
+		buf.append("}\n");
+		assertEqualString(preview, buf.toString());
+	}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingRemoveTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingRemoveTest.java
index 522af67..6320028 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingRemoveTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingRemoveTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -16,8 +16,11 @@
 
 import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.jdt.core.IPackageFragment;
-
-import org.eclipse.jdt.core.dom.*;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.Block;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
 
 public class ASTRewritingModifyingRemoveTest extends ASTRewritingModifyingTest {
 	private static final Class THIS = ASTRewritingModifyingRemoveTest.class;
@@ -407,6 +410,9 @@
 		buf.append("package test0010;\n");
 		buf.append("\n");
 		buf.append("public class X {\n");
+		buf.append("    // comment1\n");
+		buf.append("\n");
+		buf.append("    \n");
 		buf.append("\n");
 		buf.append("    // comment5\n");
 		buf.append("}\n");
@@ -458,4 +464,174 @@
 		buf.append("}\n");
 		assertEqualString(preview, buf.toString());
 	}
+	
+	/*
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=306524
+	 * To test that when types are removed, only the comments in the extended source range are
+	 * removed, and the rest are left untouched.
+	 */
+	public void test0012() throws Exception {
+		IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0012", false, null);
+		StringBuffer buf= new StringBuffer();
+		buf.append("package test0012;\n");
+		buf.append("public class X {\n");
+		buf.append("\n");
+		buf.append("    // one line comment1\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment2\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("    // one line comment3\n");
+		buf.append("    class X1{\n");
+		buf.append("    }\n");
+		buf.append("    // one line comment4\n");
+		buf.append("\n");
+		buf.append("\n");
+		buf.append("    // one line comment5\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment6\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment7\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("    // one line comment8\n");
+		buf.append("    // one line comment9\n");
+		buf.append("    class X2{\n");
+		buf.append("    }\n");
+		buf.append("    /*\n");
+		buf.append("     * comment10\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("    // one line comment11\n");
+		buf.append("    // one line comment12\n");
+		buf.append("}\n");
+		ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null);
+
+		CompilationUnit astRoot= createCU(cu, false);
+
+		astRoot.recordModifications();
+
+		List types = astRoot.types();
+		TypeDeclaration typeDeclaration = (TypeDeclaration)types.get(0);
+		TypeDeclaration [] members = typeDeclaration.getTypes();
+		typeDeclaration.bodyDeclarations().remove(members[0]);
+		typeDeclaration.bodyDeclarations().remove(members[1]);
+
+		String preview = evaluateRewrite(cu, astRoot);
+
+		buf= new StringBuffer();
+		buf.append("package test0012;\n");
+		buf.append("public class X {\n");
+		buf.append("\n");
+		buf.append("    // one line comment1\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment2\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("\n");
+		buf.append("    // one line comment5\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment6\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment7\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("    // one line comment11\n");
+		buf.append("    // one line comment12\n");
+		buf.append("}\n");
+		assertEqualString(preview, buf.toString());
+	}
+	
+	/*
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=306524
+	 * To test that when types are removed, only the comments in the extended source range are
+	 * removed, and the rest are left untouched. This test is for cases where type to be removed is the 
+	 * last one in file and there are more than one leading comments that are not part of its 
+	 * extended source range
+	 */
+	public void test0013() throws Exception {
+		IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0013", false, null);
+		StringBuffer buf= new StringBuffer();
+		buf.append("package test0013;\n");
+		buf.append("public class X {\n");
+		buf.append("\n");
+		buf.append("    // one line comment1a\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment2\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("    // one line comment1b\n");
+		buf.append("\n");
+		buf.append("    // one line comment3\n");
+		buf.append("    class X1{\n");
+		buf.append("    }\n");
+		buf.append("    // one line comment4\n");
+		buf.append("\n");
+		buf.append("\n");
+		buf.append("    // one line comment5\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment6\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment7\n");
+		buf.append("     */\n");
+		buf.append("}\n");
+		ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null);
+
+		CompilationUnit astRoot= createCU(cu, false);
+
+		astRoot.recordModifications();
+
+		List types = astRoot.types();
+		TypeDeclaration typeDeclaration = (TypeDeclaration)types.get(0);
+		TypeDeclaration [] members = typeDeclaration.getTypes();
+		typeDeclaration.bodyDeclarations().remove(members[0]);
+
+		String preview = evaluateRewrite(cu, astRoot);
+		buf= new StringBuffer();
+		buf.append("package test0013;\n");
+		buf.append("public class X {\n");
+		buf.append("\n");
+		buf.append("    // one line comment1a\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment2\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("    // one line comment1b\n");
+		buf.append("\n");
+		buf.append("    \n");
+		buf.append("\n");
+		buf.append("\n");
+		buf.append("    // one line comment5\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment6\n");
+		buf.append("     */\n");
+		buf.append("\n");
+		buf.append("\n");
+		buf.append("    /*\n");
+		buf.append("     * comment7\n");
+		buf.append("     */\n");
+		buf.append("}\n");
+		assertEqualString(preview, buf.toString());
+	}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingTest.java
index 1624839..436c2d7 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingTest.java
@@ -64,7 +64,7 @@
 	public void setUpSuite() throws Exception {
 		super.setUpSuite();
 
-		this.javaProject = createJavaProject("P", new String[] {"src"}, "bin");
+		this.javaProject = createJavaProject("P", new String[] {"src"}, null, "bin", "1.5");
 		this.sourceFolder = getPackageFragmentRoot("P", "src");
 
 		Hashtable options = JavaCore.getOptions();
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachedJavadocProject/malformedDoc/p1/p2/X.html b/org.eclipse.jdt.core.tests.model/workspace/AttachedJavadocProject/malformedDoc/p1/p2/X.html
new file mode 100644
index 0000000..04f5030
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/AttachedJavadocProject/malformedDoc/p1/p2/X.html
@@ -0,0 +1,440 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--NewPage-->
+<HTML>
+<HEAD>
+<!-- Generated by javadoc (build 1.5.0_07) on Mon Jun 05 12:35:07 CEST 2006 -->
+<TITLE>
+X
+</TITLE>
+
+<META NAME="keywords" CONTENT="p1.p2.X class">
+
+<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
+
+<SCRIPT type="text/javascript">
+function windowTitle()
+{
+    parent.document.title="X";
+}
+</SCRIPT>
+<NOSCRIPT>
+</NOSCRIPT>
+
+</HEAD>
+
+<BODY BGCOLOR="white" onload="windowTitle();">
+
+
+<!- ========= START OF TOP NAVBAR ======= -->
+<A NAME="navbar_top"><!-- --></A>
+<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
+<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
+<TR>
+<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
+<A NAME="navbar_top_firstrow"><!-- --></A>
+<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
+  <TR ALIGN="center" VALIGN="top">
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/X.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
+  </TR>
+</TABLE>
+</TD>
+<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
+</EM>
+</TD>
+</TR>
+
+<TR>
+<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
+&nbsp;<A HREF="../../p1/p2/TestClass.html" title="class in p1.p2"><B>PREV CLASS</B></A>&nbsp;
+&nbsp;<A HREF="../../p1/p2/X.A.html" title="class in p1.p2"><B>NEXT CLASS</B></A></FONT></TD>
+<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
+  <A HREF="../../index.html?p1/p2/X.html" target="_top"><B>FRAMES</B></A>  &nbsp;
+&nbsp;<A HREF="X.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
+&nbsp;<SCRIPT type="text/javascript">
+  <!--
+  if(window==top) {
+    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
+  }
+  //-->
+</SCRIPT>
+<NOSCRIPT>
+  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
+</NOSCRIPT>
+
+
+</FONT></TD>
+</TR>
+<TR>
+<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
+  SUMMARY:&nbsp;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
+<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
+DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
+</TR>
+</TABLE>
+<A NAME="skip-navbar_top"></A>
+<!- ========= END OF TOP NAVBAR ========= -->
+
+<HR>
+<!- ======== START OF CLASS DATA ======== -->
+<H2>
+<FONT SIZE="-1">
+p1.p2</FONT>
+<BR>
+Class X</H2>
+<PRE>
+java.lang.Object
+  <IMG SRC="../../resources/inherit.gif" ALT="extended by "><B>p1.p2.X</B>
+</PRE>
+<HR>
+<DL>
+<DT><PRE>public class <B>X</B><DT>extends java.lang.Object</DL>
+</PRE>
+
+<P>
+Class X javadoc
+<P>
+
+<P>
+<HR>
+
+<P>
+<!- ======== NESTED CLASS SUMMARY ======== -->
+
+<A NAME="nested_class_summary"><!-- --></A>
+<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
+<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
+<B>Nested Class Summary</B></FONT></TH>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;class</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../p1/p2/X.A.html" title="class in p1.p2">X.A</A></B></CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Javadoc for member type A</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;class</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../p1/p2/X.B.html" title="class in p1.p2">X.B</A></B></CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
+</TR>
+</TABLE>
+&nbsp;<!- =========== FIELD SUMMARY =========== -->
+
+<A NAME="field_summary"><!-- --></A>
+<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
+<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
+<B>Field Summary</B></FONT></TH>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../p1/p2/X.html#f">f</A></B></CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Javadoc for field f</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../p1/p2/X.html#f2">f2</A></B></CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../p1/p2/X.html#f3">f3</A></B></CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Real javadoc for f3</TD>
+</TR>
+</TABLE>
+&nbsp;
+<!- ======== CONSTRUCTOR SUMMARY ======== -->
+
+<A NAME="constructor_summary"><!-- --></A>
+<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
+<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
+<B>Constructor Summary</B></FONT></TH>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD><CODE><B><A HREF="../../p1/p2/X.html#X(int)">X</A></B>(int&nbsp;i)</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Javadoc for constructor X(int)</TD>
+</TR>
+</TABLE>
+&nbsp;
+<!- ========== METHOD SUMMARY =========== -->
+
+<A NAME="method_summary"><!-- --></A>
+<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
+<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
+<B>Method Summary</B></FONT></TH>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;void</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../p1/p2/X.html#bar(java.util.ArrayList)">bar</A></B>(java.util.ArrayList&lt;java.lang.String&gt;&nbsp;array)</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;void</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../p1/p2/X.html#foo(java.util.Enumeration)">foo</A></B>(java.util.Enumeration&nbsp;enumeration)</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;void</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../p1/p2/X.html#foo(int, long, java.lang.String)">foo</A></B>(int&nbsp;i,
+    long&nbsp;l,
+    java.lang.String&nbsp;s)</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Javadoc for method foo</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;void</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../p1/p2/X.html#foo2()">foo2</A></B>()</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;void</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../p1/p2/X.html#foo2(java.lang.Integer)">foo2</A></B>(java.lang.Integer&nbsp;i)</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Javadoc for method foo2</TD>
+</TR>
+</TABLE>
+&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
+<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
+<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
+<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD><CODE>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
+</TR>
+</TABLE>
+&nbsp;
+<P>
+
+<!- ============ FIELD DETAIL =========== -->
+
+<A NAME="field_detail"><!-- --></A>
+<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
+<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
+<B>Field Detail</B></FONT></TH>
+</TR>
+</TABLE>
+
+<A NAME="f"><!-- --></A><H3>
+f</H3>
+<PRE>
+public int <B>f</B></PRE>
+<DL>
+<DD>Javadoc for field f
+<P>
+<DL>
+</DL>
+</DL>
+<HR>
+
+<A NAME="f3"><!-- --></A><H3>
+f3</H3>
+<PRE>
+public java.lang.String <B>f3</B></PRE>
+<DL>
+<DD>Real javadoc for f3
+<P>
+<DL>
+</DL>
+</DL>
+<HR>
+
+<A NAME="f2"><!-- --></A><H3>
+f2</H3>
+<PRE>
+public int <B>f2</B></PRE>
+<DL>
+<DL>
+</DL>
+</DL>
+
+<!- ========= CONSTRUCTOR DETAIL ======== -->
+
+<A NAME="constructor_detail"><!-- --></A>
+<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
+<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
+<B>Constructor Detail</B></FONT></TH>
+</TR>
+</TABLE>
+
+<A NAME="X(int)"><!-- --></A><H3>
+X</H3>
+<PRE>
+public <B>X</B>(int&nbsp;i)</PRE>
+<DL>
+<DD>Javadoc for constructor X(int)
+<P>
+</DL>
+
+<!- ============ METHOD DETAIL ========== -->
+
+<A NAME="method_detail"><!-- --></A>
+<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
+<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
+<B>Method Detail</B></FONT></TH>
+</TR>
+</TABLE>
+
+<A NAME="foo(int, long, java.lang.String)"><!-- --></A><H3>
+foo</H3>
+<PRE>
+public void <B>foo</B>(int&nbsp;i,
+                long&nbsp;l,
+                java.lang.String&nbsp;s)</PRE>
+<DL>
+<DD>Javadoc for method foo
+<P>
+<DD><DL>
+<DT><B>Parameters:</B><DD><CODE>i</CODE> - the given int<DD><CODE>l</CODE> - the given long<DD><CODE>s</CODE> - the given string</DL>
+</DD>
+</DL>
+<HR>
+
+<A NAME="foo2(java.lang.Integer)"><!-- --></A><H3>
+foo2</H3>
+<PRE>
+public void <B>foo2</B>(java.lang.Integer&nbsp;i)</PRE>
+<DL>
+<DD>Javadoc for method foo2
+<P>
+<DD><DL>
+</DL>
+</DD>
+</DL>
+<HR>
+
+<A NAME="foo2()"><!-- --></A><H3>
+foo2</H3>
+<PRE>
+public void <B>foo2</B>()</PRE>
+<DL>
+<DD><DL>
+</DL>
+</DD>
+</DL>
+<HR>
+
+<A NAME="foo(java.util.Enumeration)"><!-- --></A><H3>
+foo</H3>
+<PRE>
+public void <B>foo</B>(java.util.Enumeration&nbsp;enumeration)</PRE>
+<DL>
+<DD><DL>
+</DL>
+</DD>
+</DL>
+<HR>
+
+<A NAME="bar(java.util.ArrayList)"><!-- --></A><H3>
+bar</H3>
+<PRE>
+public void <B>bar</B>(java.util.ArrayList&lt;java.lang.String&gt;&nbsp;array)</PRE>
+<DL>
+<DD><DL>
+</DL>
+</DD>
+</DL>
+<!- ========= END OF CLASS DATA ========= -->
+<HR>
+
+
+<!- ======= START OF BOTTOM NAVBAR ====== -->
+<A NAME="navbar_bottom"><!-- --></A>
+<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
+<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
+<TR>
+<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
+<A NAME="navbar_bottom_firstrow"><!-- --></A>
+<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
+  <TR ALIGN="center" VALIGN="top">
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/X.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
+  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
+  </TR>
+</TABLE>
+</TD>
+<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
+</EM>
+</TD>
+</TR>
+
+<TR>
+<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
+&nbsp;<A HREF="../../p1/p2/TestClass.html" title="class in p1.p2"><B>PREV CLASS</B></A>&nbsp;
+&nbsp;<A HREF="../../p1/p2/X.A.html" title="class in p1.p2"><B>NEXT CLASS</B></A></FONT></TD>
+<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
+  <A HREF="../../index.html?p1/p2/X.html" target="_top"><B>FRAMES</B></A>  &nbsp;
+&nbsp;<A HREF="X.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
+&nbsp;<SCRIPT type="text/javascript">
+  <!--
+  if(window==top) {
+    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
+  }
+  //-->
+</SCRIPT>
+<NOSCRIPT>
+  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
+</NOSCRIPT>
+
+
+</FONT></TD>
+</TR>
+<TR>
+<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
+  SUMMARY:&nbsp;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
+<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
+DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
+</TR>
+</TABLE>
+<A NAME="skip-navbar_bottom"></A>
+<!- ======== END OF BOTTOM NAVBAR ======= -->
+
+<HR>
+
+</BODY>
+</HTML>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Completion/b317264/org.apache.commons.lang_2.modified.jar b/org.eclipse.jdt.core.tests.model/workspace/Completion/b317264/org.apache.commons.lang_2.modified.jar
new file mode 100644
index 0000000..03ffbf6
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Completion/b317264/org.apache.commons.lang_2.modified.jar
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/ExternalContainer/.classpath b/org.eclipse.jdt.core.tests.model/workspace/ExternalContainer/.classpath
new file mode 100644
index 0000000..b455d88
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/ExternalContainer/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.core.tests.model.TEST_EXTERNAL_LIB_CONTAINER"/>
+	<classpathentry kind="var" path="JCL_LIB"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/ExternalContainer/.project b/org.eclipse.jdt.core.tests.model/workspace/ExternalContainer/.project
new file mode 100644
index 0000000..e774b6c
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/ExternalContainer/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ExternalContainer</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/ExternalContainer/src/p2/X.java b/org.eclipse.jdt.core.tests.model/workspace/ExternalContainer/src/p2/X.java
new file mode 100644
index 0000000..bacbc84
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/ExternalContainer/src/p2/X.java
@@ -0,0 +1,5 @@
+package p2;
+import p.Y;
+public class X {
+    Y y;
+}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/lib/b317264/org.apache.commons.lang_2.modified.jar b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/lib/b317264/org.apache.commons.lang_2.modified.jar
new file mode 100644
index 0000000..03ffbf6
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/lib/b317264/org.apache.commons.lang_2.modified.jar
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/TypeHierarchyNotification/.classpath b/org.eclipse.jdt.core.tests.model/workspace/TypeHierarchyNotification/.classpath
index dce3aa7..7c4a41c 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/TypeHierarchyNotification/.classpath
+++ b/org.eclipse.jdt.core.tests.model/workspace/TypeHierarchyNotification/.classpath
@@ -3,5 +3,6 @@
     <classpathentry kind="src" path="src"/>
     <classpathentry kind="var" path="JCL_LIB" sourcepath="JCL_SRC" rootpath="JCL_SRCROOT"/>
     <classpathentry kind="lib" path="lib.jar"/>
+    <classpathentry kind="lib" path="test316654.jar"/>
     <classpathentry kind="output" path="bin"/>
 </classpath>