Updated to 8c030d505f30b0cafedd9f4204a10256b97739b1 from jdt.core
- parser not yet re-generated, fixmes remain in
  - java.g
  - Parser.java
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
index a47ae86..4186565 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
@@ -1084,12 +1084,12 @@
 		expected13ProblemLog;
 
 	String expected15ProblemLog =
-		"----------\n" +
-		"1. ERROR in X.java (at line 1)\n" +
-		"	import static for;\n" +
-		"	              ^^^\n" +
-		"Syntax error on token \"for\", Identifier expected\n" +
-		"----------\n";
+			"----------\n" + 
+			"1. ERROR in X.java (at line 1)\n" + 
+			"	import static for;\n" + 
+			"	              ^^^\n" + 
+			"Syntax error on token \"for\", invalid Name\n" + 
+			"----------\n";
 
 	runComplianceParserTest(
 		testFiles,
@@ -1312,7 +1312,7 @@
 		expected15ProblemLog
 	);
 }
-public void _test0029() {
+public void test0029() {
 	String[] testFiles = new String[] {
 		"X.java",
 		"public class X {\n" +
@@ -1773,7 +1773,7 @@
 		expected15ProblemLog
 	);
 }
-public void _test0038() {
+public void test0038() {
 	String[] testFiles = new String[] {
 		"X.java",
 		"public class X {\n" +
@@ -1855,7 +1855,7 @@
 		expected15ProblemLog
 	);
 }
-public void _test0040() {
+public void test0040() {
 	String[] testFiles = new String[] {
 		"X.java",
 		"public class X {\n" +
@@ -1898,7 +1898,7 @@
 		expected15ProblemLog
 	);
 }
-public void _test0041() {
+public void test0041() {
 	String[] testFiles = new String[] {
 		"X.java",
 		"public class X {\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
index 1ebb661..ba11373 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
@@ -5,6 +5,10 @@
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  * 
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ * 
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *     Technical University Berlin - adapted for Object Teams
@@ -4580,7 +4584,7 @@
  * Bunch of syntax errors
  */
 
-public void _test75() {
+public void test75() {
 
 	String s =
 		"package ZKentTest;\n"+
@@ -4646,14 +4650,14 @@
 		"        super();\n" +
 		"      }\n" +
 		"      int hello() {\n" +
-		"        fo = $missing$;\n" +
+		"        fo $missing$;\n" +
 		"      }\n" +
 		"      int world() {\n" +
 		"      }\n" +
 		"      void foo() {\n" +
 		"      }\n" +
 		"    }\n" +
-		"    ba = $missing$;\n" +
+		"    ba $missing$;\n" +
 		"  }\n" +
 		"}\n";
 
@@ -4776,7 +4780,7 @@
  * Should not recover duplicate field numberOfDisks
  */
 
-public void _test77() {
+public void test77() {
 
 	String s =
 		"package p;															\n"+
@@ -4848,7 +4852,7 @@
 		"    else\n" +
 		"        if ((depth > 1))\n" +
 		"            {\n" +
-		"              sol = $missing$;\n" +
+		"              sol $missing$;\n" +
 		"            }\n" +
 		"        else\n" +
 		"            ;\n" +
@@ -5951,7 +5955,7 @@
 		expectedCompletionDietUnitToString, testName);
 }
 
-public void _test99() {
+public void test99() {
 	String s =
 		"import ;\n"+
 		"class X {\n"+
@@ -6003,7 +6007,7 @@
 		"    restricts breakpoint;\n" +
 		"    given thread;\n" +
 		"    any other;\n" +
-		"    specified = $missing$;\n" +
+		"    specified $missing$;\n" +
 		"  }\n" +
 		"  public void removeThreadFilter(IJavaThread thread) {\n" +
 		"    removes the;\n" +
@@ -6014,7 +6018,7 @@
 		"    request as;\n" +
 		"    does not;\n" +
 		"    the removal;\n" +
-		"    thread = $missing$;\n" +
+		"    thread $missing$;\n" +
  :giro */
 // SH}		
 		"  }\n" +
@@ -6582,7 +6586,7 @@
 		expectedFullUnitToString,
 		expectedCompletionDietUnitToString, testName);
 }
-public void test110() {
+public void _test110() {
 	String s =
 		"public class X {\n" +
 		"	void bar(){\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
index 55209fb..bf903fa 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
@@ -1,9 +1,13 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
@@ -949,7 +953,7 @@
 		expectedFullUnitToString,
 		expectedCompletionDietUnitToString, testName);
 }
-public void test0019() {
+public void _test0019() {
 
 	String s =
 		"package a;											\n"
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
index fa46308..a4651ea 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
@@ -5,6 +5,10 @@
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ * 
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
@@ -61,7 +65,7 @@
 		"----------\n"
 	);
 }
-public void _test003() {
+public void test003() {
 	this.runNegativeTest(
 		new String[] {
 			"X.java",
@@ -71,18 +75,22 @@
 			"	}\n" +
 			"}\n"
 		},
-		"----------\n" +
-		"1. ERROR in X.java (at line 3)\n" +
-		"	throws new X\n" +
-		"	^^^^^^\n" +
-		"Syntax error on token \"throws\", throw expected\n" +
-		"----------\n" +
-		"2. ERROR in X.java (at line 3)\n" +
-		"	throws new X\n" +
-		"	           ^\n" +
-		"Syntax error, unexpected end of method\n" +
-		"----------\n"
-	);
+		"----------\n" + 
+		"1. ERROR in X.java (at line 3)\n" + 
+		"	throws new X\n" + 
+		"	^^^^^^\n" + 
+		"Syntax error on token \"throws\", throw expected\n" + 
+		"----------\n" + 
+		"2. ERROR in X.java (at line 3)\n" + 
+		"	throws new X\n" + 
+		"	           ^\n" + 
+		"Syntax error, insert \"( )\" to complete Expression\n" + 
+		"----------\n" + 
+		"3. ERROR in X.java (at line 3)\n" + 
+		"	throws new X\n" + 
+		"	           ^\n" + 
+		"Syntax error, insert \";\" to complete BlockStatements\n" + 
+		"----------\n");
 }
 public void test004() {
 	this.runNegativeTest(
@@ -120,7 +128,7 @@
 		"----------\n"
 	);
 }
-public void _test006() {
+public void test006() {
 	this.runNegativeTest(
 		new String[] {
 			"X.java",
@@ -130,18 +138,22 @@
 			"	}\n" +
 			"}\n"
 		},
-		"----------\n" +
-		"1. ERROR in X.java (at line 3)\n" +
-		"	throws new X\n" +
-		"	^^^^^^\n" +
-		"Syntax error on token \"throws\", throw expected\n" +
-		"----------\n" +
-		"2. ERROR in X.java (at line 3)\n" +
-		"	throws new X\n" +
-		"	           ^\n" +
-		"Syntax error, unexpected end of initializer\n" +
-		"----------\n"
-	);
+		"----------\n" + 
+		"1. ERROR in X.java (at line 3)\n" + 
+		"	throws new X\n" + 
+		"	^^^^^^\n" + 
+		"Syntax error on token \"throws\", throw expected\n" + 
+		"----------\n" + 
+		"2. ERROR in X.java (at line 3)\n" + 
+		"	throws new X\n" + 
+		"	           ^\n" + 
+		"Syntax error, insert \"( )\" to complete Expression\n" + 
+		"----------\n" + 
+		"3. ERROR in X.java (at line 3)\n" + 
+		"	throws new X\n" + 
+		"	           ^\n" + 
+		"Syntax error, insert \";\" to complete BlockStatements\n" + 
+		"----------\n");
 }
 public void test007() {
 	this.runNegativeTest(
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
index 3870ac9..c2e7612 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
@@ -973,83 +973,11 @@
 				"}\n";
 		checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test385374", expectedUnitToString);
 	}
-	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=385374, Support for 308 style type annotations on 335 constructs - make sure illegal modifiers are rejected
+	/* https://bugs.eclipse.org/bugs/show_bug.cgi?id=385374, Support for 308 style type annotations on 335 constructs - make sure illegal modifiers are rejected
+	   This test has been rendered meaningless as the grammar has been so throughly changed - Type annotations are not accepted via modifiers in the first place.
+	   Disabling this test as we don't want fragile and unstable tests that are at the whimsy of the diagnose parser's complex algorithms. 
+	*/
 	public void test385374a() throws IOException {
-		String source = 
-				"interface I {\n" +
-				"	void foo();\n" +
-				"}\n" +
-				"@interface TypeAnnotation {\n" +
-				"}\n" +
-				"\n" +
-				"class X<T> {\n" +
-				"	 // Primitive array form\n" +
-				"	 I x1 = public @TypeAnnotation int []::clone;\n" +
-				"	 // Primitive array form with dimension annotations.\n" +
-				"	 I x2 = @TypeAnnotation public int @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" +
-				"	 // Primitive array form with dimension annotations and type parameter annotations.\n" +
-				"	 I x3 = public @TypeAnnotation int @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
-				"	 // Reference type name form\n" +
-				"	 I x4 = @TypeAnnotation public X::clone;\n" +
-				"	 // Reference type name array form\n" +
-				"	 I x5 = public @TypeAnnotation X []::clone;\n" +
-				"	 // Reference type name array form with dimension annotations.\n" +
-				"	 I x6 = @TypeAnnotation public X @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" +
-				"	 // Reference type name array form with dimension annotations and type parameter annotations.\n" +
-				"	 I x7 = public @TypeAnnotation X @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
-				"	 // Generic type array form with dimension annotations and type parameter annotations.\n" +
-				"	 I x8 = public @TypeAnnotation X<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
-				"	 // Qualified generic type array form with dimension annotations and type parameter annotations.\n" +
-				"	 I x9 = public @TypeAnnotation X<@TypeParameterAnnotation String>.Y<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
-				"}\n";
-		
-		String expectedErrorString = 
-				"----------\n" +
-				"1. ERROR in test385374a (at line 9)\n" +
-				"	I x1 = public @TypeAnnotation int []::clone;\n" +
-				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
-				"Syntax error, modifiers are illegal here\n" +
-				"----------\n" +
-				"2. ERROR in test385374a (at line 11)\n" +
-				"	I x2 = @TypeAnnotation public int @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" +
-				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
-				"Syntax error, modifiers are illegal here\n" +
-				"----------\n" +
-				"3. ERROR in test385374a (at line 13)\n" +
-				"	I x3 = public @TypeAnnotation int @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
-				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
-				"Syntax error, modifiers are illegal here\n" +
-				"----------\n" +
-				"4. ERROR in test385374a (at line 15)\n" +
-				"	I x4 = @TypeAnnotation public X::clone;\n" +
-				"	       ^^^^^^^^^^^^^^^^^^^^^^^^\n" +
-				"Syntax error, modifiers are illegal here\n" +
-				"----------\n" +
-				"5. ERROR in test385374a (at line 17)\n" +
-				"	I x5 = public @TypeAnnotation X []::clone;\n" +
-				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
-				"Syntax error, modifiers are illegal here\n" +
-				"----------\n" +
-				"6. ERROR in test385374a (at line 19)\n" +
-				"	I x6 = @TypeAnnotation public X @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" +
-				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
-				"Syntax error, modifiers are illegal here\n" +
-				"----------\n" +
-				"7. ERROR in test385374a (at line 21)\n" +
-				"	I x7 = public @TypeAnnotation X @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
-				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
-				"Syntax error, modifiers are illegal here\n" +
-				"----------\n" +
-				"8. ERROR in test385374a (at line 23)\n" +
-				"	I x8 = public @TypeAnnotation X<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
-				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
-				"Syntax error, modifiers are illegal here\n" +
-				"----------\n" +
-				"9. ERROR in test385374a (at line 25)\n" +
-				"	I x9 = public @TypeAnnotation X<@TypeParameterAnnotation String>.Y<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
-				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
-				"Syntax error, modifiers are illegal here\n" +
-				"----------\n";
-		checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), expectedErrorString, "test385374a", null);
+		// Nop.
 	}
-}
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
index cef2b72..cd7cf9d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
@@ -5,6 +5,10 @@
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ * 
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *     Technical University Berlin - adapted for Object Teams
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java
index 07e8c82..a06cb41 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java
@@ -45,6 +45,9 @@
 	private static String  jsr308TestScratchArea = "c:\\Jsr308TestScratchArea";
 	private static String referenceCompiler = "C:\\jdk-7-ea-bin-b75-windows-i586-30_oct_2009\\jdk7\\bin\\javac.exe";
 	
+	static {
+//		TESTS_NAMES = new String [] { "test0137" };
+	}
 	public static Class testClass() {
 		return TypeAnnotationSyntaxTest.class;
 	}
@@ -687,19 +690,14 @@
 					"    return 0;\n" +
 					"}\n" +
 					"}\n";
-	String expectedUnitToString = 
-		"class A {\n" + 
-		"  A() {\n" + 
-		"    super();\n" + 
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>@Marker int foo() {\n" + 
-		"    return 0;\n" +
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>int bar() {\n" + 
-		"    return 0;\n" +
-		"  }\n" + 
-		"}\n";
-	checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0026", expectedUnitToString);
+	String expectedError = 
+			"----------\n" +
+			"1. ERROR in test0026 (at line 2)\n" +
+			"	public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker int foo() {\n" +
+			"	                                                                ^^^^^^^\n" +
+			"Syntax error, type annotations are illegal here\n" +
+			"----------\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0026", null);
 }
 // Type
 public void test0027() throws IOException {
@@ -711,19 +709,14 @@
 					"    return null;\n" +
 					"}\n" +
 					"}\n";
-	String expectedUnitToString = 
-		"class A {\n" + 
-		"  A() {\n" + 
-		"    super();\n" + 
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>@Marker String foo() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>String bar() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"}\n";
-	checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0027", expectedUnitToString);
+	String expectedError = 
+			"----------\n" +
+			"1. ERROR in test0027 (at line 2)\n" +
+			"	public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker String foo() {\n" +
+			"	                                                                ^^^^^^^\n" +
+			"Syntax error, type annotations are illegal here\n" +
+			"----------\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0027", null);
 }
 //Type
 public void test0028() throws IOException {
@@ -735,19 +728,14 @@
 					"    return null;\n" +
 					"}\n" +
 					"}\n";
-	String expectedUnitToString = 
-		"class A {\n" + 
-		"  A() {\n" + 
-		"    super();\n" + 
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>@Marker HashMap<@Readonly String, Object> foo() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>HashMap<String, @NonNull Object> bar() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"}\n";
-	checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0028", expectedUnitToString);
+	String expectedError = 
+			"----------\n" +
+			"1. ERROR in test0028 (at line 2)\n" +
+			"	public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object> foo() {\n" +
+			"	                                                                ^^^^^^^\n" +
+			"Syntax error, type annotations are illegal here\n" +
+			"----------\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0028", null);
 }
 // Type
 public void test0029() throws IOException {
@@ -759,19 +747,14 @@
 					"    return null;\n" +
 					"}\n" +
 					"}\n";
-	String expectedUnitToString = 
-		"class A {\n" + 
-		"  A() {\n" + 
-		"    super();\n" + 
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator foo() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>HashMap<String, @NonNull Object>.Iterator bar() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"}\n";
-	checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0029", expectedUnitToString);
+	String expectedError = 
+			"----------\n" +
+			"1. ERROR in test0029 (at line 2)\n" +
+			"	public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator foo() {\n" +
+			"	                                                                ^^^^^^^\n" +
+			"Syntax error, type annotations are illegal here\n" +
+			"----------\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0029", null);
 }
 //Type
 public void test0030() throws IOException {
@@ -783,19 +766,14 @@
 					"    return null;\n" +
 					"}\n" +
 					"}\n";
-	String expectedUnitToString = 
-		"class A {\n" + 
-		"  A() {\n" + 
-		"    super();\n" + 
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator[] @NonEmpty [][] foo() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>HashMap<String, @NonNull Object>.Iterator[] @NonEmpty [][] bar() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"}\n";
-	checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0030", expectedUnitToString);
+	String expectedError = 
+			"----------\n" +
+			"1. ERROR in test0030 (at line 2)\n" +
+			"	public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator[] @NonEmpty[][] foo() {\n" +
+			"	                                                                ^^^^^^^\n" +
+			"Syntax error, type annotations are illegal here\n" +
+			"----------\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0030", null);
 }
 //Type
 public void test0031() throws IOException {
@@ -807,19 +785,14 @@
 					"    return 0;\n" +
 					"}\n" +
 					"}\n";
-	String expectedUnitToString = 
-		"class A {\n" + 
-		"  A() {\n" + 
-		"    super();\n" + 
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>@Marker int[] @NonEmpty [][] foo() {\n" + 
-		"    return 0;\n" +
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>int[] @NonEmpty [][] bar() {\n" + 
-		"    return 0;\n" +
-		"  }\n" + 
-		"}\n";
-	checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0031", expectedUnitToString);
+	String expectedError = 
+			"----------\n" +
+			"1. ERROR in test0031 (at line 2)\n" +
+			"	public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker int[] @NonEmpty[][] foo() {\n" +
+			"	                                                                ^^^^^^^\n" +
+			"Syntax error, type annotations are illegal here\n" +
+			"----------\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0031", null);
 }
 // Type
 public void test0032() throws IOException {
@@ -831,19 +804,14 @@
 					"    return null;\n" +
 					"}\n" +
 					"}\n";
-	String expectedUnitToString = 
-		"class A {\n" + 
-		"  A() {\n" + 
-		"    super();\n" + 
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>@Marker String[] @NonEmpty [][] foo() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>String[] @NonEmpty [][] bar() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"}\n";
-	checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0032", expectedUnitToString);
+	String expectedError = 
+			"----------\n" +
+			"1. ERROR in test0032 (at line 2)\n" +
+			"	public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker String[]@NonEmpty[][] foo() {\n" +
+			"	                                                                ^^^^^^^\n" +
+			"Syntax error, type annotations are illegal here\n" +
+			"----------\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0032", null);
 }
 //Type
 public void test0033() throws IOException {
@@ -855,19 +823,14 @@
 					"    return null;\n" +
 					"}\n" +
 					"}\n";
-	String expectedUnitToString = 
-		"class A {\n" + 
-		"  A() {\n" + 
-		"    super();\n" + 
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>@Marker HashMap<@Readonly String, Object>[] @NonEmpty [][] foo() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"  public <Integer, @Positive Integer, @Negative Integer, Integer>HashMap<String, @NonNull Object>[] @NonEmpty [][] bar() {\n" + 
-		"    return null;\n" +
-		"  }\n" + 
-		"}\n";
-	checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0033", expectedUnitToString);
+	String expectedError = 
+			"----------\n" +
+			"1. ERROR in test0033 (at line 2)\n" +
+			"	public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>[] @NonEmpty[][] foo() {\n" +
+			"	                                                                ^^^^^^^\n" +
+			"Syntax error, type annotations are illegal here\n" +
+			"----------\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0033", null);
 }
 // Type0 field declaration.
 public void test0034() throws IOException {
@@ -2915,22 +2878,14 @@
 		"		new @Marker @SingleMember(10) X().new <@Readonly String> @Marker MX(\"SUCCESS\");\n" +
 		"	}\n" +
 		"}\n";
-	String expectedUnitToString =
-		"class X {\n" +
-		"  class MX {\n" +
-		"    @Marker <T>MX(T t) {\n" +
-		"      super();\n" +
-		"      System.out.println(t);\n" +
-		"    }\n" +
-		"  }\n" +
-		"  X() {\n" +
-		"    super();\n" +
-		"  }\n" +
-		"  public static void main(String[] args) {\n" +
-		"    new @Marker @SingleMember(10) X().new <@Readonly String>@Marker MX(\"SUCCESS\");\n" +
-		"  }\n" +
-		"}\n";
-	checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER & ~CHECK_DOCUMENT_ELEMENT_PARSER, source.toCharArray(), null, "test0110", expectedUnitToString );
+	String expectedError =
+			"----------\n" +
+			"1. ERROR in test0110 (at line 8)\n" +
+			"	new @Marker @SingleMember(10) X().new <@Readonly String> @Marker MX(\"SUCCESS\");\n" +
+			"	                                                         ^^^^^^^\n" +
+			"Syntax error, type annotations are illegal here\n" +
+			"----------\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0110", null );
 }
 
 // To test Parser.consumeClassInstanceCreationExpressionWithTypeArguments()
@@ -2945,17 +2900,14 @@
 		"		new <@Readonly String> @Marker @SingleMember(0) X(\"SUCCESS\");\n" +
 		"	}\n" +
 		"}\n";
-	String expectedUnitToString =
-		"class X {\n" +
-		"  public <T>X(T t) {\n" +
-		"    super();\n" +
-		"    System.out.println(t);\n" +
-		"  }\n" +
-		"  public static void main(String[] args) {\n" +
-		"    new <@Readonly String>@Marker @SingleMember(0) X(\"SUCCESS\");\n" +
-		"  }\n" +
-		"}\n";
-	checkParse(CHECK_ALL & ~CHECK_DOCUMENT_ELEMENT_PARSER, source.toCharArray(), null, "test0111", expectedUnitToString );
+	String expectedError =
+			"----------\n" +
+			"1. ERROR in test0111 (at line 6)\n" +
+			"	new <@Readonly String> @Marker @SingleMember(0) X(\"SUCCESS\");\n" +
+			"	                       ^^^^^^^^^^^^^^^^^^^^^\n" +
+			"Syntax error, type annotations are illegal here\n" +
+			"----------\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0111", null);
 }
 
 // To test Parser.consumeEnhancedForStatementHeaderInit() with Type Annotations
@@ -3774,4 +3726,57 @@
 			"}\n";
 	checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
 }
+// Support type annotations for wildcard
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=388085
+public void test0137() throws IOException {
+	String source = 
+			"class X {\n" +
+			"	public void main(Four<@Marker ? super String, @Marker ? extends Object> param) {\n" +
+			"		One<@Marker ? extends Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String,@Marker ? extends Object>>>> one = null;\n" +
+			"		Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String,@Marker ? extends Object>>> two = null;\n" +
+			"		Three<@Marker ? extends Four<@Marker ? super String,@Marker ? extends Object>> three = null;\n" +
+			"		Four<@Marker ? super String,@Marker ? extends Object> four = param;\n" +
+			"	}\n" +
+			"}\n" +
+			"class One<R> {}\n" +
+			"class Two<S> {}\n" +
+			"class Three<T> {}\n" +
+			"class Four<U, V> {}\n" +
+			"@interface Marker {}";
+	String expectedUnitToString = 
+			"class X {\n" + 
+			"  X() {\n" + 
+			"    super();\n" + 
+			"  }\n" + 
+			"  public void main(Four<@Marker ? super String, @Marker ? extends Object> param) {\n" + 
+			"    One<@Marker ? extends Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;\n" + 
+			"    Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String, @Marker ? extends Object>>> two = null;\n" + 
+			"    Three<@Marker ? extends Four<@Marker ? super String, @Marker ? extends Object>> three = null;\n" + 
+			"    Four<@Marker ? super String, @Marker ? extends Object> four = param;\n" + 
+			"  }\n" + 
+			"}\n" + 
+			"class One<R> {\n" + 
+			"  One() {\n" + 
+			"    super();\n" + 
+			"  }\n" + 
+			"}\n" + 
+			"class Two<S> {\n" + 
+			"  Two() {\n" + 
+			"    super();\n" + 
+			"  }\n" + 
+			"}\n" + 
+			"class Three<T> {\n" + 
+			"  Three() {\n" + 
+			"    super();\n" + 
+			"  }\n" + 
+			"}\n" + 
+			"class Four<U, V> {\n" + 
+			"  Four() {\n" + 
+			"    super();\n" + 
+			"  }\n" + 
+			"}\n" + 
+			"@interface Marker {\n" + 
+			"}\n";
+	checkParse(CHECK_PARSER, source.toCharArray(), null, "test0137", expectedUnitToString);
+}
 }
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
index fbc6f69..4d8dbb0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
@@ -4,6 +4,10 @@
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
@@ -9876,7 +9880,7 @@
 }
 // Bug 366003 - CCE in ASTNode.resolveAnnotations(ASTNode.java:639) 
 // many syntax errors fixed, does not trigger CCE 
-public void _testBug366003() {
+public void testBug366003() {
 	runNegativeTest(
 		new String[] {
 			"snippet/Bug366003.java",
@@ -9928,18 +9932,18 @@
 		"----------\n" + 
 		"7. ERROR in snippet\\Bug366003.java (at line 13)\n" + 
 		"	org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" + 
-		"	^^^^^^^^^^^^^^^^\n" + 
-		"Syntax error on tokens, delete these tokens\n" + 
+		"	            ^^^^\n" + 
+		"Syntax error, insert \"Identifier (\" to complete MethodHeaderName\n" + 
 		"----------\n" + 
 		"8. ERROR in snippet\\Bug366003.java (at line 13)\n" + 
 		"	org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" + 
 		"	            ^^^^\n" + 
-		"Syntax error, insert \"enum Identifier\" to complete EnumHeaderName\n" + 
+		"Syntax error, insert \")\" to complete MethodDeclaration\n" + 
 		"----------\n" + 
 		"9. ERROR in snippet\\Bug366003.java (at line 13)\n" + 
 		"	org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" + 
 		"	            ^^^^\n" + 
-		"Syntax error, insert \"EnumBody\" to complete EnumDeclaration\n" + 
+		"Syntax error, insert \";\" to complete MethodDeclaration\n" + 
 		"----------\n" + 
 		"10. ERROR in snippet\\Bug366003.java (at line 13)\n" + 
 		"	org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" + 
@@ -9969,7 +9973,7 @@
 }
 // Bug 366003 - CCE in ASTNode.resolveAnnotations(ASTNode.java:639) 
 // code is garbage, triggers CCE 
-public void _testBug366003b() {
+public void testBug366003b() {
 	runNegativeTest(
 		new String[] {
 			"snippet/Bug366003.java",
@@ -10014,18 +10018,18 @@
 		"----------\n" + 
 		"6. ERROR in snippet\\Bug366003.java (at line 11)\n" + 
 		"	org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" + 
-		"	^^^^^^^^^^^^^^^^\n" + 
-		"Syntax error on tokens, delete these tokens\n" + 
+		"	            ^^^^\n" + 
+		"Syntax error, insert \"Identifier (\" to complete MethodHeaderName\n" + 
 		"----------\n" + 
 		"7. ERROR in snippet\\Bug366003.java (at line 11)\n" + 
 		"	org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" + 
 		"	            ^^^^\n" + 
-		"Syntax error, insert \"enum Identifier\" to complete EnumHeaderName\n" + 
+		"Syntax error, insert \")\" to complete MethodDeclaration\n" + 
 		"----------\n" + 
 		"8. ERROR in snippet\\Bug366003.java (at line 11)\n" + 
 		"	org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" + 
 		"	            ^^^^\n" + 
-		"Syntax error, insert \"EnumBody\" to complete EnumDeclaration\n" + 
+		"Syntax error, insert \";\" to complete MethodDeclaration\n" + 
 		"----------\n" + 
 		"9. ERROR in snippet\\Bug366003.java (at line 11)\n" + 
 		"	org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" + 
@@ -10055,7 +10059,7 @@
 }
 // Bug 366003 - CCE in ASTNode.resolveAnnotations(ASTNode.java:639) 
 // minimal syntax error to trigger CCE 
-public void _testBug366003c() {
+public void testBug366003c() {
 	runNegativeTest(
 		new String[] {
 			"snippet/Bug366003.java",
@@ -10069,17 +10073,17 @@
 		"1. ERROR in snippet\\Bug366003.java (at line 5)\n" + 
 		"	org.User(@Bla String a)\n" + 
 		"	^^^\n" + 
-		"Syntax error on token \"org\", delete this token\n" + 
+		"Syntax error, insert \"Identifier (\" to complete MethodHeaderName\n" + 
 		"----------\n" + 
 		"2. ERROR in snippet\\Bug366003.java (at line 5)\n" + 
 		"	org.User(@Bla String a)\n" + 
 		"	^^^\n" + 
-		"Syntax error, insert \"enum Identifier\" to complete EnumHeaderName\n" + 
+		"Syntax error, insert \")\" to complete MethodDeclaration\n" + 
 		"----------\n" + 
 		"3. ERROR in snippet\\Bug366003.java (at line 5)\n" + 
 		"	org.User(@Bla String a)\n" + 
 		"	^^^\n" + 
-		"Syntax error, insert \"EnumBody\" to complete EnumDeclaration\n" + 
+		"Syntax error, insert \";\" to complete MethodDeclaration\n" + 
 		"----------\n" + 
 		"4. ERROR in snippet\\Bug366003.java (at line 5)\n" + 
 		"	org.User(@Bla String a)\n" + 
@@ -10103,7 +10107,7 @@
 		"----------\n");
 }
 // unfinished attempt to trigger the same CCE via catch formal parameters
-public void _testBug366003d() {
+public void testBug366003d() {
 	runNegativeTest(
 		new String[] {
 			"snippet/Bug366003.java",
@@ -10118,26 +10122,26 @@
 			"	}\n" +
 			"}\n"
 		},
-		"----------\n" +
-		"1. ERROR in snippet\\Bug366003.java (at line 7)\n" +
-		"	e } catch (@Blah Exception eSecond) {\n" +
-		"	^\n" +
-		"Syntax error, insert \"AssignmentOperator Expression\" to complete Assignment\n" +
-		"----------\n" +
-		"2. ERROR in snippet\\Bug366003.java (at line 7)\n" +
-		"	e } catch (@Blah Exception eSecond) {\n" +
-		"	^\n" +
-		"Syntax error, insert \";\" to complete BlockStatements\n" +
-		"----------\n" +
-		"3. ERROR in snippet\\Bug366003.java (at line 8)\n" +
-		"	e }\n" +
-		"	^\n" +
-		"Syntax error, insert \"AssignmentOperator Expression\" to complete Expression\n" +
-		"----------\n" +
-		"4. ERROR in snippet\\Bug366003.java (at line 8)\n" +
-		"	e }\n" +
-		"	^\n" +
-		"Syntax error, insert \";\" to complete BlockStatements\n" +
+		"----------\n" + 
+		"1. ERROR in snippet\\Bug366003.java (at line 7)\n" + 
+		"	e } catch (@Blah Exception eSecond) {\n" + 
+		"	^\n" + 
+		"Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\n" + 
+		"----------\n" + 
+		"2. ERROR in snippet\\Bug366003.java (at line 7)\n" + 
+		"	e } catch (@Blah Exception eSecond) {\n" + 
+		"	^\n" + 
+		"Syntax error, insert \";\" to complete BlockStatements\n" + 
+		"----------\n" + 
+		"3. ERROR in snippet\\Bug366003.java (at line 8)\n" + 
+		"	e }\n" + 
+		"	^\n" + 
+		"Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\n" + 
+		"----------\n" + 
+		"4. ERROR in snippet\\Bug366003.java (at line 8)\n" + 
+		"	e }\n" + 
+		"	^\n" + 
+		"Syntax error, insert \";\" to complete BlockStatements\n" + 
 		"----------\n");
 }
 public void testBug366003e() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
index 7652a87..3aca887 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
@@ -539,6 +539,7 @@
 		expectedProblemAttributes.put("IllegalReturnNullityRedefinition", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
 		expectedProblemAttributes.put("IllegalRedefinitionToNonNullParameter", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
 		expectedProblemAttributes.put("IllegalStaticModifierForMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+		expectedProblemAttributes.put("IllegalTypeAnnotationsInStaticMemberAccess", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
 		expectedProblemAttributes.put("IllegalTypeForExplicitThis", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
 		expectedProblemAttributes.put("IllegalTypeVariableSuperReference", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
 		expectedProblemAttributes.put("IllegalUnderscorePosition", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
@@ -1344,6 +1345,7 @@
 		expectedProblemAttributes.put("IllegalRedefinitionToNonNullParameter", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
 		expectedProblemAttributes.put("IllegalReturnNullityRedefinition", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
 		expectedProblemAttributes.put("IllegalStaticModifierForMemberType", SKIP);
+		expectedProblemAttributes.put("IllegalTypeAnnotationsInStaticMemberAccess", SKIP);
 		expectedProblemAttributes.put("IllegalTypeForExplicitThis", SKIP);
 		expectedProblemAttributes.put("IllegalTypeVariableSuperReference", SKIP);
 		expectedProblemAttributes.put("IllegalUnderscorePosition", SKIP);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultMethodsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultMethodsTest.java
index 50733d1..bf2b913 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultMethodsTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultMethodsTest.java
@@ -420,4 +420,157 @@
 			"Name clash: The method foo(List<String>) of type I3 has the same erasure as foo(List) of type I2 but does not override it\n" + 
 			"----------\n");
 	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=390761
+	public void testDefaultNonclash() {
+		runNegativeTest(
+			new String[] {
+				"X.java",
+				"public interface X extends Map<String, Object> {\n" +
+				"   Zork z;\n" +
+				"}\n" +
+				"\n" +
+				"interface Map<K,V> extends MapStream<K, V>  {\n" +
+				"   @Override\n" +
+				"	Iterable<BiValue<K, V>> asIterable() default {\n" +
+				"		return null;\n" +
+				"	}\n" +
+				"}\n" +
+				"interface MapStream<K, V> {\n" +
+				"	Iterable<BiValue<K, V>> asIterable();\n" +
+				"}\n" +
+				"\n" +
+				"interface BiValue<T, U> {\n" +
+				"    T getKey();\n" +
+				"    U getValue();\n" +
+				"}\n",
+			},
+			"----------\n" + 
+			"1. ERROR in X.java (at line 2)\n" + 
+			"	Zork z;\n" + 
+			"	^^^^\n" + 
+			"Zork cannot be resolved to a type\n" + 
+			"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=390761
+	public void testDefaultNonclash2() {
+		runNegativeTest(
+			new String[] {
+				"X.java",
+				"public interface X extends Map<String, Object> {\n" +
+				"   Zork z;\n" +
+				"}\n" +
+				"\n" +
+				"interface Map<K,V> extends MapStream<K, V>  {\n" +
+				"   @Override\n" +
+				"	Iterable<BiValue<K, V>> asIterable();\n" +
+				"}\n" +
+				"interface MapStream<K, V> {\n" +
+				"	Iterable<BiValue<K, V>> asIterable() default {\n" +
+				"       return null;\n" +
+				"   }\n" +
+				"}\n" +
+				"\n" +
+				"interface BiValue<T, U> {\n" +
+				"    T getKey();\n" +
+				"    U getValue();\n" +
+				"}\n",
+			},
+			"----------\n" + 
+			"1. ERROR in X.java (at line 2)\n" + 
+			"	Zork z;\n" + 
+			"	^^^^\n" + 
+			"Zork cannot be resolved to a type\n" + 
+			"----------\n");
+	}
+	
+	public void _testDefaultNonclash3() {
+		runNegativeTest(
+			new String[] {
+				"X.java",
+				"public interface X extends Map<String, Object> {\n" +
+				"   Zork z;\n" +
+				"}\n" +
+				"\n" +
+				"interface Map<K,V> extends MapStream<K, V>  {\n" +
+				"   @Override\n" +
+				"	Iterable<BiValue<K, V>> asIterable() default {\n" +
+				"       return null;\n" +
+				"   }\n" +
+				"}\n" +
+				"interface MapStream<K, V> {\n" +
+				"	Iterable<BiValue<K, V>> asIterable() default {\n" +
+				"       return null;\n" +
+				"   }\n" +
+				"}\n" +
+				"\n" +
+				"interface BiValue<T, U> {\n" +
+				"    T getKey();\n" +
+				"    U getValue();\n" +
+				"}\n",
+			},
+			"----------\n" + 
+			"1. ERROR in X.java (at line 2)\n" + 
+			"	Zork z;\n" + 
+			"	^^^^\n" + 
+			"Zork cannot be resolved to a type\n" + 
+			"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=390761
+	public void testDefaultNonclash4() {
+		runNegativeTest(
+			new String[] {
+				"X.java",
+				"public interface X extends Map<String, Object> {\n" +
+				"   Zork z;\n" +
+				"}\n" +
+				"\n" +
+				"interface Map<K,V> extends MapStream<K, V>  {\n" +
+				"   @Override\n" +
+				"	Iterable<BiValue<K, V>> asIterable();\n" +
+				"}\n" +
+				"interface MapStream<K, V> {\n" +
+				"	Iterable<BiValue<K, V>> asIterable();\n" +
+				"}\n" +
+				"\n" +
+				"interface BiValue<T, U> {\n" +
+				"    T getKey();\n" +
+				"    U getValue();\n" +
+				"}\n",
+			},
+			"----------\n" + 
+			"1. ERROR in X.java (at line 2)\n" + 
+			"	Zork z;\n" + 
+			"	^^^^\n" + 
+			"Zork cannot be resolved to a type\n" + 
+			"----------\n");
+	}
+
+	// JLS 9.4.1
+	// Bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
+	// Don't report conflict between the same method inherited on two paths.
+	public void testInheritedDefaultOverrides05() {
+		runConformTest(
+			new String[] {
+				"StringList.java",
+				"import java.util.Collection;\n" +
+				"public abstract class StringList implements Collection<String> {\n" +
+				"}\n"
+			},
+			"");
+	}
+
+	// JLS 9.4.1
+	// Bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
+	// extract from SuperTypeTest.test013():
+	public void testInheritedDefaultOverrides06() {
+		runConformTest(
+			new String[] {
+				"IterableList.java",
+				"import java.util.*;\n" +
+				"public interface IterableList<E> extends Iterable<E>, List<E> {}\n" +
+				"interface ListIterable<E> extends Iterable<E>, List<E> {}\n" +
+				"\n"
+			},
+			"");
+	}
 }
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 45a1a80..85c4d49 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
@@ -1628,42 +1628,41 @@
 					"}\n"
 			},
 			"----------\n" +
-				"1. ERROR in test\\X.java (at line 7)\n" +
-				"	X<int, short, long, float, double, boolean, char> x;\n" +
-				"	  ^^^\n" +
-				"Syntax error on token \"int\", Dimensions expected after this token\n" +
-				"----------\n" +
-				"2. ERROR in test\\X.java (at line 7)\n" +
-				"	X<int, short, long, float, double, boolean, char> x;\n" +
-				"	       ^^^^^\n" +
-				"Syntax error on token \"short\", Dimensions expected after this token\n" +
-				"----------\n" +
-				"3. ERROR in test\\X.java (at line 7)\n" +
-				"	X<int, short, long, float, double, boolean, char> x;\n" +
-				"	              ^^^^\n" +
-				"Syntax error on token \"long\", Dimensions expected after this token\n" +
-				"----------\n" +
-				"4. ERROR in test\\X.java (at line 7)\n" +
-				"	X<int, short, long, float, double, boolean, char> x;\n" +
-				"	                    ^^^^^\n" +
-				"Syntax error on token \"float\", Dimensions expected after this token\n" +
-				"----------\n" +
-				"5. ERROR in test\\X.java (at line 7)\n" +
-				"	X<int, short, long, float, double, boolean, char> x;\n" +
-				"	                           ^^^^^^\n" +
-				"Syntax error on token \"double\", Dimensions expected after this token\n" +
-				"----------\n" +
-				"6. ERROR in test\\X.java (at line 7)\n" +
-				"	X<int, short, long, float, double, boolean, char> x;\n" +
-				"	                                   ^^^^^^^\n" +
-				"Syntax error on token \"boolean\", Dimensions expected after this token\n" +
-				"----------\n" +
-				"7. ERROR in test\\X.java (at line 7)\n" +
-				"	X<int, short, long, float, double, boolean, char> x;\n" +
-				"	                                            ^^^^\n" +
-				"Syntax error on token \"char\", Dimensions expected after this token\n" +
-				"----------\n"
-		);
+			"1. ERROR in test\\X.java (at line 7)\n" +
+			"	X<int, short, long, float, double, boolean, char> x;\n" +
+			"	  ^^^\n" +
+			"Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+			"----------\n" +
+			"2. ERROR in test\\X.java (at line 7)\n" +
+			"	X<int, short, long, float, double, boolean, char> x;\n" +
+			"	       ^^^^^\n" +
+			"Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+			"----------\n" +
+			"3. ERROR in test\\X.java (at line 7)\n" +
+			"	X<int, short, long, float, double, boolean, char> x;\n" +
+			"	              ^^^^\n" +
+			"Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+			"----------\n" +
+			"4. ERROR in test\\X.java (at line 7)\n" +
+			"	X<int, short, long, float, double, boolean, char> x;\n" +
+			"	                    ^^^^^\n" +
+			"Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+			"----------\n" +
+			"5. ERROR in test\\X.java (at line 7)\n" +
+			"	X<int, short, long, float, double, boolean, char> x;\n" +
+			"	                           ^^^^^^\n" +
+			"Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+			"----------\n" +
+			"6. ERROR in test\\X.java (at line 7)\n" +
+			"	X<int, short, long, float, double, boolean, char> x;\n" +
+			"	                                   ^^^^^^^\n" +
+			"Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+			"----------\n" +
+			"7. ERROR in test\\X.java (at line 7)\n" +
+			"	X<int, short, long, float, double, boolean, char> x;\n" +
+			"	                                            ^^^^\n" +
+			"Syntax error, insert \"Dimensions\" to complete ReferenceType\n" +
+			"----------\n");
 	}
 	// JSR14-v10[2.1,2.2]: Valid multiple parameter types: primitive type arrays
 	public void test0062() {
@@ -2955,12 +2954,13 @@
 				"class AX<P> {\n" +
 				"}\n",
 			},
-		"----------\n" +
-		"1. ERROR in X.java (at line 1)\n" +
-		"	public class X  <T extends AX<? super int>> {\n" +
-		"	                                      ^^^\n" +
-		"Syntax error on token \"int\", Dimensions expected after this token\n" +
-		"----------\n");
+			"----------\n" +
+			"1. ERROR in X.java (at line 1)\n" +
+			"	public class X  <T extends AX<? super int>> {\n" +
+			"	                                      ^^^\n" +
+			"Syntax error, insert \"Dimensions\" to complete ArrayType\n" +
+			"----------\n"
+);
 	}
 
 	// type parameterized with wildcard cannot appear in allocation
@@ -48357,7 +48357,7 @@
 		"----------\n");
 }
 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=252120 - variation
-public void _test1403()  throws Exception {
+public void test1403()  throws Exception {
 	this.runNegativeTest(
 		new String[] {
 			"A.java",
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java
index 13375e6..a815e76 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java
@@ -4,6 +4,10 @@
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
@@ -1022,17 +1026,29 @@
 						"	int i = 0;\n" +
 						"}\n",
 						},
-						"----------\n" + 
-						"1. WARNING in X.java (at line 2)\n"+
-						"	import java.util.Map.Entry;\n"+
-						"	       ^^^^^^^^^^^^^^^^^^^\n"+
-						"The import java.util.Map.Entry is never used\n"+
-						"----------\n"+
-						"2. ERROR in X.java (at line 6)\n" + 
-						"	* <li> {@link Entry} </li>\n" + 
-						"	              ^^^^^\n" + 
-						"Javadoc: Invalid member type qualification\n" + 
-						"----------\n");
+						IS_JRE_8 ? 		
+								"----------\n" + 
+								"1. ERROR in X.java (at line 6)\n" + 
+								"	* <li> {@link Entry} </li>\n" + 
+								"	              ^^^^^\n" + 
+								"Javadoc: Invalid member type qualification\n" + 
+								"----------\n" + 
+								"2. ERROR in X.java (at line 9)\n" + 
+								"	public interface X extends Map {\n" + 
+								"	                 ^\n" + 
+								"The return types are incompatible for the inherited methods MapStream.values(), Map.values()\n" + 
+								"----------\n" : 
+									"----------\n" + 
+									"1. WARNING in X.java (at line 2)\n"+
+									"	import java.util.Map.Entry;\n"+
+									"	       ^^^^^^^^^^^^^^^^^^^\n"+
+									"The import java.util.Map.Entry is never used\n"+
+									"----------\n"+
+									"2. ERROR in X.java (at line 6)\n" + 
+									"	* <li> {@link Entry} </li>\n" + 
+									"	              ^^^^^\n" + 
+									"Javadoc: Invalid member type qualification\n" + 
+									"----------\n");
 			return;
 		}
 		runNegativeTest(
@@ -1073,12 +1089,24 @@
 				"	Entry e = null;\n" + 
 				"}\n",
 				},
-				"----------\n" + 
-				"1. ERROR in X.java (at line 5)\n" + 
-				"	* <li> {@link Entry} </li>\n" + 
-				"	              ^^^^^\n" + 
-				"Javadoc: Invalid member type qualification\n" + 
-				"----------\n");
+				!IS_JRE_8 || (IS_JRE_8 && this.complianceLevel >= ClassFileConstants.JDK1_5) ? 
+						"----------\n" + 
+						"1. ERROR in X.java (at line 5)\n" + 
+						"	* <li> {@link Entry} </li>\n" + 
+						"	              ^^^^^\n" + 
+						"Javadoc: Invalid member type qualification\n" + 
+						"----------\n":
+							"----------\n" + 
+							"1. ERROR in X.java (at line 5)\n" + 
+							"	* <li> {@link Entry} </li>\n" + 
+							"	              ^^^^^\n" + 
+							"Javadoc: Invalid member type qualification\n" + 
+							"----------\n" + 
+							"2. ERROR in X.java (at line 8)\n" + 
+							"	public interface X extends Map {\n" + 
+							"	                 ^\n" + 
+							"The return types are incompatible for the inherited methods MapStream.values(), Map.values()\n" + 
+							"----------\n");
 	}	
 
 	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=253750
@@ -1099,17 +1127,29 @@
 						"	Entry e = null;\n" + 
 						"}\n",
 						},
-						"----------\n" + 
-						"1. WARNING in X.java (at line 2)\n"+
-						"	import java.util.Map.Entry;\n"+
-						"	       ^^^^^^^^^^^^^^^^^^^\n"+
-						"The import java.util.Map.Entry is never used\n"+
-						"----------\n"+
-						"2. ERROR in X.java (at line 6)\n" + 
-						"	* <li> {@link Entry} </li>\n" + 
-						"	              ^^^^^\n" + 
-						"Javadoc: Invalid member type qualification\n" + 
-						"----------\n");
+						IS_JRE_8 ? 
+								"----------\n" + 
+								"1. ERROR in X.java (at line 6)\n" + 
+								"	* <li> {@link Entry} </li>\n" + 
+								"	              ^^^^^\n" + 
+								"Javadoc: Invalid member type qualification\n" + 
+								"----------\n" + 
+								"2. ERROR in X.java (at line 9)\n" + 
+								"	public interface X extends Map {\n" + 
+								"	                 ^\n" + 
+								"The return types are incompatible for the inherited methods MapStream.values(), Map.values()\n" + 
+								"----------\n" : 
+									"----------\n" + 
+									"1. WARNING in X.java (at line 2)\n"+
+									"	import java.util.Map.Entry;\n"+
+									"	       ^^^^^^^^^^^^^^^^^^^\n"+
+									"The import java.util.Map.Entry is never used\n"+
+									"----------\n"+
+									"2. ERROR in X.java (at line 6)\n" + 
+									"	* <li> {@link Entry} </li>\n" + 
+									"	              ^^^^^\n" + 
+									"Javadoc: Invalid member type qualification\n" + 
+									"----------\n");
 			return;
 		}
 		runNegativeTest(
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java
index 67b866e..5ca0df1 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java
@@ -5,6 +5,10 @@
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ * 
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java
index d90340b..76cdcf2 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java
@@ -654,14 +654,22 @@
 					"@interface Marker {}",
 					"X.java",
 					"public class X<@Marker T> {}",
+
+					"java/lang/annotation/ElementType.java",
+					"package java.lang.annotation;\n" +
+					"public enum ElementType {\n" +
+					"    TYPE,\n" +
+					"    FIELD,\n" +
+					"    METHOD,\n" +
+					"    PARAMETER,\n" +
+					"    CONSTRUCTOR,\n" +
+					"    LOCAL_VARIABLE,\n" +
+					"    ANNOTATION_TYPE,\n" +
+					"    PACKAGE,\n" +
+					"    TYPE_PARAMETER,\n" +
+					"    TYPE_USE\n" +
+					"}\n"
 				},
-				/* TODO(Srikanth/Jay) when JSR308 enabled runtime becomes available for testing, the first error message should be deleted. */
-				"----------\n" + 
-				"1. ERROR in Marker.java (at line 3)\n" + 
-				"	@Target(TYPE_USE)\n" + 
-				"	        ^^^^^^^^\n" + 
-				"TYPE_USE cannot be resolved to a variable\n" + 
-				"----------\n" + 
 				"----------\n" + 
 				"1. ERROR in X.java (at line 1)\n" + 
 				"	public class X<@Marker T> {}\n" + 
@@ -845,68 +853,28 @@
 		"----------\n" + 
 		"2. ERROR in X.java (at line 3)\n" + 
 		"	System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
-		"	                       ^^^^^^^^^\n" + 
-		"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
-		"----------\n" + 
-		"3. ERROR in X.java (at line 3)\n" + 
-		"	System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
 		"	                                       ^^^^^^^^^^^^^^^^\n" + 
 		"Syntax error, type annotations are illegal here\n" + 
 		"----------\n" + 
-		"4. ERROR in X.java (at line 3)\n" + 
-		"	System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
-		"	                                       ^^^^^^^^^\n" + 
-		"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
-		"----------\n" + 
-		"5. ERROR in X.java (at line 3)\n" + 
-		"	System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
-		"	                                                 ^^^^^^\n" + 
-		"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
-		"----------\n" + 
-		"6. ERROR in X.java (at line 3)\n" + 
+		"3. ERROR in X.java (at line 3)\n" + 
 		"	System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
 		"	                                                              ^^^^^^^^^\n" + 
 		"Syntax error, type annotations are illegal here\n" + 
 		"----------\n" + 
-		"7. ERROR in X.java (at line 3)\n" + 
-		"	System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
-		"	                                                              ^^^^^^^^^\n" + 
-		"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
-		"----------\n" + 
-		"8. ERROR in X.java (at line 4)\n" + 
+		"4. ERROR in X.java (at line 4)\n" + 
 		"	System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
 		"	                     ^^^^^^^^^\n" + 
 		"Syntax error, type annotations are illegal here\n" + 
 		"----------\n" + 
-		"9. ERROR in X.java (at line 4)\n" + 
-		"	System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
-		"	                     ^^^^^^^^^\n" + 
-		"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
-		"----------\n" + 
-		"10. ERROR in X.java (at line 4)\n" + 
+		"5. ERROR in X.java (at line 4)\n" + 
 		"	System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
 		"	                                     ^^^^^^^^^^^^^^^^\n" + 
 		"Syntax error, type annotations are illegal here\n" + 
 		"----------\n" + 
-		"11. ERROR in X.java (at line 4)\n" + 
-		"	System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
-		"	                                     ^^^^^^^^^\n" + 
-		"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
-		"----------\n" + 
-		"12. ERROR in X.java (at line 4)\n" + 
-		"	System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
-		"	                                               ^^^^^^\n" + 
-		"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
-		"----------\n" + 
-		"13. ERROR in X.java (at line 4)\n" + 
+		"6. ERROR in X.java (at line 4)\n" + 
 		"	System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
 		"	                                                            ^^^^^^^^^\n" + 
 		"Syntax error, type annotations are illegal here\n" + 
-		"----------\n" + 
-		"14. ERROR in X.java (at line 4)\n" + 
-		"	System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" + 
-		"	                                                            ^^^^^^^^^\n" + 
-		"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
 		"----------\n");
 	}
 	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383950
@@ -973,13 +941,8 @@
 					"----------\n" + 
 					"1. ERROR in X.java (at line 1)\n" + 
 					"	import @Marker java.lang.String; // Compilation error \n" + 
-					"	^^^^^^\n" + 
-					"Syntax error on token(s), misplaced construct(s)\n" + 
-					"----------\n" + 
-					"2. ERROR in X.java (at line 1)\n" + 
-					"	import @Marker java.lang.String; // Compilation error \n" + 
-					"	        ^^^^^^\n" + 
-					"Syntax error on token \"Marker\", package expected after this token\n" + 
+					"	       ^^^^^^^\n" + 
+					"Syntax error, type annotations are illegal here\n" + 
 					"----------\n");
 	}
 	// Test that type name can't be left out in a cast expression with an annotations 
@@ -997,8 +960,8 @@
 					"----------\n" + 
 					"1. ERROR in X.java (at line 3)\n" + 
 					"	String myString = (@NonNull) myObject;	}\n" + 
-					"	                    ^^^^^^^\n" + 
-					"Syntax error on token \"NonNull\", void expected after this token\n" + 
+					"	                   ^\n" + 
+					"Syntax error on token \"@\", delete this token\n" + 
 					"----------\n");
 	}
 	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=385111
@@ -1292,7 +1255,23 @@
 						"    public void foobar(AnonymousInner this);\n" +
 						"}\n" +
 						"@Target(TYPE_USE)\n" + 
-						"@interface Marker {}"},
+						"@interface Marker {}",
+
+						"java/lang/annotation/ElementType.java",
+						"package java.lang.annotation;\n" +
+						"public enum ElementType {\n" +
+						"    TYPE,\n" +
+						"    FIELD,\n" +
+						"    METHOD,\n" +
+						"    PARAMETER,\n" +
+						"    CONSTRUCTOR,\n" +
+						"    LOCAL_VARIABLE,\n" +
+						"    ANNOTATION_TYPE,\n" +
+						"    PACKAGE,\n" +
+						"    TYPE_PARAMETER,\n" +
+						"    TYPE_USE\n" +
+						"}\n"
+					},
 							"----------\n" + 
 							"1. ERROR in Outer.java (at line 5)\n" + 
 							"	public Inner(@Missing Outer Outer.this) {}\n" + 
@@ -1311,33 +1290,18 @@
 							"----------\n" + 
 							"4. ERROR in Outer.java (at line 21)\n" + 
 							"	public StaticNested(@Marker Outer.StaticNested Outer.StaticNested.this) {}\n" + 
-							"	                    ^^^^^^^\n" + 
-							"The annotation @Marker is disallowed for this location\n" + 
-							"----------\n" + 
-							"5. ERROR in Outer.java (at line 21)\n" + 
-							"	public StaticNested(@Marker Outer.StaticNested Outer.StaticNested.this) {}\n" + 
 							"	                                                                  ^^^^\n" + 
 							"Explicit \'this\' parameter is allowed only in instance methods of non-anonymous classes and inner class constructors\n" + 
 							"----------\n" + 
-							"6. ERROR in Outer.java (at line 23)\n" + 
-							"	public static void foo(@Marker Outer this) {}\n" + 
-							"	                       ^^^^^^^\n" + 
-							"The annotation @Marker is disallowed for this location\n" + 
-							"----------\n" + 
-							"7. ERROR in Outer.java (at line 23)\n" + 
+							"5. ERROR in Outer.java (at line 23)\n" + 
 							"	public static void foo(@Marker Outer this) {}\n" + 
 							"	                                     ^^^^\n" + 
 							"Explicit \'this\' parameter is allowed only in instance methods of non-anonymous classes and inner class constructors\n" + 
 							"----------\n" + 
-							"8. ERROR in Outer.java (at line 24)\n" + 
+							"6. ERROR in Outer.java (at line 24)\n" + 
 							"	public void foo(@Missing Outer this, int i) {}\n" + 
 							"	                 ^^^^^^^\n" + 
 							"Missing cannot be resolved to a type\n" + 
-							"----------\n" + 
-							"9. ERROR in Outer.java (at line 29)\n" + 
-							"	@Target(TYPE_USE)\n" + 
-							"	        ^^^^^^^^\n" + 
-							"TYPE_USE cannot be resolved to a variable\n" + 
 							"----------\n");
 	}
 	public void test0383908() {
@@ -1365,4 +1329,1306 @@
 				"Duplicate method foo() in type X\n" + 
 				"----------\n");
 	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on nested package names.
+	public void test383596() throws Exception {
+		this.runNegativeTest(
+			new String[] {
+				"X.java",
+				"package p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" +
+				"public class X {\n" +
+				"}"
+			}, 
+			"----------\n" + 
+			"1. ERROR in X.java (at line 1)\n" + 
+			"	package p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	           ^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n" + 
+			"2. ERROR in X.java (at line 1)\n" + 
+			"	package p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	                        ^^^^^^^^^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n" + 
+			"3. ERROR in X.java (at line 1)\n" + 
+			"	package p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	                                           ^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on nested package names.
+	public void test383596a() throws Exception {
+		this.runNegativeTest(
+			new String[] {
+				"X.java",
+				"@Marker package p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" +
+				"public class X {\n" +
+				"}"
+			}, 
+			"----------\n" + 
+			"1. ERROR in X.java (at line 1)\n" + 
+			"	@Marker package p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	^^^^^^^\n" + 
+			"Package annotations must be in file package-info.java\n" + 
+			"----------\n" + 
+			"2. ERROR in X.java (at line 1)\n" + 
+			"	@Marker package p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	                   ^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n" + 
+			"3. ERROR in X.java (at line 1)\n" + 
+			"	@Marker package p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	                                ^^^^^^^^^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n" + 
+			"4. ERROR in X.java (at line 1)\n" + 
+			"	@Marker package p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	                                                   ^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on nested import names.
+	public void test039b() throws Exception {
+		this.runNegativeTest(
+			new String[] {
+				"X.java",
+				"import p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" +
+				"public class X {\n" +
+				"}"
+			}, 
+			"----------\n" + 
+			"1. ERROR in X.java (at line 1)\n" + 
+			"	import p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	       ^\n" + 
+			"The import p cannot be resolved\n" + 
+			"----------\n" + 
+			"2. ERROR in X.java (at line 1)\n" + 
+			"	import p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	          ^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n" + 
+			"3. ERROR in X.java (at line 1)\n" + 
+			"	import p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	                       ^^^^^^^^^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n" + 
+			"4. ERROR in X.java (at line 1)\n" + 
+			"	import p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z. z2;\n" + 
+			"	                                          ^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on nested import names.
+	public void test383596b() throws Exception {
+		this.runNegativeTest(
+			new String[] {
+				"X.java",
+				"import p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.*;\n" +
+				"public class X {\n" +
+				"}"
+			}, 
+			"----------\n" + 
+			"1. ERROR in X.java (at line 1)\n" + 
+			"	import p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.*;\n" + 
+			"	       ^\n" + 
+			"The import p cannot be resolved\n" + 
+			"----------\n" + 
+			"2. ERROR in X.java (at line 1)\n" + 
+			"	import p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.*;\n" + 
+			"	          ^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n" + 
+			"3. ERROR in X.java (at line 1)\n" + 
+			"	import p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.*;\n" + 
+			"	                       ^^^^^^^^^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n" + 
+			"4. ERROR in X.java (at line 1)\n" + 
+			"	import p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.*;\n" + 
+			"	                                          ^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+			"Syntax error, type annotations are illegal here\n" + 
+			"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on nested static import names.
+	public void test041() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"import static p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.z2;\n" +
+						"public class X {\n" +
+						"}"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 1)\n" + 
+				"	import static p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.z2;\n" + 
+				"	              ^\n" + 
+				"The import p cannot be resolved\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 1)\n" + 
+				"	import static p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.z2;\n" + 
+				"	                 ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"3. ERROR in X.java (at line 1)\n" + 
+				"	import static p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.z2;\n" + 
+				"	                              ^^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"4. ERROR in X.java (at line 1)\n" + 
+				"	import static p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.z2;\n" + 
+				"	                                                 ^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on nested static import names.
+	public void test042() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"import static p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.*;\n" +
+						"public class X {\n" +
+						"}"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 1)\n" + 
+				"	import static p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.*;\n" + 
+				"	              ^\n" + 
+				"The import p cannot be resolved\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 1)\n" + 
+				"	import static p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.*;\n" + 
+				"	                 ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"3. ERROR in X.java (at line 1)\n" + 
+				"	import static p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.*;\n" + 
+				"	                              ^^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"4. ERROR in X.java (at line 1)\n" + 
+				"	import static p. @Marker q.x. @Marker @Marker y. @Marker @Marker @Marker z.*;\n" + 
+				"	                                                 ^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on Qualified name in explicit this.
+	// Much water has flown under the bridge. The grammar itself does not allow annotations in qualified name in explicit this.
+	// We now use the production UnannotatableName instead of plain Name. 
+	public void test043() throws Exception {
+		this.runNegativeTest(
+			new String[] {
+				"X.java",
+				"public class X {\n" +
+				"   class Y {\n" +
+			    "       class Z {\n" +
+				"           Z(X. @Marker Y  X.Y.this) {\n" +
+				"           }\n" +
+				"       }\n" +
+				"    }\n" +
+				"}"
+			}, 
+			"----------\n" + 
+			"1. ERROR in X.java (at line 4)\n" + 
+			"	Z(X. @Marker Y  X.Y.this) {\n" + 
+			"	      ^^^^^^\n" + 
+			"Marker cannot be resolved to a type\n" + 
+			"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on Qualified name in explicit constructor call -- super form
+	public void test044() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"public class X {\n" +
+						"	static X x;\n" +
+						"	public class InnerBar {\n" +
+						"	}\n" +
+						"	public class SubInnerBar extends InnerBar {\n" +
+						"		SubInnerBar() {\n" +
+						"			X.@Marker x. @Marker @Marker @Marker x.super();\n" +
+						"		}\n" +
+						"	}\n" +
+						"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 7)\n" + 
+				"	X.@Marker x. @Marker @Marker @Marker x.super();\n" + 
+				"	  ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 7)\n" + 
+				"	X.@Marker x. @Marker @Marker @Marker x.super();\n" + 
+				"	             ^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"3. WARNING in X.java (at line 7)\n" + 
+				"	X.@Marker x. @Marker @Marker @Marker x.super();\n" + 
+				"	                                     ^\n" + 
+				"The static field X.x should be accessed in a static way\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on Qualified name in explicit constructor call, super form with explicit type arguments
+	public void test045() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"public class X {\n" +
+						"	static X x;\n" +
+						"	public class InnerBar {\n" +
+						"	}\n" +
+						"	public class SubInnerBar extends InnerBar {\n" +
+						"		SubInnerBar() {\n" +
+						"			X.@Marker x. @Marker @Marker @Marker x.<String>super();\n" +
+						"		}\n" +
+						"	}\n" +
+						"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 7)\n" + 
+				"	X.@Marker x. @Marker @Marker @Marker x.<String>super();\n" + 
+				"	  ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 7)\n" + 
+				"	X.@Marker x. @Marker @Marker @Marker x.<String>super();\n" + 
+				"	             ^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"3. WARNING in X.java (at line 7)\n" + 
+				"	X.@Marker x. @Marker @Marker @Marker x.<String>super();\n" + 
+				"	                                     ^\n" + 
+				"The static field X.x should be accessed in a static way\n" + 
+				"----------\n" + 
+				"4. WARNING in X.java (at line 7)\n" + 
+				"	X.@Marker x. @Marker @Marker @Marker x.<String>super();\n" + 
+				"	                                        ^^^^^^\n" + 
+				"Unused type arguments for the non generic constructor X.InnerBar() of type X.InnerBar; it should not be parameterized with arguments <String>\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on Qualified name in explicit constructor call - this form
+	public void test046() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"public class X {\n" +
+						"	Bar bar;\n" +
+						"	class Bar {\n" +
+						"		//static Bar x;\n" +
+						"		public class InnerBar {\n" +
+						"			InnerBar(Bar x) {\n" +
+						"			}\n" +
+						"		}\n" +
+						"		public class SubInnerBar extends InnerBar {\n" +
+						"			SubInnerBar() {\n" +
+						"				X. @Marker bar.this();\n" +
+						"			}\n" +
+						"		}\n" +
+						"	}\n" +
+						"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 11)\n" + 
+				"	X. @Marker bar.this();\n" + 
+				"	^^^^^^^^^^^^^^\n" + 
+				"Illegal enclosing instance specification for type X.Bar.SubInnerBar\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 11)\n" + 
+				"	X. @Marker bar.this();\n" + 
+				"	^^^^^^^^^^^^^^\n" + 
+				"Cannot make a static reference to the non-static field X.bar\n" + 
+				"----------\n" + 
+				"3. ERROR in X.java (at line 11)\n" + 
+				"	X. @Marker bar.this();\n" + 
+				"	   ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+					"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on Qualified name in explicit constructor call, this form with explicit type arguments
+	public void test047() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"public class X {\n" +
+						"	Bar bar;\n" +
+						"	class Bar {\n" +
+						"		//static Bar x;\n" +
+						"		public class InnerBar {\n" +
+						"			InnerBar(Bar x) {\n" +
+						"			}\n" +
+						"		}\n" +
+						"		public class SubInnerBar extends InnerBar {\n" +
+						"			SubInnerBar() {\n" +
+						"				X.@Marker bar.<String>this();\n" +
+						"			}\n" +
+						"		}\n" +
+						"	}\n" +
+						"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 11)\n" + 
+				"	X.@Marker bar.<String>this();\n" + 
+				"	^^^^^^^^^^^^^\n" + 
+				"Illegal enclosing instance specification for type X.Bar.SubInnerBar\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 11)\n" + 
+				"	X.@Marker bar.<String>this();\n" + 
+				"	^^^^^^^^^^^^^\n" + 
+				"Cannot make a static reference to the non-static field X.bar\n" + 
+				"----------\n" + 
+				"3. ERROR in X.java (at line 11)\n" + 
+				"	X.@Marker bar.<String>this();\n" + 
+				"	  ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"4. WARNING in X.java (at line 11)\n" + 
+				"	X.@Marker bar.<String>this();\n" + 
+				"	               ^^^^^^\n" + 
+				"Unused type arguments for the non generic constructor X.Bar.SubInnerBar() of type X.Bar.SubInnerBar; it should not be parameterized with arguments <String>\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations on Qualified name in PrimaryNoNewArray
+	public void test048() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"public class X {\n" +
+						"	X bar;\n" +
+						"	private void foo(X x) {\n" +
+						"		System.out.println((x. @Marker bar));\n" +
+						"	}\n" +
+						"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	System.out.println((x. @Marker bar));\n" + 
+				"	                       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in qualified this.
+	public void test049() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"public class X {\n" +
+						"	class Y {\n" +
+						"		class Z {\n" +
+						"			void foo() {\n" +
+						"				Object o = X.@Marker Y.this; \n" +
+						"			}\n" +
+						"		}\n" +
+						"	}\n" +
+						"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 5)\n" + 
+				"	Object o = X.@Marker Y.this; \n" + 
+				"	             ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" +
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in qualified super.
+	public void test050() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"public class X {\n" +
+						"	public class Y  {\n" +
+						"		public void foo() {\n" +
+						"			X. @Marker Y.super.hashCode();\n" +
+						"		}\n" +
+						"	}\n" +
+						"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	X. @Marker Y.super.hashCode();\n" + 
+				"	   ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in Name.class
+	public void test051() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"public class X {\n" +
+						"	public class Y  {\n" +
+						"		public void foo() {\n" +
+						"			Class<?> c = X. @Marker @Illegal Y.class;\n" +
+						"		}\n" +
+						"	}\n" +
+						"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	Class<?> c = X. @Marker @Illegal Y.class;\n" + 
+				"	                ^^^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in Name [].class.
+	public void test052() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"public class X {\n" +
+						"	public class Y  {\n" +
+						"		public void foo() {\n" +
+						"			Class<?> c = X. @Marker @Another Y @YetMore [].class;\n" +
+						"		}\n" +
+						"	}\n" +
+						"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	Class<?> c = X. @Marker @Another Y @YetMore [].class;\n" + 
+				"	                ^^^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 4)\n" + 
+				"	Class<?> c = X. @Marker @Another Y @YetMore [].class;\n" + 
+				"	                                   ^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in binary expressions with qualified names.
+	public void test053() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+						"X.java",
+						"public class X {\n" +
+						"    static int x;\n" +
+						"    static boolean fb;\n" +
+						"	 public void foo(boolean b) {\n" +
+						"		x = (X.@Marker x * 10);\n" +
+						"		x = (X.@Marker x / 10);\n" +
+						"		x = (X.@Marker x % 10);\n" +
+						"		x = (X.@Marker x + 10);\n" +
+						"		x = (X.@Marker x - 10);\n" +
+						"		x = (X.@Marker x << 10);\n" +
+						"		x = (X.@Marker x >> 10);\n" +
+						"		x = (X.@Marker x >>> 10);\n" +
+						"		b = (X.@Marker x < 10);\n" +
+						"		b = (X.@Marker x > 10);\n" +
+						"		b = (X.@Marker x <= 10);\n" +
+						"		b = (X.@Marker x >= 10);\n" +
+						"		b = (X.@Marker x instanceof Object);\n" +
+						"		b = (X.@Marker x == 10);\n" +
+						"		b = (X.@Marker x != 10);\n" +
+						"		x = (X.@Marker x & 10);\n" +
+						"		x = (X.@Marker x ^ 10);\n" +
+						"		x = (X.@Marker x | 10);\n" +
+						"		fb = (X.@Marker fb && true);\n" +
+						"		fb = (X.@Marker fb || true);\n" +
+						"		x = (X.@Marker fb ? 10 : 10);\n" +
+						"	 }\n" +
+						"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 5)\n" + 
+				"	x = (X.@Marker x * 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 6)\n" + 
+				"	x = (X.@Marker x / 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"3. ERROR in X.java (at line 7)\n" + 
+				"	x = (X.@Marker x % 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"4. ERROR in X.java (at line 8)\n" + 
+				"	x = (X.@Marker x + 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"5. ERROR in X.java (at line 9)\n" + 
+				"	x = (X.@Marker x - 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"6. ERROR in X.java (at line 10)\n" + 
+				"	x = (X.@Marker x << 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"7. ERROR in X.java (at line 11)\n" + 
+				"	x = (X.@Marker x >> 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"8. ERROR in X.java (at line 12)\n" + 
+				"	x = (X.@Marker x >>> 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"9. ERROR in X.java (at line 13)\n" + 
+				"	b = (X.@Marker x < 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"10. ERROR in X.java (at line 14)\n" + 
+				"	b = (X.@Marker x > 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"11. ERROR in X.java (at line 15)\n" + 
+				"	b = (X.@Marker x <= 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"12. ERROR in X.java (at line 16)\n" + 
+				"	b = (X.@Marker x >= 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"13. ERROR in X.java (at line 17)\n" + 
+				"	b = (X.@Marker x instanceof Object);\n" + 
+				"	    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+				"Incompatible conditional operand types int and Object\n" + 
+				"----------\n" + 
+				"14. ERROR in X.java (at line 17)\n" + 
+				"	b = (X.@Marker x instanceof Object);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"15. ERROR in X.java (at line 18)\n" + 
+				"	b = (X.@Marker x == 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"16. ERROR in X.java (at line 19)\n" + 
+				"	b = (X.@Marker x != 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"17. ERROR in X.java (at line 20)\n" + 
+				"	x = (X.@Marker x & 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"18. ERROR in X.java (at line 21)\n" + 
+				"	x = (X.@Marker x ^ 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"19. ERROR in X.java (at line 22)\n" + 
+				"	x = (X.@Marker x | 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"20. ERROR in X.java (at line 23)\n" + 
+				"	fb = (X.@Marker fb && true);\n" + 
+				"	        ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"21. ERROR in X.java (at line 24)\n" + 
+				"	fb = (X.@Marker fb || true);\n" + 
+				"	        ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"22. ERROR in X.java (at line 25)\n" + 
+				"	x = (X.@Marker fb ? 10 : 10);\n" + 
+				"	       ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	/* https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in annotations with qualified names.
+	   This test is disabled. Now the grammar itself forbids annotations in the said place by using the production
+	   AnnotationName ::= '@' UnannotatableName. We don't want to add tests that will be fragile and unstable due to 
+	   syntax. If a construct is provably not parsed at the grammar level, that ought to be good enough.
+	*/
+	public void test054() throws Exception {
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in qualified names used as annotation values.
+	public void test055() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"@interface Annot {\n" +
+					"	String bar();\n" +
+					"}\n" +
+					"@Annot(bar = X. @Marker s)\n" +
+					"public class X {\n" +
+					"	final static String s = \"\";\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	@Annot(bar = X. @Marker s)\n" + 
+				"	                ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in qualified names that are postfix expressions.
+	public void test056() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"    static int x;\n" +
+					"    int foo() {\n" +
+					"        return X.@Marker x;\n" +
+					"    }\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	return X.@Marker x;\n" + 
+				"	         ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in qualified names used in array access.
+	public void test057() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"    static int x[];\n" +
+					"    int foo() {\n" +
+					"        return X.@Marker x[0];\n" +
+					"    }\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	return X.@Marker x[0];\n" + 
+				"	         ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in qualified name with type arguments used in method invocation.
+	public void test058() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"    static X x;\n" +
+					"    int foo() {\n" +
+					"        return X.@Marker x.<String> foo();\n" +
+					"    }\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	return X.@Marker x.<String> foo();\n" + 
+				"	         ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. WARNING in X.java (at line 4)\n" + 
+				"	return X.@Marker x.<String> foo();\n" + 
+				"	                    ^^^^^^\n" + 
+				"Unused type arguments for the non generic method foo() of type X; it should not be parameterized with arguments <String>\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in qualified name used in method invocation.
+	public void test059() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"    static X x;\n" +
+					"    int foo() {\n" +
+					"        return X.@Marker x. @Blah foo();\n" +
+					"    }\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	return X.@Marker x. @Blah foo();\n" + 
+				"	         ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 4)\n" + 
+				"	return X.@Marker x. @Blah foo();\n" + 
+				"	                    ^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in qualified name used in class instance creation
+	public void test060() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"    static Y y;\n" +
+					"    class Y {\n" +
+					"        class Z {\n" +
+					"            void foo() {\n" +
+					"                Z z = X. @Marker y.new Z();\n" +
+					"            }\n" +
+					"        }\n" +
+					"    }\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 6)\n" + 
+				"	Z z = X. @Marker y.new Z();\n" + 
+				"	         ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596 -- reject annotations in qualified name used in class instance creation
+	public void test061() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"    static X x;\n" +
+					"    X getX() {\n" +
+					"        return (X.@Marker x);\n" +
+					"    }\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	return (X.@Marker x);\n" + 
+				"	          ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	public void test062() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"	public <T> @Marker Object foo() {\n" +
+					"	}\n" +
+					"}\n" +
+					"@interface Marker {\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 2)\n" + 
+				"	public <T> @Marker Object foo() {\n" + 
+				"	           ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	public void test063() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"	Object o = @Marker int.class;\n" +
+					"}\n" +
+					"@interface Marker {\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 2)\n" + 
+				"	Object o = @Marker int.class;\n" + 
+				"	           ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	public void test064() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"@interface X {\n" +
+					"	<T> @Marker String foo();\n" +
+					"}\n" +
+					"@interface Marker {\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 2)\n" + 
+				"	<T> @Marker String foo();\n" + 
+				"	    ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 2)\n" + 
+				"	<T> @Marker String foo();\n" + 
+				"	                   ^^^^^\n" + 
+				"Annotation attributes cannot be generic\n" + 
+				"----------\n");
+	}
+	public void test065() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"	Object o = new <String> @Marker X();\n" +
+					"}\n" +
+					"@interface Marker {\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. WARNING in X.java (at line 2)\n" + 
+				"	Object o = new <String> @Marker X();\n" + 
+				"	                ^^^^^^\n" + 
+				"Unused type arguments for the non generic constructor X() of type X; it should not be parameterized with arguments <String>\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 2)\n" + 
+				"	Object o = new <String> @Marker X();\n" + 
+				"	                        ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	public void test066() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"	Object o = new X().new <String> @Marker X();\n" +
+					"}\n" +
+					"@interface Marker {\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 2)\n" + 
+				"	Object o = new X().new <String> @Marker X();\n" + 
+				"	                                ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 2)\n" + 
+				"	Object o = new X().new <String> @Marker X();\n" + 
+				"	                                ^^^^^^^^^\n" + 
+				"X.X cannot be resolved to a type\n" + 
+				"----------\n");
+	}
+	public void test067() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"	Object o = x.new <String> @Marker X() {};\n" +
+					"}\n" +
+					"@interface Marker {\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 2)\n" + 
+				"	Object o = x.new <String> @Marker X() {};\n" + 
+				"	           ^\n" + 
+				"x cannot be resolved to a variable\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 2)\n" + 
+				"	Object o = x.new <String> @Marker X() {};\n" + 
+				"	                          ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	public void test068() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"public class X {\n" +
+					"	Object o = new <String> @Marker X() {};\n" +
+					"}\n" +
+					"@interface Marker {\n" +
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. WARNING in X.java (at line 2)\n" + 
+				"	Object o = new <String> @Marker X() {};\n" + 
+				"	                ^^^^^^\n" + 
+				"Unused type arguments for the non generic constructor X() of type X; it should not be parameterized with arguments <String>\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 2)\n" + 
+				"	Object o = new <String> @Marker X() {};\n" + 
+				"	                        ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=385293
+	public void test069() throws Exception {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"class X<final T> {\n" +
+					"	Object o = (Object) (public X<final String>) null;\n" + 
+					"}\n"
+				}, 
+				"----------\n" + 
+				"1. ERROR in X.java (at line 1)\n" + 
+				"	class X<final T> {\n" + 
+				"	        ^^^^^\n" + 
+				"Syntax error on token \"final\", delete this token\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 2)\n" + 
+				"	Object o = (Object) (public X<final String>) null;\n" + 
+				"	                     ^^^^^^\n" + 
+				"Syntax error on token \"public\", delete this token\n" + 
+				"----------\n" + 
+				"3. ERROR in X.java (at line 2)\n" + 
+				"	Object o = (Object) (public X<final String>) null;\n" + 
+				"	                              ^^^^^\n" + 
+				"Syntax error on token \"final\", delete this token\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=388085
+	public void test0388085() {
+		this.runNegativeTest(
+				new String[] {"X.java",
+						"class X {\n" +
+						"	public void main() {\n" +
+						"		final One<@Marker ? extends Two<@Marker ? super Three<? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;" +
+						"		one = null;\n" +
+						"	}\n" +
+						"}\n" +
+						"class One<R> {}\n" +
+						"class Two<S> {}\n" +
+						"class Three<T> {}\n" +
+						"class Four<U, V> {}\n"},
+							"----------\n" + 
+							"1. ERROR in X.java (at line 3)\n" + 
+							"	final One<@Marker ? extends Two<@Marker ? super Three<? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;		one = null;\n" + 
+							"	           ^^^^^^\n" + 
+							"Marker cannot be resolved to a type\n" + 
+							"----------\n" + 
+							"2. ERROR in X.java (at line 3)\n" + 
+							"	final One<@Marker ? extends Two<@Marker ? super Three<? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;		one = null;\n" + 
+							"	                                 ^^^^^^\n" + 
+							"Marker cannot be resolved to a type\n" + 
+							"----------\n" + 
+							"3. ERROR in X.java (at line 3)\n" + 
+							"	final One<@Marker ? extends Two<@Marker ? super Three<? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;		one = null;\n" + 
+							"	                                                                      ^^^^^^\n" + 
+							"Marker cannot be resolved to a type\n" + 
+							"----------\n" + 
+							"4. ERROR in X.java (at line 3)\n" + 
+							"	final One<@Marker ? extends Two<@Marker ? super Three<? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;		one = null;\n" + 
+							"	                                                                                              ^^^^^^\n" + 
+							"Marker cannot be resolved to a type\n" + 
+							"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=388085
+	public void test0388085a() {
+		this.runNegativeTest(
+				new String[] {"X.java",
+						"import java.lang.annotation.Target;\n" + 
+						"import static java.lang.annotation.ElementType.*;\n" + 
+						"class X {\n" +
+						"	public void main() {\n" +
+						"		final One<@Marker ? extends Two<@Marker ? super Three<? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;" +
+						"		one = null;\n" +
+						"	}\n" +
+						"}\n" +
+						"class One<R> {}\n" +
+						"class Two<S> {}\n" +
+						"class Three<T> {}\n" +
+						"class Four<U, V> {}\n" +
+						"@interface Marker {}"},
+						"----------\n" + 
+						"1. ERROR in X.java (at line 5)\n" + 
+						"	final One<@Marker ? extends Two<@Marker ? super Three<? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;		one = null;\n" + 
+						"	          ^^^^^^^\n" + 
+						"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
+						"----------\n" + 
+						"2. ERROR in X.java (at line 5)\n" + 
+						"	final One<@Marker ? extends Two<@Marker ? super Three<? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;		one = null;\n" + 
+						"	                                ^^^^^^^\n" + 
+						"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
+						"----------\n" + 
+						"3. ERROR in X.java (at line 5)\n" + 
+						"	final One<@Marker ? extends Two<@Marker ? super Three<? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;		one = null;\n" + 
+						"	                                                                     ^^^^^^^\n" + 
+						"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
+						"----------\n" + 
+						"4. ERROR in X.java (at line 5)\n" + 
+						"	final One<@Marker ? extends Two<@Marker ? super Three<? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;		one = null;\n" + 
+						"	                                                                                             ^^^^^^^\n" + 
+						"Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + 
+						"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=390882
+	public void test0390882() {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"import java.lang.annotation.Target;\n" +
+					"import static java.lang.annotation.ElementType.*;\n" +
+					"public class X {    \n " +
+					"	Object o1 = (@Marker java.lang.Integer) null;   // 1. Right.\n" +
+					"	Object o2 = (java. @Marker lang.Integer) null;  // 2. Wrong.\n" +
+					"	Object o3 = (java.lang. @Marker Integer) null;  // 3. Wrong.\n" +
+					"	public void foo(java. @Marker lang.Integer arg) {}\n" +
+					"	public void bar(java.lang. @Marker Integer arg) {}\n" +
+					"	public void foobar(@Marker java.lang.Integer arg) {}\n" +
+					"}\n" +
+					"@Target(TYPE_USE)\n" +
+					"@interface Marker {}\n",
+
+					"java/lang/annotation/ElementType.java",
+					"package java.lang.annotation;\n" +
+					"public enum ElementType {\n" +
+					"    TYPE,\n" +
+					"    FIELD,\n" +
+					"    METHOD,\n" +
+					"    PARAMETER,\n" +
+					"    CONSTRUCTOR,\n" +
+					"    LOCAL_VARIABLE,\n" +
+					"    ANNOTATION_TYPE,\n" +
+					"    PACKAGE,\n" +
+					"    TYPE_PARAMETER,\n" +
+					"    TYPE_USE\n" +
+					"}\n"
+				},
+				"----------\n" + 
+				"1. ERROR in X.java (at line 5)\n" + 
+				"	Object o2 = (java. @Marker lang.Integer) null;  // 2. Wrong.\n" + 
+				"	                   ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 6)\n" + 
+				"	Object o3 = (java.lang. @Marker Integer) null;  // 3. Wrong.\n" + 
+				"	                        ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"3. ERROR in X.java (at line 7)\n" + 
+				"	public void foo(java. @Marker lang.Integer arg) {}\n" + 
+				"	                      ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"4. ERROR in X.java (at line 8)\n" + 
+				"	public void bar(java.lang. @Marker Integer arg) {}\n" + 
+				"	                           ^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	public void test0390882a() {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"import java.lang.annotation.Target;\n" +
+					"import static java.lang.annotation.ElementType.*;\n" +
+					"public class X {    \n " +
+					"	Object o1 = (java. @Marker @Annot lang.Integer) null;  // 2. Wrong.\n" +
+					"	Object o2 = (java.lang. @Marker @Annot Integer) null;  // 3. Wrong.\n" +
+					"	Object o3 = (java.@lang lang) null;  // 3. Wrong.\n" +
+					"}\n" +
+					"@Target(TYPE_USE)\n" +
+					"@interface Marker {}\n" +
+					"@Target(TYPE_USE)\n" +
+					"@interface Annot {}",
+
+					"java/lang/annotation/ElementType.java",
+					"package java.lang.annotation;\n" +
+					"public enum ElementType {\n" +
+					"    TYPE,\n" +
+					"    FIELD,\n" +
+					"    METHOD,\n" +
+					"    PARAMETER,\n" +
+					"    CONSTRUCTOR,\n" +
+					"    LOCAL_VARIABLE,\n" +
+					"    ANNOTATION_TYPE,\n" +
+					"    PACKAGE,\n" +
+					"    TYPE_PARAMETER,\n" +
+					"    TYPE_USE\n" +
+					"}\n"
+				},
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	Object o1 = (java. @Marker @Annot lang.Integer) null;  // 2. Wrong.\n" + 
+				"	                   ^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 5)\n" + 
+				"	Object o2 = (java.lang. @Marker @Annot Integer) null;  // 3. Wrong.\n" + 
+				"	                        ^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"3. ERROR in X.java (at line 6)\n" + 
+				"	Object o3 = (java.@lang lang) null;  // 3. Wrong.\n" + 
+				"	             ^^^^^^^^^^^^^^^\n" + 
+				"java.lang cannot be resolved to a type\n" + 
+				"----------\n");
+	}
+	public void test0390882b() {
+		this.runNegativeTest(
+				new String[] {
+					"X.java",
+					"import java.lang.annotation.Target;\n" +
+					"import static java.lang.annotation.ElementType.*;\n" +
+					"public class X {    \n " +
+					"	Object o1 = (java.util.@Marker @Annot List<String>) null; 	// 1. Wrong.\n" +
+					"	Object o2 = (java.lang.@Marker @Annot Integer[]) null;		// 2. Wrong.\n" +
+					"	Object o3 = (java.util.@Marker @Annot List<String>[]) null; // 3. Wrong.\n" +
+					"	Object o4 = (java.lang.Integer @Marker []) null;	// 4. Right.\n" +
+					"}\n" +
+					"@Target(TYPE_USE)\n" +
+					"@interface Marker {}\n" +
+					"@Target(TYPE_USE)\n" +
+					"@interface Annot {}",
+
+					"java/lang/annotation/ElementType.java",
+					"package java.lang.annotation;\n" +
+					"public enum ElementType {\n" +
+					"    TYPE,\n" +
+					"    FIELD,\n" +
+					"    METHOD,\n" +
+					"    PARAMETER,\n" +
+					"    CONSTRUCTOR,\n" +
+					"    LOCAL_VARIABLE,\n" +
+					"    ANNOTATION_TYPE,\n" +
+					"    PACKAGE,\n" +
+					"    TYPE_PARAMETER,\n" +
+					"    TYPE_USE\n" +
+					"}\n"
+				},
+				"----------\n" + 
+				"1. ERROR in X.java (at line 4)\n" + 
+				"	Object o1 = (java.util.@Marker @Annot List<String>) null; 	// 1. Wrong.\n" + 
+				"	                       ^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"2. ERROR in X.java (at line 5)\n" + 
+				"	Object o2 = (java.lang.@Marker @Annot Integer[]) null;		// 2. Wrong.\n" + 
+				"	                       ^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n" + 
+				"3. ERROR in X.java (at line 6)\n" + 
+				"	Object o3 = (java.util.@Marker @Annot List<String>[]) null; // 3. Wrong.\n" + 
+				"	                       ^^^^^^^^^^^^^^\n" + 
+				"Syntax error, type annotations are illegal here\n" + 
+				"----------\n");
+	}
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=385137
+	public void test0385137() {
+		this.runNegativeTest(
+				new String[]{ "A.java",
+				"package p;" +
+				"import java.lang.annotation.Target;\n" + 
+				"import static java.lang.annotation.ElementType.*;\n" + 
+				"public class A<T> { \n" +
+				"	static class B<T> {" +
+				"		static class C<K, V> {" +
+				"		}	" +
+				"	}\n" +
+				"   public void foo() {\n" +
+				"		Object o = (@Marker @Annot A.@Marker B.@Marker C) null;\n" +
+				"		Object o2 = (@Marker p.@Marker A.@Marker B.@Marker C) null;\n" +
+				"   }\n" +
+				"}\n" +
+				"@Target(TYPE_USE)\n" + 
+				"@interface Marker {}\n" +
+				"@Target(TYPE_USE)\n" + 
+				"@interface Annot {}\n",
+
+				"java/lang/annotation/ElementType.java",
+				"package java.lang.annotation;\n" +
+				"public enum ElementType {\n" +
+				"    TYPE,\n" +
+				"    FIELD,\n" +
+				"    METHOD,\n" +
+				"    PARAMETER,\n" +
+				"    CONSTRUCTOR,\n" +
+				"    LOCAL_VARIABLE,\n" +
+				"    ANNOTATION_TYPE,\n" +
+				"    PACKAGE,\n" +
+				"    TYPE_PARAMETER,\n" +
+				"    TYPE_USE\n" +
+				"}\n"},
+					"----------\n" + 
+					"1. ERROR in A.java (at line 6)\n" + 
+					"	Object o = (@Marker @Annot A.@Marker B.@Marker C) null;\n" + 
+					"	            ^^^^^^^^^^^^^^\n" + 
+					"Type annotations are not allowed on type names used to access static members\n" + 
+					"----------\n" + 
+					"2. WARNING in A.java (at line 6)\n" + 
+					"	Object o = (@Marker @Annot A.@Marker B.@Marker C) null;\n" + 
+					"	            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+					"A.B.C is a raw type. References to generic type A<T>.B<T>.C<K,V> should be parameterized\n" + 
+					"----------\n" + 
+					"3. ERROR in A.java (at line 6)\n" + 
+					"	Object o = (@Marker @Annot A.@Marker B.@Marker C) null;\n" + 
+					"	                             ^^^^^^^\n" + 
+					"Type annotations are not allowed on type names used to access static members\n" + 
+					"----------\n" + 
+					"4. ERROR in A.java (at line 7)\n" + 
+					"	Object o2 = (@Marker p.@Marker A.@Marker B.@Marker C) null;\n" + 
+					"	             ^^^^^^^\n" + 
+					"Type annotations are not allowed on type names used to access static members\n" + 
+					"----------\n" + 
+					"5. WARNING in A.java (at line 7)\n" + 
+					"	Object o2 = (@Marker p.@Marker A.@Marker B.@Marker C) null;\n" + 
+					"	             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+					"A.B.C is a raw type. References to generic type A<T>.B<T>.C<K,V> should be parameterized\n" + 
+					"----------\n" + 
+					"6. ERROR in A.java (at line 7)\n" + 
+					"	Object o2 = (@Marker p.@Marker A.@Marker B.@Marker C) null;\n" + 
+					"	                       ^^^^^^^\n" + 
+					"Syntax error, type annotations are illegal here\n" + 
+					"----------\n" + 
+					"7. ERROR in A.java (at line 7)\n" + 
+					"	Object o2 = (@Marker p.@Marker A.@Marker B.@Marker C) null;\n" + 
+					"	                                 ^^^^^^^\n" + 
+					"Type annotations are not allowed on type names used to access static members\n" + 
+					"----------\n");
+	}
+	public void test0385137a() {
+		this.runNegativeTest(
+				new String[]{"A.java",
+				"package p;" +
+				"import java.lang.annotation.Target;\n" + 
+				"import static java.lang.annotation.ElementType.*;\n" + 
+				"public class A { \n" +
+				"	static class B<T> {" +
+				"		static class C<K, V> {" +
+				"		}	" +
+				"	}\n" +
+				"   public void foo() {\n" +
+				"		Object o1 = (@Marker p.@Marker A.@Marker B.@Marker C[]) null;\n" +
+				"		Object o2 = (@Marker @Annot A.@Annot B.C<Integer, String>) null;\n" +
+				"		Object o5 = (@Marker @Annot A.B<String>[]) null;\n" +
+				"   }\n" +
+				"}\n" +
+				"@Target(TYPE_USE)\n" + 
+				"@interface Marker {}\n" +
+				"@Target(TYPE_USE)\n" + 
+				"@interface Annot {}\n",
+
+				"java/lang/annotation/ElementType.java",
+				"package java.lang.annotation;\n" +
+				"public enum ElementType {\n" +
+				"    TYPE,\n" +
+				"    FIELD,\n" +
+				"    METHOD,\n" +
+				"    PARAMETER,\n" +
+				"    CONSTRUCTOR,\n" +
+				"    LOCAL_VARIABLE,\n" +
+				"    ANNOTATION_TYPE,\n" +
+				"    PACKAGE,\n" +
+				"    TYPE_PARAMETER,\n" +
+				"    TYPE_USE\n" +
+				"}\n",
+				},
+				"----------\n" + 
+					"1. ERROR in A.java (at line 6)\n" + 
+					"	Object o1 = (@Marker p.@Marker A.@Marker B.@Marker C[]) null;\n" + 
+					"	             ^^^^^^^\n" + 
+					"Type annotations are not allowed on type names used to access static members\n" + 
+					"----------\n" + 
+					"2. ERROR in A.java (at line 6)\n" + 
+					"	Object o1 = (@Marker p.@Marker A.@Marker B.@Marker C[]) null;\n" + 
+					"	                       ^^^^^^^\n" + 
+					"Syntax error, type annotations are illegal here\n" + 
+					"----------\n" + 
+					"3. ERROR in A.java (at line 6)\n" + 
+					"	Object o1 = (@Marker p.@Marker A.@Marker B.@Marker C[]) null;\n" + 
+					"	                                 ^^^^^^^\n" + 
+					"Type annotations are not allowed on type names used to access static members\n" + 
+					"----------\n" + 
+					"4. ERROR in A.java (at line 7)\n" + 
+					"	Object o2 = (@Marker @Annot A.@Annot B.C<Integer, String>) null;\n" + 
+					"	             ^^^^^^^^^^^^^^\n" + 
+					"Type annotations are not allowed on type names used to access static members\n" + 
+					"----------\n" + 
+					"5. ERROR in A.java (at line 7)\n" + 
+					"	Object o2 = (@Marker @Annot A.@Annot B.C<Integer, String>) null;\n" + 
+					"	                              ^^^^^^\n" + 
+					"Type annotations are not allowed on type names used to access static members\n" + 
+					"----------\n" + 
+					"6. ERROR in A.java (at line 8)\n" + 
+					"	Object o5 = (@Marker @Annot A.B<String>[]) null;\n" + 
+					"	             ^^^^^^^^^^^^^^\n" + 
+					"Type annotations are not allowed on type names used to access static members\n" + 
+					"----------\n");
+	}
 }
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java
index 7886745..e9912b2 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java
@@ -1,9 +1,13 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
@@ -152,12 +156,7 @@
 		evaluateWithExpectedImportProblem(buildCharArray(new String[] {
 			"new File(\"c:\\temp\")"}),
 			"{".toCharArray(),
-//{ObjectTeams: our grammar yields a slightly different error:
-/* orig:			
-			newProblem(IProblem.ParsingError, Error, 0, 0, 1)); // Syntax error on token "{", "Identifier" expected
-  :giro */			
 			newProblem(IProblem.ParsingErrorInvalidToken, Error, 0, 0, 1)); // Syntax error on token "{", "Identifier" expected
-// SH}		
 	} finally {
 		// Clean up
 		this.context.setImports(new char[0][]);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS3.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS3.java
index b9ea950..4ed1818 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS3.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS3.java
@@ -5,6 +5,10 @@
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ * 
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
@@ -765,7 +769,7 @@
 			"No problem",
 			result);
 }
-public void _testBug130778q() throws JavaModelException {
+public void testBug130778q() throws JavaModelException {
 	this.workingCopies = new ICompilationUnit[2];
 
 	this.workingCopies[0] = getWorkingCopy(
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java
index 14fc55e..064ca2c 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java
@@ -5,6 +5,10 @@
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ * 
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
index 71c0745..eda577e 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
@@ -786,6 +786,17 @@
 									this.identifierLengthPtr--;
 								} else {
 									this.identifierLengthStack[this.identifierLengthPtr]--;
+									length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--];
+									Annotation [] typeAnnotations;
+									if (length != 0) {
+										System.arraycopy(
+												this.typeAnnotationStack,
+												(this.typeAnnotationPtr -= length) + 1,
+												typeAnnotations = new Annotation[length],
+												0,
+												length);
+										problemReporter().misplacedTypeAnnotations(typeAnnotations[0], typeAnnotations[typeAnnotations.length - 1]);
+									}
 								}
 								// consume the receiver
 								int identifierLength = this.identifierLengthStack[this.identifierLengthPtr];
@@ -1202,12 +1213,9 @@
 				if(info == LESS && node instanceof TypeReference) {
 					if(this.identifierLengthPtr > -1 && this.identifierLengthStack[this.identifierLengthPtr]!= 0) {
 						if (consumeTypeArguments) consumeTypeArguments();
-						TypeReference ref;
+						TypeReference ref = this.getTypeReference(0);
 						if(prevKind == K_PARAMETERIZED_CAST) {
-							ref = this.getUnannotatedTypeReference(0);  // by design type is not annotated.
-							ref = computeQualifiedGenericsFromRightSide(ref, 0);
-						} else {
-							ref = this.getTypeReference(0);
+							ref = computeQualifiedGenericsFromRightSide(ref, 0, null);
 						}
 						if(this.currentElement instanceof RecoveredType) {
 							this.currentElement = this.currentElement.add(new CompletionOnFieldType(ref, false), 0);
@@ -1625,6 +1633,17 @@
 						this.identifierLengthPtr--;
 					} else {
 						this.identifierLengthStack[this.identifierLengthPtr]--;
+						int length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--];
+						Annotation [] typeAnnotations;
+						if (length != 0) {
+							System.arraycopy(
+									this.typeAnnotationStack,
+									(this.typeAnnotationPtr -= length) + 1,
+									typeAnnotations = new Annotation[length],
+									0,
+									length);
+							problemReporter().misplacedTypeAnnotations(typeAnnotations[0], typeAnnotations[typeAnnotations.length - 1]);
+						}
 					}
 					// consume the receiver
 					messageSend.receiver = getUnspecifiedReference();
@@ -2407,34 +2426,6 @@
 	cast.sourceStart = castType.sourceStart - 1;
 	cast.sourceEnd = exp.sourceEnd;
 }
-protected void consumeCastExpressionWithPrimitiveTypeWithTypeAnnotations() {
-	popElement(K_CAST_STATEMENT);
-
-	Expression expression = this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	TypeReference typeReference = (TypeReference) this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.sourceStart = typeReferenceSourceStart;
-	}
-
-	Expression cast;
-	pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
-	cast.sourceStart = typeReference.sourceStart - 1;
-	cast.sourceEnd = expression.sourceEnd;
-}
 protected void consumeCastExpressionWithGenericsArray() {
 	popElement(K_CAST_STATEMENT);
 
@@ -2447,36 +2438,7 @@
 	cast.sourceStart = castType.sourceStart - 1;
 	cast.sourceEnd = exp.sourceEnd;
 }
-protected void consumeCastExpressionWithGenericsArrayWithTypeAnnotations() {
-	popElement(K_CAST_STATEMENT);
- 
-	Expression exp = this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	// pop the type reference
-	TypeReference typeReference = (TypeReference) this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
 
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.sourceStart = typeReferenceSourceStart;
-	}
-
-	Expression cast;
-	pushOnExpressionStack(cast = new CastExpression(exp, typeReference));
-	cast.sourceStart = typeReference.sourceStart - 1;
-	cast.sourceEnd = exp.sourceEnd;
-}
 protected void consumeCastExpressionWithQualifiedGenericsArray() {
 	popElement(K_CAST_STATEMENT);
 
@@ -2489,33 +2451,6 @@
 	cast.sourceStart = castType.sourceStart - 1;
 	cast.sourceEnd = exp.sourceEnd;
 }
-protected void consumeCastExpressionWithQualifiedGenericsArrayWithTypeAnnotations() {
-	popElement(K_CAST_STATEMENT);
-
-	Expression expression = this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	TypeReference typeReference = (TypeReference) this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.sourceStart = typeReferenceSourceStart;
-	}
-	Expression cast;
-	pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
-	cast.sourceStart = typeReference.sourceStart - 1;
-	cast.sourceEnd = expression.sourceEnd;
-}
 protected void consumeCastExpressionWithNameArray() {
 	// CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
 	popElement(K_CAST_STATEMENT);
@@ -2529,42 +2464,10 @@
 	cast.sourceStart = castType.sourceStart - 1;
 	cast.sourceEnd = exp.sourceEnd;
 }
-protected void consumeCastExpressionWithNameArrayWithTypeAnnotations() {
-	popElement(K_CAST_STATEMENT);
-
-	Expression expression = this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	TypeReference typeReference = (TypeReference) this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.sourceStart = typeReferenceSourceStart;
-	}
-	Expression cast;
-	pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
-	cast.sourceStart = typeReference.sourceStart - 1;
-	cast.sourceEnd = expression.sourceEnd;
-}
 protected void consumeCastExpressionLL1() {
 	popElement(K_CAST_STATEMENT);
 	super.consumeCastExpressionLL1();
 }
-protected void consumeCastExpressionLL1WithTypeAnnotations() {
-	popElement(K_CAST_STATEMENT);
-	super.consumeCastExpressionLL1WithTypeAnnotations();
-}
 protected void consumeCatchFormalParameter() {
 	if (this.indexOfAssistIdentifier() < 0) {
 		super.consumeCatchFormalParameter();
@@ -3064,31 +2967,34 @@
 		char[] identifierName = this.identifierStack[this.identifierPtr];
 		long namePositions = this.identifierPositionStack[this.identifierPtr--];
 		int extendedDimensions = this.intStack[this.intPtr--];
+		Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : getAnnotationsOnDimensions(extendedDimensions);
+		Annotation [] varArgsAnnotations = null;
+		int length;
 		int endOfEllipsis = 0;
 		if (isVarArgs) {
 			endOfEllipsis = this.intStack[this.intPtr--];
+			if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
+				System.arraycopy(
+					this.typeAnnotationStack,
+					(this.typeAnnotationPtr -= length) + 1,
+					varArgsAnnotations = new Annotation[length],
+					0,
+					length);
+			} 
 		}
 		int firstDimensions = this.intStack[this.intPtr--];
-		TypeReference type = getUnannotatedTypeReference(extendedDimensions);
-		Annotation [] varArgsAnnotations = null;
-		int length;
-		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
-			System.arraycopy(
-				this.typeAnnotationStack,
-				(this.typeAnnotationPtr -= length) + 1,
-				varArgsAnnotations = new Annotation[length],
-				0,
-				length);
-		} 
+		TypeReference type = getTypeReference(firstDimensions);
+		
 		final int typeDimensions = firstDimensions + extendedDimensions + (isVarArgs ? 1 : 0);
-		if (typeDimensions != extendedDimensions) {
+		if (typeDimensions != firstDimensions) {
 			// jsr308 type annotations management
-			Annotation [][] annotationsOnFirstDimensions = firstDimensions == 0 ? null : getAnnotationsOnDimensions(firstDimensions);
-			Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : type.getAnnotationsOnDimensions();
-			Annotation [][] annotationsOnAllDimensions = null;
-			if (annotationsOnFirstDimensions != null || annotationsOnExtendedDimensions != null || varArgsAnnotations != null) {
-				annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions, annotationsOnFirstDimensions, extendedDimensions, annotationsOnExtendedDimensions); 
-				annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions + extendedDimensions, annotationsOnAllDimensions, isVarArgs ? 1 : 0, isVarArgs ? new Annotation[][]{varArgsAnnotations} : null);
+			Annotation [][] annotationsOnFirstDimensions = firstDimensions == 0 ? null : type.getAnnotationsOnDimensions();
+			Annotation [][] annotationsOnAllDimensions = annotationsOnFirstDimensions;
+			if (annotationsOnExtendedDimensions != null) {
+				annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions, annotationsOnFirstDimensions, extendedDimensions, annotationsOnExtendedDimensions);
+			}
+			if (varArgsAnnotations != null) {
+				annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions + extendedDimensions, annotationsOnAllDimensions, 1, new Annotation[][]{varArgsAnnotations});
 			}
 			type = copyDims(type, typeDimensions, annotationsOnAllDimensions);
 			type.sourceEnd = type.isParameterizedTypeReference() ? this.endStatementPosition : this.endPosition;
@@ -3208,24 +3114,6 @@
 	}
 	pushOnElementStack(K_CAST_STATEMENT);
 }
-protected void consumeInsideCastExpressionWithAnnotatedQualifiedGenerics() {
-	popElement(K_PARAMETERIZED_CAST);
-
-	Expression castType;
-	int end = this.intStack[this.intPtr--];
-
-	int dim = this.intStack[this.intPtr--];
-	// TODO is it an annotated type reference?
-	TypeReference rightSide = getUnannotatedTypeReference(0); // by design the type after . is not annotated.
-
-	castType = computeQualifiedGenericsFromRightSide(rightSide, dim);
-	this.intPtr--;
-	castType.sourceEnd = end - 1;
-	castType.sourceStart = this.intStack[this.intPtr--] + 1;
-	pushOnExpressionStack(castType);
-
-	pushOnElementStack(K_CAST_STATEMENT);
-}
 protected void consumeInsideCastExpressionWithQualifiedGenerics() {
 	popElement(K_PARAMETERIZED_CAST);
 
@@ -3233,9 +3121,10 @@
 	int end = this.intStack[this.intPtr--];
 
 	int dim = this.intStack[this.intPtr--];
-	TypeReference rightSide = getUnannotatedTypeReference(0); // by design the type after . is not annotated.
+	Annotation[][] annotationsOnDimensions = dim == 0 ? null : getAnnotationsOnDimensions(dim);
+	TypeReference rightSide = getTypeReference(0);
 
-	castType = computeQualifiedGenericsFromRightSide(rightSide, dim);
+	castType = computeQualifiedGenericsFromRightSide(rightSide, dim, annotationsOnDimensions);
 	this.intPtr--;
 	castType.sourceEnd = end - 1;
 	castType.sourceStart = this.intStack[this.intPtr--] + 1;
@@ -3626,14 +3515,14 @@
 	pushOnLabelStack(this.identifierStack[this.identifierPtr]);
 	this.pushOnElementStack(K_LABEL, this.labelPtr);
 }
-protected void consumeMarkerAnnotation() {
+protected void consumeMarkerAnnotation(boolean isTypeAnnotation) {
 	if (this.topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN &&
 			(this.topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) & ANNOTATION_NAME_COMPLETION) != 0 ) {
 		popElement(K_BETWEEN_ANNOTATION_NAME_AND_RPAREN);
 		this.restartRecovery = true;
 	} else {
 		popElement(K_BETWEEN_ANNOTATION_NAME_AND_RPAREN);
-		super.consumeMarkerAnnotation();
+		super.consumeMarkerAnnotation(isTypeAnnotation);
 	}
 }
 protected void consumeMemberValuePair() {
@@ -3723,14 +3612,14 @@
 		popElement(K_LOCAL_INITIALIZER_DELIMITER);
 	}
 }
-protected void consumeSingleMemberAnnotation() {
+protected void consumeSingleMemberAnnotation(boolean isTypeAnnotation) {
 	if (this.topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN &&
 			(this.topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) & ANNOTATION_NAME_COMPLETION) != 0 ) {
 		popElement(K_BETWEEN_ANNOTATION_NAME_AND_RPAREN);
 		this.restartRecovery = true;
 	} else {
 		popElement(K_BETWEEN_ANNOTATION_NAME_AND_RPAREN);
-		super.consumeSingleMemberAnnotation();
+		super.consumeSingleMemberAnnotation(isTypeAnnotation);
 	}
 }
 protected void consumeSingleStaticImportDeclarationName() {
@@ -3787,14 +3676,14 @@
 	super.consumeNestedMethod();
 	if(!(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BLOCK_DELIMITER)) pushOnElementStack(K_BLOCK_DELIMITER);
 }
-protected void consumeNormalAnnotation() {
+protected void consumeNormalAnnotation(boolean isTypeAnnotation) {
 	if (this.topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN &&
 			(this.topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) & ANNOTATION_NAME_COMPLETION) != 0 ) {
 		popElement(K_BETWEEN_ANNOTATION_NAME_AND_RPAREN);
 		this.restartRecovery = true;
 	} else {
 		popElement(K_BETWEEN_ANNOTATION_NAME_AND_RPAREN);
-		super.consumeNormalAnnotation();
+		super.consumeNormalAnnotation(isTypeAnnotation);
 	}
 }
 protected void consumePackageDeclarationName() {
@@ -5046,8 +4935,8 @@
 
 	return ref;
 }
-protected NameReference getUnspecifiedReference() {
-	NameReference nameReference = super.getUnspecifiedReference();
+protected NameReference getUnspecifiedReference(boolean rejectTypeAnnotations) {
+	NameReference nameReference = super.getUnspecifiedReference(rejectTypeAnnotations);
 	if (this.record) {
 		recordReference(nameReference);
 	}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
index f1b11a2..529cd92 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
@@ -985,18 +985,18 @@
 /*
  * Build specific type reference nodes in case the cursor is located inside the type reference
  */
-protected TypeReference getUnannotatedTypeReference(int dim) {
+protected TypeReference getTypeReference(int dim) {
 //{ObjectTeams: wrap to introduce 2nd parameter
-	return getUnannotatedTypeReference(dim, false);  
+	return getTypeReference(dim, false);  
 }
-protected TypeReference getUnannotatedTypeReference(int dim, boolean liftingTypeAllowed) {
+protected TypeReference getTypeReference(int dim, boolean liftingTypeAllowed) {
 // orig:
 	int index;
 
 	/* no need to take action if not inside completed identifiers */
 	if ((index = indexOfAssistIdentifier(true)) < 0) {
 // orig: FIXME
-		return super.getUnannotatedTypeReference(dim);
+		return super.getTypeReference(dim);
 // :giro */
 // OT PREVIOUS:
 //		return super.getUnannotatedTypeReference(dim, liftingTypeAllowed);
@@ -1159,6 +1159,8 @@
 		return super.getUnspecifiedReferenceOptimized();
 	}
 
+	consumeNonTypeUseName();
+	
 	/* retrieve identifiers subset and whole positions, the completion node positions
 		should include the entire replaced source. */
 	int length = this.identifierLengthStack[this.identifierLengthPtr];
@@ -1806,7 +1808,6 @@
 	this.astLengthPtr = -1;
 	this.expressionPtr = -1;
 	this.expressionLengthPtr = -1;
-	this.unattachedAnnotationPtr = -1;
 	this.typeAnnotationLengthPtr = -1;
 	this.typeAnnotationPtr = -1;
 	this.identifierPtr = -1;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
index 20e1d60..fb3a44d 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
@@ -242,6 +242,7 @@
 		char [] oldIdent = assistIdentifier();
 		setAssistIdentifier(null);
 		alloc.type = getTypeReference(0);
+		rejectIllegalLeadingTypeAnnotations(alloc.type);
 		checkForDiamond(alloc.type);
 
 		setAssistIdentifier(oldIdent);
@@ -404,6 +405,7 @@
 		char [] oldIdent = assistIdentifier();
 		setAssistIdentifier(null);
 		alloc.type = getTypeReference(0);
+		rejectIllegalLeadingTypeAnnotations(alloc.type);
 		checkForDiamond(alloc.type);
 
 		setAssistIdentifier(oldIdent);
@@ -645,31 +647,34 @@
 		char[] identifierName = this.identifierStack[this.identifierPtr];
 		long namePositions = this.identifierPositionStack[this.identifierPtr--];
 		int extendedDimensions = this.intStack[this.intPtr--];
+		Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : getAnnotationsOnDimensions(extendedDimensions);
+		Annotation [] varArgsAnnotations = null;
+		int length;
 		int endOfEllipsis = 0;
 		if (isVarArgs) {
 			endOfEllipsis = this.intStack[this.intPtr--];
+			if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
+				System.arraycopy(
+					this.typeAnnotationStack,
+					(this.typeAnnotationPtr -= length) + 1,
+					varArgsAnnotations = new Annotation[length],
+					0,
+					length);
+			} 
 		}
 		int firstDimensions = this.intStack[this.intPtr--];
-		TypeReference type = getUnannotatedTypeReference(extendedDimensions);
-		Annotation [] varArgsAnnotations = null;
-		int length;
-		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
-			System.arraycopy(
-				this.typeAnnotationStack,
-				(this.typeAnnotationPtr -= length) + 1,
-				varArgsAnnotations = new Annotation[length],
-				0,
-				length);
-		} 
+		TypeReference type = getTypeReference(firstDimensions);
+
 		final int typeDimensions = firstDimensions + extendedDimensions + (isVarArgs ? 1 : 0);
-		if (typeDimensions != extendedDimensions) {
+		if (typeDimensions != firstDimensions) {
 			// jsr308 type annotations management
-			Annotation [][] annotationsOnFirstDimensions = firstDimensions == 0 ? null : getAnnotationsOnDimensions(firstDimensions);
-			Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : type.getAnnotationsOnDimensions();
-			Annotation [][] annotationsOnAllDimensions = null;
-			if (annotationsOnFirstDimensions != null || annotationsOnExtendedDimensions != null || varArgsAnnotations != null) {
-				annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions, annotationsOnFirstDimensions, extendedDimensions, annotationsOnExtendedDimensions); 
-				annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions + extendedDimensions, annotationsOnAllDimensions, isVarArgs ? 1 : 0, isVarArgs ? new Annotation[][]{varArgsAnnotations} : null);
+			Annotation [][] annotationsOnFirstDimensions = firstDimensions == 0 ? null : type.getAnnotationsOnDimensions();
+			Annotation [][] annotationsOnAllDimensions = annotationsOnFirstDimensions;
+			if (annotationsOnExtendedDimensions != null) {
+				annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions, annotationsOnFirstDimensions, extendedDimensions, annotationsOnExtendedDimensions);
+			}
+			if (varArgsAnnotations != null) {
+				annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions + extendedDimensions, annotationsOnAllDimensions, 1, new Annotation[][]{varArgsAnnotations});
 			}
 			type = copyDims(type, typeDimensions, annotationsOnAllDimensions);
 			type.sourceEnd = type.isParameterizedTypeReference() ? this.endStatementPosition : this.endPosition;
@@ -773,11 +778,11 @@
 		}
 	}
 }
-protected void consumeMarkerAnnotation() {
+protected void consumeMarkerAnnotation(boolean isTypeAnnotation) {
 	int index;
 
 	if ((index = this.indexOfAssistIdentifier()) < 0) {
-		super.consumeMarkerAnnotation();
+		super.consumeMarkerAnnotation(isTypeAnnotation);
 		return;
 	}
 
@@ -818,7 +823,11 @@
 
 	markerAnnotation = new MarkerAnnotation(typeReference, this.intStack[this.intPtr--]);
 	markerAnnotation.declarationSourceEnd = markerAnnotation.sourceEnd;
-	pushOnExpressionStack(markerAnnotation);
+	if (isTypeAnnotation) {
+		pushOnTypeAnnotationStack(markerAnnotation);
+	} else {
+		pushOnExpressionStack(markerAnnotation);
+	}
 }
 protected void consumeMemberValuePair() {
 	if (this.indexOfAssistIdentifier() < 0) {
@@ -958,11 +967,11 @@
 	this.lastCheckPoint = constructorCall.sourceEnd + 1;
 	this.isOrphanCompletionNode = true;
 }
-protected void consumeNormalAnnotation() {
+protected void consumeNormalAnnotation(boolean isTypeAnnotation) {
 	int index;
 
 	if ((index = this.indexOfAssistIdentifier()) < 0) {
-		super.consumeNormalAnnotation();
+		super.consumeNormalAnnotation(isTypeAnnotation);
 		return;
 	}
 
@@ -1011,13 +1020,17 @@
 			length);
 	}
 	normalAnnotation.declarationSourceEnd = this.rParenPos;
-	pushOnExpressionStack(normalAnnotation);
+	if (isTypeAnnotation) {
+		pushOnTypeAnnotationStack(normalAnnotation);
+	} else {
+		pushOnExpressionStack(normalAnnotation);
+	}
 }
-protected void consumeSingleMemberAnnotation() {
+protected void consumeSingleMemberAnnotation(boolean isTypeAnnotation) {
 	int index;
 
 	if ((index = this.indexOfAssistIdentifier()) < 0) {
-		super.consumeSingleMemberAnnotation();
+		super.consumeSingleMemberAnnotation(isTypeAnnotation);
 		return;
 	}
 
@@ -1060,7 +1073,11 @@
 	singleMemberAnnotation.memberValue = this.expressionStack[this.expressionPtr--];
 	this.expressionLengthPtr--;
 	singleMemberAnnotation.declarationSourceEnd = this.rParenPos;
-	pushOnExpressionStack(singleMemberAnnotation);
+	if (isTypeAnnotation) {
+		pushOnTypeAnnotationStack(singleMemberAnnotation);
+	} else {
+		pushOnExpressionStack(singleMemberAnnotation);
+	}
 }
 protected void consumeStaticImportOnDemandDeclarationName() {
 	// TypeImportOnDemandDeclarationName ::= 'import' 'static' Name '.' '*'
@@ -1256,25 +1273,32 @@
 	selectionScanner.selectionEnd = end;
 	return this.dietParse(sourceUnit, compilationResult);
 }
-protected NameReference getUnspecifiedReference() {
+protected NameReference getUnspecifiedReference(boolean rejectTypeAnnotations) {
 	/* build a (unspecified) NameReference which may be qualified*/
 
 	int completionIndex;
 
 	/* no need to take action if not inside completed identifiers */
 	if ((completionIndex = indexOfAssistIdentifier()) < 0) {
-		return super.getUnspecifiedReference();
+		return super.getUnspecifiedReference(rejectTypeAnnotations);
 	}
 
+	if (rejectTypeAnnotations) {
+		consumeNonTypeUseName();
+	}
 	int length = this.identifierLengthStack[this.identifierLengthPtr];
 	if (CharOperation.equals(assistIdentifier(), SUPER)){
 		Reference reference;
 		if (completionIndex > 0){ // qualified super
 			// discard 'super' from identifier stacks
+			// There is some voodoo going on here in combination with SelectionScanne#scanIdentifierOrKeyword, do in Rome as Romans do and leave the stacks at the right depth.
 			this.identifierLengthStack[this.identifierLengthPtr] = completionIndex;
 			int ptr = this.identifierPtr -= (length - completionIndex);
 			pushOnGenericsLengthStack(0);
 			pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
+			for (int i = 0; i < completionIndex; i++) {
+				pushOnTypeAnnotationLengthStack(0);
+			}
 			reference =
 				new SelectionOnQualifiedSuperReference(
 					getTypeReference(0),
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
index ee241db..7ab77fc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
@@ -1304,7 +1304,7 @@
     /** @since 3.9 */
     int MisplacedTypeAnnotations = Syntax + Internal + 639;
     /** @since 3.9 */
-    int InvalidLocationForModifiers = Syntax + Internal + 640;
+    int IllegalTypeAnnotationsInStaticMemberAccess = Internal + Syntax + 640;
     /** @since 3.9*/
     int IllegalUsageOfTypeAnnotations = Internal + Syntax + 641;
     /** @since 3.9*/
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index 97db77b..d986c81 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -829,122 +829,6 @@
 		}
 	}
 
-	/**
-	 * Resolve annotations, and check duplicates, answers combined tagBits
-	 * for recognized standard annotations
-	 */
-	public static void resolveAnnotations(ClassScope scope, Annotation[] sourceAnnotations, Binding recipient) {
-		AnnotationBinding[] annotations = null;
-		int length = sourceAnnotations == null ? 0 : sourceAnnotations.length;
-		if (recipient != null) {
-			switch (recipient.kind()) {
-				case Binding.PACKAGE :
-					PackageBinding packageBinding = (PackageBinding) recipient;
-					if ((packageBinding.tagBits & TagBits.AnnotationResolved) != 0) return;
-					packageBinding.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
-					break;
-				case Binding.TYPE :
-				case Binding.GENERIC_TYPE :
-					ReferenceBinding type = (ReferenceBinding) recipient;
-					if ((type.tagBits & TagBits.AnnotationResolved) != 0) return;
-					type.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
-					if (length > 0) {
-						annotations = new AnnotationBinding[length];
-						type.setAnnotations(annotations);
-					}
-					break;
-				case Binding.METHOD :
-					MethodBinding method = (MethodBinding) recipient;
-					if ((method.tagBits & TagBits.AnnotationResolved) != 0) return;
-					method.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
-					if (length > 0) {
-						annotations = new AnnotationBinding[length];
-						method.setAnnotations(annotations);
-					}
-					break;
-				case Binding.FIELD :
-					FieldBinding field = (FieldBinding) recipient;
-					if ((field.tagBits & TagBits.AnnotationResolved) != 0) return;
-					field.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
-					if (length > 0) {
-						annotations = new AnnotationBinding[length];
-						field.setAnnotations(annotations);
-					}
-					break;
-				case Binding.LOCAL :
-					LocalVariableBinding local = (LocalVariableBinding) recipient;
-					if ((local.tagBits & TagBits.AnnotationResolved) != 0) return;
-					local.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
-					if (length > 0) {
-						annotations = new AnnotationBinding[length];
-						local.setAnnotations(annotations, scope);
-					}
-					break;
-				default :
-					return;
-			}
-		}
-		if (sourceAnnotations == null)
-			return;
-		for (int i = 0; i < length; i++) {
-			Annotation annotation = sourceAnnotations[i];
-			final Binding annotationRecipient = annotation.recipient;
-			if (annotationRecipient != null && recipient != null) {
-				// only local and field can share annnotations
-				switch (recipient.kind()) {
-					case Binding.FIELD :
-						FieldBinding field = (FieldBinding) recipient;
-						field.tagBits = ((FieldBinding) annotationRecipient).tagBits;
-						break;
-					case Binding.LOCAL :
-						LocalVariableBinding local = (LocalVariableBinding) recipient;
-						local.tagBits = ((LocalVariableBinding) annotationRecipient).tagBits;
-						break;
-				}
-				if (annotations != null) {
-					// need to fill the instances array
-					annotations[0] = annotation.getCompilerAnnotation();
-					for (int j = 1; j < length; j++) {
-						Annotation annot = sourceAnnotations[j];
-						annotations[j] = annot.getCompilerAnnotation();
-					}
-				}
-				return;
-			} else {
-				annotation.recipient = recipient;
-				annotation.resolveType(scope);
-				// null if receiver is a package binding
-				if (annotations != null) {
-					annotations[i] = annotation.getCompilerAnnotation();
-				}
-			}
-		}
-		// check duplicate annotations
-		if (annotations != null) {
-			AnnotationBinding[] distinctAnnotations = annotations; // only copy after 1st duplicate is detected
-			for (int i = 0; i < length; i++) {
-				AnnotationBinding annotation = distinctAnnotations[i];
-				if (annotation == null) continue;
-				TypeBinding annotationType = annotation.getAnnotationType();
-				boolean foundDuplicate = false;
-				for (int j = i+1; j < length; j++) {
-					AnnotationBinding otherAnnotation = distinctAnnotations[j];
-					if (otherAnnotation == null) continue;
-					if (otherAnnotation.getAnnotationType() == annotationType) {
-						foundDuplicate = true;
-						if (distinctAnnotations == annotations) {
-							System.arraycopy(distinctAnnotations, 0, distinctAnnotations = new AnnotationBinding[length], 0, length);
-						}
-						distinctAnnotations[j] = null; // report it only once
-						scope.problemReporter().duplicateAnnotation(sourceAnnotations[j]);
-					}
-				}
-				if (foundDuplicate) {
-					scope.problemReporter().duplicateAnnotation(sourceAnnotations[i]);
-				}
-			}
-		}
-	}
 /**
  * Figures if @Deprecated annotation is specified, do not resolve entire annotations.
  */
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
index b14573e..2b503da 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
@@ -358,7 +358,7 @@
 		return result;
 	}
 	
-	// jsr 308
+	    // jsr 308
 		public static class TypeUseBinding extends ReferenceBinding {
 			private int kind;
 			public TypeUseBinding(int kind) {
@@ -369,7 +369,6 @@
 				return this.kind;
 			}
 			public boolean hasTypeBit(int bit) {
-				// TODO Auto-generated method stub
 				return false;
 			}
 		}
@@ -773,6 +772,11 @@
 					case Binding.PACKAGE :
 						((PackageBinding)this.recipient).tagBits |= tagBits;
 						break;
+					case Binding.TYPE_PARAMETER:
+					case Binding.TYPE_USE:
+						ReferenceBinding typeAnnotationRecipient = (ReferenceBinding) this.recipient;
+						typeAnnotationRecipient.tagBits |= tagBits;
+						break;
 					case Binding.TYPE :
 					case Binding.GENERIC_TYPE :
 						SourceTypeBinding sourceType = (SourceTypeBinding) this.recipient;
@@ -910,7 +914,6 @@
 						if ((metaTagBits & TagBits.AnnotationForField) != 0) {
 							break checkTargetCompatibility;
 						} else if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) {
-							// jsr 308 - annotation on field type
 							break checkTargetCompatibility;
 						}
 						break;
@@ -919,13 +922,11 @@
 							if ((metaTagBits & TagBits.AnnotationForParameter) != 0) {
 								break checkTargetCompatibility;
 							} else if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) {
-								// jsr 308 - annotation on method parameter type
 								break checkTargetCompatibility;
 							}
 						} else if ((annotationType.tagBits & TagBits.AnnotationForLocalVariable) != 0) {
 							break checkTargetCompatibility;
 						} else if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) {
-							// jsr 308 - annotation on local type
 							break checkTargetCompatibility;
 						}
 						break;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
index 6bea210..66f924a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
@@ -40,7 +40,8 @@
 	public ArrayQualifiedTypeReference(char[][] sources, int dim, Annotation[][] annotationsOnDimensions, long[] poss) {
 		this(sources, dim, poss);
 		this.annotationsOnDimensions = annotationsOnDimensions;
-		this.bits |= ASTNode.HasTypeAnnotations;
+		if (annotationsOnDimensions != null)
+			this.bits |= ASTNode.HasTypeAnnotations;
 	}
 
 	public int dimensions() {
@@ -51,6 +52,10 @@
 	public Annotation[][] getAnnotationsOnDimensions() {
 		return this.annotationsOnDimensions;
 	}
+	
+	public void setAnnotationsOnDimensions(Annotation [][] annotationsOnDimensions) {
+		this.annotationsOnDimensions = annotationsOnDimensions;
+	}
 
 	/**
 	 * @return char[][]
@@ -153,7 +158,7 @@
 			if (this.annotationsOnDimensions != null) {
 				for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
 					Annotation[] annotations2 = this.annotationsOnDimensions[i];
-					for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+					for (int j = 0, max2 = annotations2 == null ? 0 : annotations2.length; j < max2; j++) {
 						Annotation annotation = annotations2[j];
 						annotation.traverse(visitor, scope);
 					}
@@ -176,7 +181,7 @@
 			if (this.annotationsOnDimensions != null) {
 				for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
 					Annotation[] annotations2 = this.annotationsOnDimensions[i];
-					for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+					for (int j = 0, max2 = annotations2 == null ? 0 : annotations2.length; j < max2; j++) {
 						Annotation annotation = annotations2[j];
 						annotation.traverse(visitor, scope);
 					}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
index a233368..5a92d95 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
@@ -57,6 +57,9 @@
 	public Annotation[][] getAnnotationsOnDimensions() {
 		return this.annotationsOnDimensions;
 	}
+	public void setAnnotationsOnDimensions(Annotation [][] annotationsOnDimensions) {
+		this.annotationsOnDimensions = annotationsOnDimensions;
+	}
 	/**
 	 * @return char[][]
 	 */
@@ -117,11 +120,9 @@
 	public void traverse(ASTVisitor visitor, BlockScope scope) {
 		if (visitor.visit(this, scope)) {
 			if (this.annotations != null) {
-				int annotationsLevels = this.annotations.length;
-				for (int i = 0; i < annotationsLevels; i++) {
-					int annotationsLength = this.annotations[i] == null ? 0 : this.annotations[i].length;
-					for (int j = 0; j < annotationsLength; j++)
-						this.annotations[i][j].traverse(visitor, scope);
+				Annotation [] typeAnnotations = this.annotations[0];
+				for (int i = 0, length = typeAnnotations == null ? 0 : typeAnnotations.length; i < length; i++) {
+					typeAnnotations[i].traverse(visitor, scope);
 				}
 			}
 			if (this.annotationsOnDimensions != null) {
@@ -142,11 +143,9 @@
 	public void traverse(ASTVisitor visitor, ClassScope scope) {
 		if (visitor.visit(this, scope)) {
 			if (this.annotations != null) {
-				int annotationsLevels = this.annotations.length;
-				for (int i = 0; i < annotationsLevels; i++) {
-					int annotationsLength = this.annotations[i] == null ? 0 : this.annotations[i].length;
-					for (int j = 0; j < annotationsLength; j++)
-						this.annotations[i][j].traverse(visitor, scope);
+				Annotation [] typeAnnotations = this.annotations[0];
+				for (int i = 0, length = typeAnnotations == null ? 0 : typeAnnotations.length; i < length; i++) {
+					typeAnnotations[i].traverse(visitor, scope);
 				}
 			}
 			if (this.annotationsOnDimensions != null) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
index 4237d44..9abce54 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
@@ -389,11 +389,6 @@
 		}
 		// only resolve annotation at the end, for constant to be positioned before (96991)
 		resolveAnnotations(scope, this.annotations, this.binding);
-		// jsr 308
-		Annotation[][] typeAnnotations = this.type.annotations;
-		if (typeAnnotations != null) {
-			ASTNode.resolveAnnotations(scope, typeAnnotations, new Annotation.TypeUseBinding(Binding.TYPE_USE));
-		}
 		scope.validateNullAnnotation(this.binding.tagBits, this.type, this.annotations);
 	}
 
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
index 7d04018..600e889 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
@@ -206,6 +206,8 @@
 		}
 
 		PackageBinding packageBinding = binding == null ? null : (PackageBinding) binding;
+		rejectAnnotationsOnPackageQualifiers(scope, packageBinding);
+
 		boolean typeIsConsistent = true;
 		ReferenceBinding qualifyingType = null;
 		for (int i = packageBinding == null ? 0 : packageBinding.compoundName.length, max = this.tokens.length; i < max; i++) {
@@ -238,6 +240,7 @@
 						: scope.environment().convertToParameterizedType(qualifyingType);
 				}
 			} else {
+				 rejectAnnotationsOnStaticMemberQualififer(scope, currentType, packageBinding, i);
 				if (typeIsConsistent && currentType.isStatic()
 						&& (qualifyingType.isParameterizedTypeWithActualArguments() || qualifyingType.isGenericType())) {
 					scope.problemReporter().staticMemberOfParameterizedType(this, scope.environment().createParameterizedType((ReferenceBinding)currentType.erasure(), null, qualifyingType), i);
@@ -439,7 +442,7 @@
 			if (this.annotationsOnDimensions != null) {
 				for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
 					Annotation[] annotations2 = this.annotationsOnDimensions[i];
-					for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+					for (int j = 0, max2 = annotations2 == null ? 0 : annotations2.length; j < max2; j++) {
 						Annotation annotation = annotations2[j];
 						annotation.traverse(visitor, scope);
 					}
@@ -469,7 +472,7 @@
 			if (this.annotationsOnDimensions != null) {
 				for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
 					Annotation[] annotations2 = this.annotationsOnDimensions[i];
-					for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+					for (int j = 0, max2 = annotations2 == null ? 0 : annotations2.length; j < max2; j++) {
 						Annotation annotation = annotations2[j];
 						annotation.traverse(visitor, scope);
 					}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
index ad7f074..e5df357 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
@@ -570,11 +570,9 @@
 	public void traverse(ASTVisitor visitor, BlockScope scope) {
 		if (visitor.visit(this, scope)) {
 			if (this.annotations != null) {
-				int annotationsLevels = this.annotations.length;
-				for (int i = 0; i < annotationsLevels; i++) {
-					int annotationsLength = this.annotations[i] == null ? 0 : this.annotations[i].length;
-					for (int j = 0; j < annotationsLength; j++)
-						this.annotations[i][j].traverse(visitor, scope);
+				Annotation [] typeAnnotations = this.annotations[0];
+				for (int i = 0, length = typeAnnotations == null ? 0 : typeAnnotations.length; i < length; i++) {
+					typeAnnotations[i].traverse(visitor, scope);
 				}
 			}
 			if (this.annotationsOnDimensions != null) {
@@ -598,11 +596,9 @@
 	public void traverse(ASTVisitor visitor, ClassScope scope) {
 		if (visitor.visit(this, scope)) {
 			if (this.annotations != null) {
-				int annotationsLevels = this.annotations.length;
-				for (int i = 0; i < annotationsLevels; i++) {
-					int annotationsLength = this.annotations[i] == null ? 0 : this.annotations[i].length;
-					for (int j = 0; j < annotationsLength; j++)
-						this.annotations[i][j].traverse(visitor, scope);
+				Annotation [] typeAnnotations = this.annotations[0];
+				for (int i = 0, length = typeAnnotations == null ? 0 : typeAnnotations.length; i < length; i++) {
+					typeAnnotations[i].traverse(visitor, scope);
 				}
 			}
 			if (this.annotationsOnDimensions != null) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
index 19fb508..a49e5c1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
@@ -135,6 +135,40 @@
 	public char[] getLastToken() {
 		return this.tokens[this.tokens.length-1];
 	}
+
+	protected void rejectAnnotationsOnPackageQualifiers(Scope scope, PackageBinding packageBinding) {
+		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=390882
+		if (packageBinding == null || this.annotations == null) return;
+
+		int i = packageBinding.compoundName.length;
+		for (int j = i; j > 0; j--) {
+			Annotation[] qualifierAnnot = this.annotations[j];
+			if (qualifierAnnot != null && qualifierAnnot.length > 0) {
+				scope.problemReporter().misplacedTypeAnnotations(qualifierAnnot[0], qualifierAnnot[qualifierAnnot.length - 1]);
+				this.annotations[j] = null;
+			}
+		}
+	}
+
+	protected void rejectAnnotationsOnStaticMemberQualififer(Scope scope, ReferenceBinding currentType, PackageBinding packageBinding, int tokenIndex) {
+		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=385137
+		if (this.annotations != null && currentType.isMemberType() && currentType.isStatic()) {
+			Annotation[] qualifierAnnot = this.annotations[tokenIndex - 1];
+			if (qualifierAnnot != null) {
+				scope.problemReporter().illegalTypeAnnotationsInStaticMemberAccess(qualifierAnnot[0],
+						qualifierAnnot[qualifierAnnot.length - 1]);
+			}
+			// For the case: @Marker p.X.StaticNestedType, where 'p' is a package and 'X' is a class
+			if (packageBinding != null && packageBinding.compoundName.length == (tokenIndex - 1)) {
+				qualifierAnnot = this.annotations[0];
+				if (qualifierAnnot != null) {
+					scope.problemReporter().illegalTypeAnnotationsInStaticMemberAccess(qualifierAnnot[0],
+							qualifierAnnot[qualifierAnnot.length - 1]);
+				}
+			}
+		}
+	}
+
 	protected TypeBinding getTypeBinding(Scope scope) {
 
 		if (this.resolvedType != null) {
@@ -169,6 +203,8 @@
 			return (ReferenceBinding) binding; // not found
 		}
 	    PackageBinding packageBinding = binding == null ? null : (PackageBinding) binding;
+	    rejectAnnotationsOnPackageQualifiers(scope, packageBinding);
+
 	    boolean isClassScope = scope.kind == Scope.CLASS_SCOPE;
 	    ReferenceBinding qualifiedType = null;
 		for (int i = packageBinding == null ? 0 : packageBinding.compoundName.length, max = this.tokens.length, last = max-1; i < max; i++) {
@@ -198,6 +234,7 @@
 					return null;
 			ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
 			if (qualifiedType != null) {
+				rejectAnnotationsOnStaticMemberQualififer(scope, currentType, packageBinding, i);
 				ReferenceBinding enclosingType = currentType.enclosingType();
 				if (enclosingType != null && enclosingType.erasure() != qualifiedType.erasure()) {
 					qualifiedType = enclosingType; // inherited member type, leave it associated with its enclosing rather than subtype
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java
index 809c51e..8125e20 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java
@@ -153,12 +153,9 @@
 	public void traverse(ASTVisitor visitor, BlockScope scope) {
 		if (visitor.visit(this, scope)) {
 			if (this.annotations != null) {
-				int annotationsLevels = this.annotations.length;
-				for (int i = 0; i < annotationsLevels; i++) {
-					int annotationsLength = this.annotations[i] == null ? 0 : this.annotations[i].length;
-					for (int j = 0; j < annotationsLength; j++)
-						this.annotations[i][j].traverse(visitor, scope);
-				}
+				Annotation [] typeAnnotations = this.annotations[0];
+				for (int i = 0, length = typeAnnotations == null ? 0 : typeAnnotations.length; i < length; i++)
+					typeAnnotations[i].traverse(visitor, scope);
 			}
 		}
 		visitor.endVisit(this, scope);
@@ -167,12 +164,9 @@
 	public void traverse(ASTVisitor visitor, ClassScope scope) {
 		if (visitor.visit(this, scope)) {
 			if (this.annotations != null) {
-				int annotationsLevels = this.annotations.length;
-				for (int i = 0; i < annotationsLevels; i++) {
-					int annotationsLength = this.annotations[i] == null ? 0 : this.annotations[i].length;
-					for (int j = 0; j < annotationsLength; j++)
-						this.annotations[i][j].traverse(visitor, scope);
-				}
+				Annotation [] typeAnnotations = this.annotations[0];
+				for (int i = 0, length = typeAnnotations == null ? 0 : typeAnnotations.length; i < length; i++)
+					typeAnnotations[i].traverse(visitor, scope);
 			}
 		}
 		visitor.endVisit(this, scope);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
index 04328fd..ef2f428 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
@@ -383,6 +383,10 @@
 	return null;
 }
 
+public void setAnnotationsOnDimensions(Annotation [][] annotationsOnDimensions) {
+	// nothing to do. Subtypes should react suitably.
+}
+
 public abstract char[] getLastToken();
 
 /**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnionTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnionTypeReference.java
index bbf7806..9a4e07c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnionTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnionTypeReference.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -37,7 +37,7 @@
 	 * @see org.eclipse.jdt.internal.compiler.ast.TypeReference#copyDims(int)
 	 */
 	public TypeReference copyDims(int dim) {
-		return this;
+		return this; // arrays are not legal as union types.
 	}
 
 	/* (non-Javadoc)
@@ -161,8 +161,7 @@
 	}
 
 	public TypeReference copyDims(int dim, Annotation[][] annotationsOnDimensions) {
-		// TODO Auto-generated method stub
-		return null;
+		return this; // arrays are not legal as union types.
 	}
 
 }
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Wildcard.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Wildcard.java
index 8f4db26..96fa34a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Wildcard.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Wildcard.java
@@ -59,6 +59,7 @@
 
 	private TypeBinding internalResolveType(Scope scope, ReferenceBinding genericType, int rank) {
 		TypeBinding boundType = null;
+		resolveAnnotations(scope);
 		if (this.bound != null) {
 			boundType = scope.kind == Scope.CLASS_SCOPE
 					? this.bound.resolveType((ClassScope)scope)
@@ -72,7 +73,23 @@
 		return this.resolvedType = wildcard;
 	}
 
+	
+	private void resolveAnnotations(Scope scope) {
+		switch (scope.kind) {
+			case Scope.METHOD_SCOPE:
+			case Scope.BLOCK_SCOPE:
+				if (this.annotations != null)
+					resolveAnnotations((BlockScope) scope, this.annotations[0], new Annotation.TypeUseBinding(Binding.TYPE_USE));
+				break;
+			default: 
+				break;
+		}
+	}
 	public StringBuffer printExpression(int indent, StringBuffer output){
+		if (this.annotations != null && this.annotations[0] != null) {
+			printAnnotations(this.annotations[0], output);
+			output.append(' ');
+		}
 		switch (this.kind) {
 			case Wildcard.UNBOUND :
 				output.append(WILDCARD_NAME);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java
index ec3ded4..b91eac1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java
@@ -668,7 +668,8 @@
 			findEquivalent: for (int j=0; j<length; j++) {
 				if (j == i) continue findEquivalent;
 				if (isMethodSubsignature(methods[i], methods[j])) {
-					problemReporter().inheritedDefaultMethodConflictsWithOtherInherited(this.type, methods[i], methods[j]);
+					if (!doesMethodOverride(methods[i], methods[j]) && !doesMethodOverride(methods[j], methods[i])) 
+						problemReporter().inheritedDefaultMethodConflictsWithOtherInherited(this.type, methods[i], methods[j]);
 					continue findDefaultMethod;
 				}
 			}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java
index a795f04..6ee4085 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java
@@ -17,7 +17,9 @@
 public interface ConflictedParser {
 	
 	/* Return true if at the configuration the parser finds itself in, token would need to be disambiguated.
-	   At Java SE 8 time, we have two tokens that need to clarified: the use of '( and that of '<'
+	   At Java SE 8 time, we have three tokens that need to clarified: the use of '( and that of '<' and finally
+	   whether an @ begins a SE8 style type annotation or a SE5 declaration annotation. Where they can co-exist,
+	   we treat the type annotation as a declarative annotation.
 	*/
 	boolean atConflictScenario(int token);
 }
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index ee9bc7f..c02e226 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -102,9 +102,6 @@
 	//expression stack
 	protected final static int ExpressionStackIncrement = 100;
 
-	// annotation stack
-	protected final static int TypeAnnotationStackIncrement = 100;
-	
 	protected final static int GenericsStackIncrement = 10;
 
 	private final static String FILEPREFIX = "parser"; //$NON-NLS-1$
@@ -855,7 +852,6 @@
 	protected int[] expressionLengthStack;
 	protected int expressionPtr;
 	protected Expression[] expressionStack = new Expression[ExpressionStackIncrement];
-	protected int unattachedAnnotationPtr;  // used for figuring out whether some set of annotations are annotating a dimension or not.
 	public int firstToken ; // handle for multiple parsing goals
 	
 	/* jsr308 -- Type annotation management, we now maintain type annotations in a separate stack
@@ -863,17 +859,17 @@
 	   to handle such interleaving and will look ugly if changed. 
 	   
 	   See consumeArrayCreationExpressionWithoutInitializer for example. 
-	   
-	   See that annotations gets pushed into expression stack the moment an annotation is discovered and
-	   get moved to the new type annotations stack only later when the annotation is recognized to be a
-	   type annotation. Where ambiguities exist (i.e 1.7 annotation occurs in a place sanctioned for an
-	   1.5 type annotation, the annotation continues to stay in the expression stack, but in these case
-	   interleaving is not an issue.
+
+	   Where SE8 annotations occur in a place SE5 annotations are legal, the SE8 annotations end up in
+	   the expression stack as we have no way of distinguishing between the two.
 	*/  
 	protected int typeAnnotationPtr;
 	protected int typeAnnotationLengthPtr;
 	protected Annotation [] typeAnnotationStack = new Annotation[TypeAnnotationStackIncrement];
 	protected int [] typeAnnotationLengthStack;
+	// annotation stack
+	protected final static int TypeAnnotationStackIncrement = 100;
+	
 	// generics management
 	protected int genericsIdentifiersLengthPtr;
 	protected int[] genericsIdentifiersLengthStack = new int[GenericsStackIncrement];
@@ -959,7 +955,7 @@
 private int valueLambdaNestDepth = -1;
 private int stateStackLengthStack[] = new int[0];
 private boolean parsingJava8Plus;
-private int unstackedAct = ERROR_ACTION;
+protected int unstackedAct = ERROR_ACTION;
 
 
 //{ObjectTeams: context info while parsing separate role files:
@@ -968,7 +964,9 @@
 	public TypeDeclaration currentTeam = null;
 // SH}
 
-
+protected Parser () {
+	// Caveat Emptor: For inheritance purposes and then only in very special needs. Only minimal state is initialized !
+}
 public Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals) {
 
 	this.problemReporter = problemReporter;
@@ -1335,8 +1333,7 @@
 		}
 	}
 }
-protected ParameterizedQualifiedTypeReference computeQualifiedGenericsFromRightSide(TypeReference rightSide, int dim) {
-	Annotation [][] annotationsOnDimensions = dim == 0 ? null : getAnnotationsOnDimensions(dim);
+protected ParameterizedQualifiedTypeReference computeQualifiedGenericsFromRightSide(TypeReference rightSide, int dim, Annotation [][] annotationsOnDimensions) {
 	int nameSize = this.identifierLengthStack[this.identifierLengthPtr];
 	int tokensSize = nameSize;
 	if (rightSide instanceof ParameterizedSingleTypeReference) {
@@ -1351,15 +1348,24 @@
 	TypeReference[][] typeArguments = new TypeReference[tokensSize][];
 	char[][] tokens = new char[tokensSize][];
 	long[] positions = new long[tokensSize];
+	Annotation [][] typeAnnotations = null;
 	if (rightSide instanceof ParameterizedSingleTypeReference) {
 		ParameterizedSingleTypeReference singleParameterizedTypeReference = (ParameterizedSingleTypeReference) rightSide;
 		tokens[nameSize] = singleParameterizedTypeReference.token;
 		positions[nameSize] = (((long) singleParameterizedTypeReference.sourceStart) << 32) + singleParameterizedTypeReference.sourceEnd;
 		typeArguments[nameSize] = singleParameterizedTypeReference.typeArguments;
+		if (singleParameterizedTypeReference.annotations != null) {
+			typeAnnotations = new Annotation[tokensSize][];
+		    typeAnnotations[nameSize] = singleParameterizedTypeReference.annotations[0];
+		}
 	} else if (rightSide instanceof SingleTypeReference) {
 		SingleTypeReference singleTypeReference = (SingleTypeReference) rightSide;
 		tokens[nameSize] = singleTypeReference.token;
 		positions[nameSize] = (((long) singleTypeReference.sourceStart) << 32) + singleTypeReference.sourceEnd;
+		if (singleTypeReference.annotations != null) {
+			typeAnnotations = new Annotation[tokensSize][];
+			typeAnnotations[nameSize] =  singleTypeReference.annotations[0];
+		}
 	} else if (rightSide instanceof ParameterizedQualifiedTypeReference) {
 		ParameterizedQualifiedTypeReference parameterizedTypeReference = (ParameterizedQualifiedTypeReference) rightSide;
 		TypeReference[][] rightSideTypeArguments = parameterizedTypeReference.typeArguments;
@@ -1368,12 +1374,22 @@
 		System.arraycopy(rightSideTokens, 0, tokens, nameSize, rightSideTokens.length);
 		long[] rightSidePositions = parameterizedTypeReference.sourcePositions;
 		System.arraycopy(rightSidePositions, 0, positions, nameSize, rightSidePositions.length);
+		Annotation [][] rightSideAnnotations = parameterizedTypeReference.annotations;
+		if (rightSideAnnotations != null) {
+			typeAnnotations = new Annotation[tokensSize][];
+			System.arraycopy(rightSideAnnotations, 0, typeAnnotations, nameSize, rightSideAnnotations.length);
+		}
 	} else if (rightSide instanceof QualifiedTypeReference) {
 		QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) rightSide;
 		char[][] rightSideTokens = qualifiedTypeReference.tokens;
 		System.arraycopy(rightSideTokens, 0, tokens, nameSize, rightSideTokens.length);
 		long[] rightSidePositions = qualifiedTypeReference.sourcePositions;
 		System.arraycopy(rightSidePositions, 0, positions, nameSize, rightSidePositions.length);
+		Annotation [][] rightSideAnnotations = qualifiedTypeReference.annotations;
+		if (rightSideAnnotations != null) {
+			typeAnnotations = new Annotation[tokensSize][];
+			System.arraycopy(rightSideAnnotations, 0, typeAnnotations, nameSize, rightSideAnnotations.length);
+		}
 	}
 
 	int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--];
@@ -1393,16 +1409,26 @@
 	}
 	this.identifierLengthPtr--;
 	ParameterizedQualifiedTypeReference typeRef = new ParameterizedQualifiedTypeReference(tokens, typeArguments, dim, annotationsOnDimensions, positions);
-	int length;
-	if (this.typeAnnotationLengthPtr >= 0 && (length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
-		typeRef.annotations = new Annotation[tokensSize][];
-		System.arraycopy(
-			this.typeAnnotationStack,
-			(this.typeAnnotationPtr -= length) + 1,
-			typeRef.annotations[0] = new Annotation[length],
-			0,
-			length);
-		typeRef.sourceStart = typeRef.annotations[0][0].sourceStart;
+
+	while (nameSize > 0) {
+		int length;
+		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
+			if (typeAnnotations == null)
+				typeAnnotations = new Annotation[tokensSize][];
+			System.arraycopy(
+					this.typeAnnotationStack,
+					(this.typeAnnotationPtr -= length) + 1,
+					typeAnnotations[nameSize - 1] = new Annotation[length],
+					0,
+					length);
+			if (nameSize == 1) {
+				typeRef.sourceStart = typeAnnotations[0][0].sourceStart;
+			}
+		}
+		nameSize--;
+	}
+	
+	if ((typeRef.annotations = typeAnnotations) != null) {
 		typeRef.bits |= ASTNode.HasTypeAnnotations;
 	}
 	return typeRef;
@@ -2915,45 +2941,6 @@
 	updateSourcePosition(cast);
 	cast.sourceEnd=exp.sourceEnd;
 }
-protected void consumeCastExpressionLL1WithTypeAnnotations() {
-	// CastExpression ::= '(' Modifiers Name ')' InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
-	// Expression is used in order to make the grammar LL1
-
-	//optimize push/pop
-
-	// pop the expression
-	Expression expression = this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	// pop the type reference
-	TypeReference typeReference = (TypeReference) this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.sourceStart = typeReferenceSourceStart;
-		typeReference.bits |= ASTNode.HasTypeAnnotations;
-	}
-	Expression cast;
-	pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
-	// pop the two positions for left and right parenthesis 
-	updateSourcePosition(cast);
-	cast.sourceEnd = expression.sourceEnd;
-	if (this.modifiers != ClassFileConstants.AccDefault) {
-		problemReporter().invalidLocationForModifiers(typeReference);
-	}
-	resetModifiers();
-}
 protected void consumeCastExpressionWithGenericsArray() {
 	// CastExpression ::= PushLPAREN Name TypeArguments Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
 
@@ -2971,45 +2958,6 @@
 	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
 	cast.sourceEnd = exp.sourceEnd;
 }
-protected void consumeCastExpressionWithGenericsArrayWithTypeAnnotations() {
-	// CastExpression ::= PushLPAREN Modifiers Name OnlyTypeArgumentsForCastExpression Dimsopt PushRPARENForAnnotatedTypeCast InsideCastExpression UnaryExpressionNotPlusMinus
-	int end = this.intStack[this.intPtr--];
-	int dim = this.intStack[this.intPtr--];
-
-	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
-	TypeReference typeReference = getTypeReference(dim);
-	
-	// pop expression
-	Expression expression = this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.bits |= ASTNode.HasTypeAnnotations;
-		typeReference.sourceStart = typeReferenceSourceStart;
-	}
-	Expression cast;
-	pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
-	this.intPtr--;
-	typeReference.sourceEnd = end - 1;
-	typeReference.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
-	cast.sourceEnd = expression.sourceEnd;
-	if (this.modifiers != ClassFileConstants.AccDefault) {
-		problemReporter().invalidLocationForModifiers(typeReference);
-	}
-	resetModifiers();
-}
 protected void consumeCastExpressionWithNameArray() {
 	// CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
 
@@ -3027,46 +2975,6 @@
 	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
 	cast.sourceEnd = exp.sourceEnd;
 }
-protected void consumeCastExpressionWithNameArrayWithTypeAnnotations() {
-	// CastExpression ::= PushLPAREN Modifiers Name Dims PushRPARENForAnnotatedTypeCast InsideCastExpression UnaryExpressionNotPlusMinus
-
-	int end = this.intStack[this.intPtr--];
-
-	// handle type arguments
-	pushOnGenericsLengthStack(0);
-	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
-
-	// pop expression
-	Expression expression = this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	TypeReference typeReference = getTypeReference(this.intStack[this.intPtr--]);
-
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.bits |= ASTNode.HasTypeAnnotations;
-		typeReference.sourceStart = typeReferenceSourceStart;
-	}
-	Expression cast;
-	pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
-	typeReference.sourceEnd = end - 1;
-	typeReference.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
-	cast.sourceEnd = expression.sourceEnd;
-	if (this.modifiers != ClassFileConstants.AccDefault) {
-		problemReporter().invalidLocationForModifiers(typeReference);
-	}
-	resetModifiers();
-}
 protected void consumeCastExpressionWithPrimitiveType() {
 	// CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression UnaryExpression
 
@@ -3083,45 +2991,6 @@
 	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
 	cast.sourceEnd = exp.sourceEnd;
 }
-protected void consumeCastExpressionWithPrimitiveTypeWithTypeAnnotations() {
-	// CastExpression ::= PushLPAREN Modifiers PrimitiveType Dimsopt PushRPARENForAnnotatedTypeCast InsideCastExpression UnaryExpression
-
-	//this.intStack : posOfLeftParen dim posOfRightParen
-	int end = this.intStack[this.intPtr--];
-
-	// pop expression
-	Expression expression = this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-
-	TypeReference typeReference = getTypeReference(this.intStack[this.intPtr--]);
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.bits |= ASTNode.HasTypeAnnotations;
-		typeReference.sourceStart = typeReferenceSourceStart;
-	}
-	
-	Expression cast;
-	pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
-	
-	typeReference.sourceEnd = end - 1;
-	typeReference.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
-	cast.sourceEnd = expression.sourceEnd;
-	if (this.modifiers != ClassFileConstants.AccDefault) {
-		problemReporter().invalidLocationForModifiers(typeReference);
-	}
-	resetModifiers();
-}
 protected void consumeCastExpressionWithQualifiedGenericsArray() {
 	// CastExpression ::= PushLPAREN Name OnlyTypeArguments '.' ClassOrInterfaceType Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
 	Expression exp;
@@ -3130,54 +2999,15 @@
 	int end = this.intStack[this.intPtr--];
 
 	int dim = this.intStack[this.intPtr--];
-	TypeReference rightSide = getUnannotatedTypeReference(0); // by design the type after . is not annotated.
-
-	ParameterizedQualifiedTypeReference qualifiedParameterizedTypeReference = computeQualifiedGenericsFromRightSide(rightSide, dim);
+	Annotation [][] annotationsOnDimensions = dim == 0 ? null : getAnnotationsOnDimensions(dim);
+	TypeReference rightSide = getTypeReference(0);
+    ParameterizedQualifiedTypeReference qualifiedParameterizedTypeReference = computeQualifiedGenericsFromRightSide(rightSide, dim, annotationsOnDimensions);
 	this.intPtr--;
 	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = qualifiedParameterizedTypeReference);
 	castType.sourceEnd = end - 1;
 	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
 	cast.sourceEnd = exp.sourceEnd;
 }
-protected void consumeCastExpressionWithQualifiedGenericsArrayWithTypeAnnotations() {
-	// CastExpression ::= PushLPAREN Name OnlyTypeArguments '.' ClassOrInterfaceType Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
-	int end = this.intStack[this.intPtr--];
-
-	int dim = this.intStack[this.intPtr--];
-	// pop expression
-	Expression expression = this.expressionStack[this.expressionPtr--];
-	this.expressionLengthPtr--;
-	
-	TypeReference rightSide = getUnannotatedTypeReference(0); // by design the type after . is not annotated.
-
-	ParameterizedQualifiedTypeReference typeReference = computeQualifiedGenericsFromRightSide(rightSide, dim);
-	this.intPtr--;
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.bits |= ASTNode.HasTypeAnnotations;
-		typeReference.sourceStart = typeReferenceSourceStart;
-	}
-	Expression cast;
-	pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
-	typeReference.sourceEnd = end - 1;
-	typeReference.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
-	cast.sourceEnd = expression.sourceEnd;
-	if (this.modifiers != ClassFileConstants.AccDefault) {
-		problemReporter().invalidLocationForModifiers(typeReference);
-	}
-	resetModifiers();
-}
 protected void consumeCatches() {
 	// Catches ::= Catches CatchClause
 	optimizedConcatNodeLists();
@@ -3622,6 +3452,7 @@
 				length);
 		}
 		alloc.type = getTypeReference(0);
+		rejectIllegalLeadingTypeAnnotations(alloc.type);
 		checkForDiamond(alloc.type);
 		length = this.genericsLengthStack[this.genericsLengthPtr--];
 		this.genericsPtr -= length;
@@ -3653,6 +3484,7 @@
 			allocationExpression.sourceStart = this.intStack[this.intPtr--];
 			checkForDiamond(allocationExpression.type);
 		}
+		rejectIllegalLeadingTypeAnnotations(allocationExpression.type);
 	}
 	
 	QualifiedAllocationExpression qae =
@@ -3687,6 +3519,7 @@
 				length);
 		}
 		alloc.type = getTypeReference(0);
+		rejectIllegalLeadingTypeAnnotations(alloc.type);
 		checkForDiamond(alloc.type);
 
 		length = this.genericsLengthStack[this.genericsLengthPtr--];
@@ -3719,6 +3552,7 @@
 			allocationExpression.sourceStart = this.intStack[this.intPtr--];
 			checkForDiamond(allocationExpression.type);
 		}
+		rejectIllegalLeadingTypeAnnotations(allocationExpression.type);
 	}
 }
 protected void consumeClassOrInterface() {
@@ -4047,8 +3881,8 @@
 	this.dimensions = 0;
 }
 protected void consumeDimWithOrWithOutExpr() {
-	// DimWithOrWithOutExpr ::= '[' ']'
-	// DimWithOrWithOutExpr ::= OneOrMoreAnnotations '[' ']' 
+	// DimWithOrWithOutExpr ::= TypeAnnotationsopt '[' ']'
+	// DimWithOrWithOutExpr ::= TypeAnnotationsopt '[' Expression ']'
 	pushOnExpressionStack(null);
 
 	if(this.currentElement != null && this.currentToken == TokenNameLBRACE) {
@@ -4486,18 +4320,15 @@
 		return null;
 
 	Annotation [][] mergedAnnotations = new Annotation[dims + extendedDims][];
-	for (int i = 0; i < dims; i++) {
-		if (annotationsOnDimensions != null) {
+	
+	if (annotationsOnDimensions != null) {
+		for (int i = 0; i < dims; i++) {
 			mergedAnnotations[i] = annotationsOnDimensions[i];
-		} else {
-			mergedAnnotations[i] = null;
-		}
+		} 
 	}
-	for (int i = dims, j = 0; i < dims + extendedDims; i++, j++) {
-		if (annotationsOnExtendedDimensions != null) {
+	if (annotationsOnExtendedDimensions != null) {
+		for (int i = dims, j = 0; i < dims + extendedDims; i++, j++) {
 			mergedAnnotations[i] = annotationsOnExtendedDimensions[j];
-		} else {
-			mergedAnnotations[i] = null;
 		}
 	}
 
@@ -5195,8 +5026,9 @@
 	pushOnAstLengthStack(-1);
 }
 protected void consumeFormalParameter(boolean isVarArgs) {
-	// FormalParameter ::= Type VariableDeclaratorId ==> false
-	// FormalParameter ::= Modifiers Type VariableDeclaratorId ==> true
+	// FormalParameter ::= Modifiersopt Type VariableDeclaratorIdOrThis
+	// FormalParameter ::= Modifiersopt Type PushZeroTypeAnnotations '...' VariableDeclaratorIdOrThis
+	// FormalParameter ::= Modifiersopt Type @308... TypeAnnotations '...' VariableDeclaratorIdOrThis
 	/*
 	this.astStack :
 	this.identifierStack : type identifier
@@ -5216,9 +5048,20 @@
 	char[] identifierName = this.identifierStack[this.identifierPtr];
 	long namePositions = this.identifierPositionStack[this.identifierPtr--];
 	int extendedDimensions = this.intStack[this.intPtr--];
+	Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : getAnnotationsOnDimensions(extendedDimensions);
+	Annotation [] varArgsAnnotations = null;
 	int endOfEllipsis = 0;
+	int length;
 	if (isVarArgs) {
 		endOfEllipsis = this.intStack[this.intPtr--];
+		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
+			System.arraycopy(
+				this.typeAnnotationStack,
+				(this.typeAnnotationPtr -= length) + 1,
+				varArgsAnnotations = new Annotation[length],
+				0,
+				length);
+		} 
 	}
 //{ObjectTeams: LiftingTypeReference?
 	// Inserted via LiftingTypeopt, e.g.,:
@@ -5241,33 +5084,24 @@
 	// next is base side:
 // SH}
 	int firstDimensions = this.intStack[this.intPtr--];
-	TypeReference type = getUnannotatedTypeReference(extendedDimensions);
-//{ObjectTeams: LiftingTypeReference? Compose:
+	TypeReference type = getTypeReference(firstDimensions);
+//{ObjectTeams: LiftingTypeReference? Compose:  FIXME?!? jdt moved some to getTypeReference?
 	if (ltr != null) {
 		ltr.setReferences(type, roleRef);
 		type = ltr;
 	}
 // SH}
-	Annotation [] varArgsAnnotations = null;
-	int length;
-	if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
-		System.arraycopy(
-			this.typeAnnotationStack,
-			(this.typeAnnotationPtr -= length) + 1,
-			varArgsAnnotations = new Annotation[length],
-			0,
-			length);
-	} 
 	final int typeDimensions = firstDimensions + extendedDimensions + (isVarArgs ? 1 : 0);
 
-	if (typeDimensions != extendedDimensions) {
+	if (typeDimensions != firstDimensions) {
 		// jsr308 type annotations management
-		Annotation [][] annotationsOnFirstDimensions = firstDimensions == 0 ? null : getAnnotationsOnDimensions(firstDimensions);
-		Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : type.getAnnotationsOnDimensions();
-		Annotation [][] annotationsOnAllDimensions = null;
-		if (annotationsOnFirstDimensions != null || annotationsOnExtendedDimensions != null || varArgsAnnotations != null) {
-			annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions, annotationsOnFirstDimensions, extendedDimensions, annotationsOnExtendedDimensions); 
-			annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions + extendedDimensions, annotationsOnAllDimensions, isVarArgs ? 1 : 0, isVarArgs ? new Annotation[][]{varArgsAnnotations} : null);
+		Annotation [][] annotationsOnFirstDimensions = firstDimensions == 0 ? null : type.getAnnotationsOnDimensions();
+		Annotation [][] annotationsOnAllDimensions = annotationsOnFirstDimensions;
+		if (annotationsOnExtendedDimensions != null) {
+			annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions, annotationsOnFirstDimensions, extendedDimensions, annotationsOnExtendedDimensions);
+		}
+		if (varArgsAnnotations != null) {
+			annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions + extendedDimensions, annotationsOnAllDimensions, 1, new Annotation[][]{varArgsAnnotations});
 		}
 		type = copyDims(type, typeDimensions, annotationsOnAllDimensions);
 		type.sourceEnd = type.isParameterizedTypeReference() ? this.endStatementPosition : this.endPosition;
@@ -5325,14 +5159,6 @@
 				extendedDimensions > 0) {
 			problemReporter().illegalExtendedDimensions(arg);
 		}
-	} else {
-		// The grammar allows trailing annotations in FormalParameter as in 
-		// "int @NonNull[] @Misplaced parameter" in order to allow for constructs such as
-		// "Object @NonNull[] @Correct ... objects" -- we prune these here.
-		if (varArgsAnnotations != null) {
-			problemReporter().misplacedTypeAnnotations(varArgsAnnotations[0],
-					varArgsAnnotations[varArgsAnnotations.length-1]);
-		}
 	}
 }
 protected Annotation[][] getAnnotationsOnDimensions(int dimensionsCount) {
@@ -5418,9 +5244,6 @@
 protected void consumeInsideCastExpressionWithQualifiedGenerics() {
 	// InsideCastExpressionWithQualifiedGenerics ::= $empty
 }
-protected void consumeInsideCastExpressionWithAnnotatedQualifiedGenerics() {
-	// InsideCastExpressionWithAnnotatedQualifiedGenerics ::= $empty
-}
 protected void consumeInstanceOfExpression() {
 	// RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
 	//optimize the push/pop
@@ -5853,8 +5676,9 @@
 	}
 
 }
-protected void consumeMarkerAnnotation() {
-	// MarkerAnnotation ::= '@' Name
+protected void consumeMarkerAnnotation(boolean isTypeAnnotation) {
+	// MarkerAnnotation ::= AnnotationName
+	// MarkerTypeAnnotation ::= TypeAnnotationName
 	MarkerAnnotation markerAnnotation = null;
 
 	int oldIndex = this.identifierPtr;
@@ -5862,7 +5686,11 @@
 	TypeReference typeReference = getAnnotationType();
 	markerAnnotation = new MarkerAnnotation(typeReference, this.intStack[this.intPtr--]);
 	markerAnnotation.declarationSourceEnd = markerAnnotation.sourceEnd;
-	pushOnExpressionStack(markerAnnotation);
+	if (isTypeAnnotation) {
+		pushOnTypeAnnotationStack(markerAnnotation);
+	} else {
+		pushOnExpressionStack(markerAnnotation);
+	}
 	if(!this.statementRecoveryActivated &&
 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
@@ -6146,6 +5974,7 @@
 	this.identifierLengthPtr--;
 	//type
 	TypeReference returnType = getTypeReference(this.intStack[this.intPtr--]);
+	rejectIllegalLeadingTypeAnnotations(returnType);
 	md.returnType = returnType;
 	md.bits |= (returnType.bits & ASTNode.HasTypeAnnotations);
 
@@ -6329,6 +6158,17 @@
 		this.identifierLengthPtr--;
 	} else {
 		this.identifierLengthStack[this.identifierLengthPtr]--;
+		int length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--];
+		Annotation [] typeAnnotations;
+		if (length != 0) {
+			System.arraycopy(
+					this.typeAnnotationStack,
+					(this.typeAnnotationPtr -= length) + 1,
+					typeAnnotations = new Annotation[length],
+					0,
+					length);
+			problemReporter().misplacedTypeAnnotations(typeAnnotations[0], typeAnnotations[typeAnnotations.length - 1]);
+		}
 		m.receiver = getUnspecifiedReference();
 		m.sourceStart = m.receiver.sourceStart;
 	}
@@ -6665,26 +6505,21 @@
 	// Resources ::= Resources ';' Resource
 	concatNodeLists();
 }
-protected void consumeOneMoreTypeAnnotation() {
-	// OneOrMoreAnnotations ::= OneOrMoreAnnotations Annotation
-	this.expressionLengthPtr --;
-	Annotation annotation = (Annotation) this.expressionStack[this.expressionPtr--];
-	pushOnTypeAnnotationStack(annotation);
-	this.typeAnnotationLengthStack[--this.typeAnnotationLengthPtr]++;
-	if(!this.statementRecoveryActivated &&
-			this.options.sourceLevel <= ClassFileConstants.JDK1_7 &&
+protected void consumeTypeAnnotation() {
+	// TypeAnnotation ::= NormalTypeAnnotation
+	// TypeAnnotation ::= MarkerTypeAnnotation
+	// TypeAnnotation ::= SingleMemberTypeAnnotation
+	
+	if (!this.statementRecoveryActivated &&
+			this.options.sourceLevel < ClassFileConstants.JDK1_8 &&
 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
+		Annotation annotation = this.typeAnnotationStack[this.typeAnnotationPtr];
 		problemReporter().invalidUsageOfTypeAnnotations(annotation);
 	}
 }
-protected void consumePotentialNameArrayType () {
-	
-	// FormalParameter ::= Modifiersopt Name DimsoptAnnotsopt PotentialNameArray VariableDeclaratorId
-	// FormalParameter ::= Modifiersopt Name DimsoptAnnotsopt PotentialNameArray '...' VariableDeclaratorId
-	// PotentialNameArray -> $empty
-	// Dimensions including lack of have been pushed appropriately by action attached to DimsoptAnnotsopt
-	pushOnGenericsLengthStack(0); // handle type arguments
-	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
+protected void consumeOneMoreTypeAnnotation() {
+	// TypeAnnotations ::= TypeAnnotations TypeAnnotation
+	this.typeAnnotationLengthStack[--this.typeAnnotationLengthPtr]++;
 }
 protected void consumeNameArrayType() {
 	pushOnGenericsLengthStack(0); // handle type arguments
@@ -6714,8 +6549,9 @@
 	this.nestedMethod[this.nestedType] = 0;
 	this.variablesCounter[this.nestedType] = 0;
 }
-protected void consumeNormalAnnotation() {
-	// NormalAnnotation ::= '@' Name '(' MemberValuePairsopt ')'
+protected void consumeNormalAnnotation(boolean isTypeAnnotation) {
+	// NormalTypeAnnotation ::= TypeAnnotationName '(' MemberValuePairsopt ')'
+	// NormalAnnotation ::= AnnotationName '(' MemberValuePairsopt ')'
 	NormalAnnotation normalAnnotation = null;
 
 	int oldIndex = this.identifierPtr;
@@ -6732,7 +6568,12 @@
 			length);
 	}
 	normalAnnotation.declarationSourceEnd = this.rParenPos;
-	pushOnExpressionStack(normalAnnotation);
+	
+	if (isTypeAnnotation) {
+		pushOnTypeAnnotationStack(normalAnnotation);
+	} else {
+		pushOnExpressionStack(normalAnnotation);
+	}
 
 	if(this.currentElement != null) {
 		annotationRecoveryCheckPoint(normalAnnotation.sourceStart, normalAnnotation.declarationSourceEnd);
@@ -6749,22 +6590,14 @@
 	}
 	this.recordStringLiterals = true;
 }
-protected void consumeOneDimLoop(boolean expressionStackMayHaveAnnotations) {
+protected void consumeOneDimLoop(boolean isAnnotated) {
 	// OneDimLoop ::= '[' ']'
-	// OneDimOrAnnot -> '[' ']'
+	// OneDimLoop ::= TypeAnnotations '[' ']'
 	this.dimensions++;
-	if (!expressionStackMayHaveAnnotations || this.unattachedAnnotationPtr == -1 ) {
-		pushOnTypeAnnotationLengthStack(0); // no annotations for the current dimension.
-	} else { 
-		this.unattachedAnnotationPtr = -1;	// Leave type annotation stacks they are. 
+	if (!isAnnotated) {
+		pushOnTypeAnnotationLengthStack(0); // signal no annotations for the current dimension.
 	}
 }
-protected void consumeOneDimLoopWithAnnotations() {
-	// OneDimLoop ::= OneOrMoreAnnotations '[' ']'
-	this.dimensions++;
-	// Top of expression stack contains annotations of length specified
-	// by top of expression length stack that apply to this dimension.
-}
 protected void consumeOnlySynchronized() {
 	// OnlySynchronized ::= 'synchronized'
 	pushOnIntStack(this.synchronizedBlockSourceStart);
@@ -6817,7 +6650,7 @@
 	impt.declarationSourceEnd = flushCommentsDefinedPriorTo(impt.declarationSourceEnd);
 }
 protected void consumePackageDeclarationName() {
-	// PackageDeclarationName ::= 'package' Name
+	// PackageDeclarationName ::= PackageComment 'package' Name RejectTypeAnnotations
 	/* build an ImportRef build from the last name
 	stored in the identifier stack. */
 
@@ -6859,7 +6692,7 @@
 	}
 }
 protected void consumePackageDeclarationNameWithModifiers() {
-	// PackageDeclarationName ::= Modifiers 'package' Name
+	// PackageDeclarationName ::= Modifiers 'package' PushRealModifiers Name RejectTypeAnnotations
 	/* build an ImportRef build from the last name
 	stored in the identifier stack. */
 
@@ -7308,17 +7141,8 @@
 	pushOnGenericsLengthStack(0);
 	ClassLiteralAccess cla;
 	pushOnExpressionStack(
-		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getUnannotatedTypeReference(this.intStack[this.intPtr--])));
-	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383884
-	Annotation [][] dimensionAnnotations = cla.type.getAnnotationsOnDimensions();
-	if (dimensionAnnotations != null) {
-		for (int i = 0, max = dimensionAnnotations.length; i < max; i++) {
-			Annotation [] annotations = dimensionAnnotations[i];
-			if (annotations != null) {
-				problemReporter().misplacedTypeAnnotations(annotations[0], annotations[annotations.length - 1]);
-			}
-		}
-	}
+		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(this.intStack[this.intPtr--])));
+	rejectIllegalTypeAnnotations(cla.type);
 }
 protected void consumePrimaryNoNewArrayName() {
 	// PrimaryNoNewArray ::= Name '.' 'class'
@@ -7327,18 +7151,50 @@
 	// handle type arguments
 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
 	pushOnGenericsLengthStack(0);
-	TypeReference typeReference = getUnannotatedTypeReference(0);
+	TypeReference typeReference = getTypeReference(0);
+	
+	rejectIllegalTypeAnnotations(typeReference);
 
 	pushOnExpressionStack(
 		new ClassLiteralAccess(this.intStack[this.intPtr--], typeReference));
 }
+protected void rejectIllegalLeadingTypeAnnotations(TypeReference typeReference) {
+	// Reject misplaced annotations prefixed to a type reference; Used when the grammar is permissive enough to allow them in the first place.
+	Annotation [][]  annotations = typeReference.annotations;
+	if (annotations != null && annotations[0] != null) {
+		problemReporter().misplacedTypeAnnotations(annotations[0][0], annotations[0][annotations[0].length - 1]);
+		annotations[0] = null;  // don't complain further.
+	}
+}
+private void rejectIllegalTypeAnnotations(TypeReference typeReference) {
+	// Reject misplaced annotations on type reference; Used when grammar is permissive enough to allow them in the first place.
+	Annotation [][]  annotations = typeReference.annotations;
+	Annotation[] misplacedAnnotations;
+	for (int i = 0, length = annotations == null ? 0 : annotations.length; i < length; i++) {
+		misplacedAnnotations =  annotations[i];
+		if (misplacedAnnotations != null) {
+			problemReporter().misplacedTypeAnnotations(misplacedAnnotations[0], misplacedAnnotations[misplacedAnnotations.length - 1]);
+		}
+	}
+	annotations = typeReference.getAnnotationsOnDimensions();
+	for (int i = 0, length = annotations == null ? 0 : annotations.length; i < length; i++) {
+		misplacedAnnotations = annotations[i];
+		if (misplacedAnnotations != null) {
+			problemReporter().misplacedTypeAnnotations(misplacedAnnotations[0], misplacedAnnotations[misplacedAnnotations.length - 1]);
+		}
+	}
+	typeReference.annotations = null;
+	typeReference.setAnnotationsOnDimensions(null);
+	typeReference.bits &= ~ASTNode.HasTypeAnnotations;
+}
 protected void consumePrimaryNoNewArrayNameSuper() {
 	// PrimaryNoNewArray ::= Name '.' 'super'
 	// handle type arguments
 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
 	pushOnGenericsLengthStack(0);
-	TypeReference typeReference = getUnannotatedTypeReference(0);
-
+	// javac does not accept annotations here anywhere ...
+	TypeReference typeReference = getTypeReference(0);
+	rejectIllegalTypeAnnotations(typeReference);
 	pushOnExpressionStack(
 		new QualifiedSuperReference(
 			typeReference,
@@ -7350,8 +7206,9 @@
 	// handle type arguments
 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
 	pushOnGenericsLengthStack(0); // handle type arguments
-	TypeReference typeReference = getUnannotatedTypeReference(0);
-
+	// javac does not accept annotations here anywhere ...
+	TypeReference typeReference = getTypeReference(0);
+	rejectIllegalTypeAnnotations(typeReference);
 	pushOnExpressionStack(
 		new QualifiedThisReference(
 			typeReference,
@@ -7363,30 +7220,23 @@
 	this.intPtr--; // remove the class start position
 	ClassLiteralAccess cla;
 	pushOnExpressionStack(
-		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getUnannotatedTypeReference(this.intStack[this.intPtr--])));
-	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383884
-	Annotation [][] dimensionAnnotations = cla.type.getAnnotationsOnDimensions();
-	if (dimensionAnnotations != null) {
-		for (int i = 0, max = dimensionAnnotations.length; i < max; i++) {
-			Annotation [] annotations = dimensionAnnotations[i];
-			if (annotations != null) {
-				problemReporter().misplacedTypeAnnotations(annotations[0], annotations[annotations.length - 1]);
-			}
-		}
-	}
+		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(this.intStack[this.intPtr--])));
+	rejectIllegalTypeAnnotations(cla.type);
 }
 protected void consumePrimaryNoNewArrayPrimitiveType() {
 	// PrimaryNoNewArray ::= PrimitiveType '.' 'class'
 	this.intPtr--; // remove the class start position
+	ClassLiteralAccess cla;
 	pushOnExpressionStack(
-		new ClassLiteralAccess(this.intStack[this.intPtr--], getUnannotatedTypeReference(0)));
+		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(0)));
+	rejectIllegalTypeAnnotations(cla.type);
 }
 protected void consumePrimaryNoNewArrayThis() {
 	// PrimaryNoNewArray ::= 'this'
 	pushOnExpressionStack(new ThisReference(this.intStack[this.intPtr--], this.endPosition));
 }
 protected void consumePrimaryNoNewArrayWithName() {
-	// PrimaryNoNewArray ::=  PushLPAREN Expression PushRPAREN
+	// PrimaryNoNewArray ::=  PushLPAREN Name PushRPAREN
 	pushOnExpressionStack(getUnspecifiedReferenceOptimized());
 	final Expression parenthesizedExpression = this.expressionStack[this.expressionPtr];
 	updateSourcePosition(parenthesizedExpression);
@@ -7429,12 +7279,20 @@
 	pushOnIntStack(this.modifiersSourceStart);
 	resetModifiers();
 }
-protected void consumeQualifiedName() {
+protected void consumeQualifiedName(boolean qualifiedNameIsAnnotated) {
 	// QualifiedName ::= Name '.' SimpleName
+	// QualifiedName ::= Name '.' TypeAnnotations SimpleName 
 	/*back from the recursive loop of QualifiedName.
 	Updates identifier length into the length stack*/
 
 	this.identifierLengthStack[--this.identifierLengthPtr]++;
+	if (!qualifiedNameIsAnnotated) {
+		pushOnTypeAnnotationLengthStack(0);
+	}
+}
+protected void consumeUnannotatableQualifiedName() {
+	// UnannotatableName ::= UnannotatableName '.' SimpleName
+	this.identifierLengthStack[--this.identifierLengthPtr]++;
 }
 protected void consumeRecoveryMethodHeaderName() {
 	// this method is call only inside recovery
@@ -7636,37 +7494,11 @@
 		this.typeAnnotationLengthPtr --; // pop the 0 from the length stack
 	}
 }
-protected void consumeEmptyDimsoptAnnotsopt() {
-	// DimsoptAnnotsopt ::= $empty
-	pushOnIntStack(0);  // signal a non array
-	pushOnTypeAnnotationLengthStack(0); // no trailing annotations (receiver/vararg)
-}
-protected void consumeRightParenForUnannotatedTypeCast() {
-	consumeUnannotatedType();
-	// PushRPAREN ::= ')'
-	pushOnIntStack(this.rParenPos);
-}
-protected void consumeRightParenForNameUnannotatedTypeCast() {
-	pushOnIntStack(0);  // signal a non array
-	consumeUnannotatedType();
-	// remove the fake dimension
-	this.intPtr--;
-	// PushRPAREN ::= ')'
-	pushOnIntStack(this.rParenPos);
-}
-protected void consumeRightParenForAnnotatedTypeCast() {
-	consumeUnannotatedType();
-	// PushRPAREN ::= ')'
-	pushOnIntStack(this.rParenPos);
-}
-protected void consumeRightParenForNameAndAnnotatedTypeCast() {
-	// push a zero for dimensions
-	pushOnIntStack(0);
-	consumeUnannotatedType();
-	// remove the fake dimension
-	this.intPtr--;
-	// PushRPAREN ::= ')'
-	pushOnIntStack(this.rParenPos);
+protected void consumeZeroTypeAnnotations() {
+	// PushZeroTypeAnnotations ::= $empty
+	// Name ::= SimpleName
+	// TypeAnnotationsopt ::= $empty
+	pushOnTypeAnnotationLengthStack(0); // signal absence of @308 annotations.
 }
 // This method is part of an automatic generation : do NOT edit-modify
 protected void consumeRule(int act) {
@@ -10072,11 +9904,12 @@
 }
 protected void consumeExplicitThisParameter(boolean isQualified) {
 	// VariableDeclaratorIdOrThis ::= 'this'
-	// VariableDeclaratorIdOrThis ::= Name '.' 'this'
+	// VariableDeclaratorIdOrThis ::= UnannotatableName '.' 'this'
+	// VariableDeclaratorIdOrThis ::= VariableDeclaratorId
 
 	NameReference qualifyingNameReference = null;
 	if (isQualified) {
-		qualifyingNameReference = getUnspecifiedReference();
+		qualifyingNameReference = getUnspecifiedReference(false); // By construction the qualified name is unannotated here, so we should not meddle with the type annotation stack
 	}
 	pushOnExpressionStack(qualifyingNameReference);
 
@@ -10229,11 +10062,9 @@
 }
 protected void consumeReferenceExpressionTypeForm(boolean isPrimitive, boolean isArray) {
 	
-	// ReferenceExpression ::= PrimitiveType Dims PushModifiers '::' NonWildTypeArgumentsopt IdentifierOrNew
-	// ReferenceExpression ::= Modifiers PrimitiveType Dims PushRealModifiers '::' NonWildTypeArgumentsopt IdentifierOrNew
-	// ReferenceExpression ::= Name Dims PushModifiers '::' NonWildTypeArgumentsopt IdentifierOrNew
-	// ReferenceExpression ::= Modifiers Name Dims PushRealModifiers '::' NonWildTypeArgumentsopt IdentifierOrNew
-	// ReferenceExpression ::= Modifiers Name PushRealModifiers '::' NonWildTypeArgumentsopt IdentifierOrNew
+	// ReferenceExpression ::= PrimitiveType Dims '::' NonWildTypeArgumentsopt IdentifierOrNew
+	// ReferenceExpression ::= Name Dims '::' NonWildTypeArgumentsopt IdentifierOrNew
+	// ReferenceExpression ::= Name '::' NonWildTypeArgumentsopt IdentifierOrNew
 
 	ReferenceExpression rexp;
 	TypeReference type = null;
@@ -10245,7 +10076,8 @@
 	if (newForm) {
 		newEnd = this.intStack[this.intPtr--] + 3; // "new"
 	} else {
-		methodReference = (SingleNameReference) getUnspecifiedReferenceOptimized();
+		methodReference = new SingleNameReference(this.identifierStack[this.identifierPtr], this.identifierPositionStack[this.identifierPtr--]);
+		this.identifierLengthPtr--;
 	}
 	
 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
@@ -10255,37 +10087,15 @@
 		this.intPtr--;  // pop type arguments source start.
 	}
 	
-	int illegalModifiersSourceStart = this.intStack[this.intPtr--];
-	int illegalModifiers = this.intStack[this.intPtr--];
+	// TODO(Srikanth) : Handle ambiguity with NameReference.
 	
 	if (!isPrimitive) { // handle type arguments
 		pushOnGenericsLengthStack(0);
 		pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
 	}
 
-	// Type Annotations are in the expression stack, so retrieve as unannotated type 
-	type = getUnannotatedTypeReference(isArray ? this.intStack[this.intPtr--] : 0);
-    // and attach the annotations now.
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		type.annotations = new Annotation[type.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				type.annotations[0] = new Annotation[length],
-				0,
-				length);
-		type.sourceStart = type.annotations[0][0].sourceStart;
-		type.bits |= ASTNode.HasTypeAnnotations;
-	}
-	if (illegalModifiersSourceStart >= 0 && illegalModifiersSourceStart < type.sourceStart) {
-		type.sourceStart = illegalModifiersSourceStart;
-	}
+	type = getTypeReference(isArray ? this.intStack[this.intPtr--] : 0);
 
-	if (illegalModifiers != ClassFileConstants.AccDefault) {
-		problemReporter().invalidLocationForModifiers(type);
-	}
-	resetModifiers();
-	
 	if (newForm) {
 		rexp = new ReferenceExpression(type, typeArguments, newEnd);
 	} else {
@@ -10297,40 +10107,6 @@
 		problemReporter().referenceExpressionsNotBelow18(rexp);
 	}
 }
-protected void consumeReferenceExpressionNameForm() {
-	// ReferenceExpression ::= Name '::' NonWildTypeArgumentsopt IdentifierOrNew
-	
-	ReferenceExpression rexp;
-	TypeReference [] typeArguments = null;
-	SingleNameReference methodReference = null;
-	int newEnd = -1;
-	
-	boolean newForm = this.intStack[this.intPtr--] != 0;
-	if (newForm) {
-		newEnd = this.intStack[this.intPtr--] + 3; // "new"
-	} else {
-		methodReference = (SingleNameReference) getUnspecifiedReferenceOptimized();
-	}
-	
-	int length = this.genericsLengthStack[this.genericsLengthPtr--];
-	if (length > 0) {
-		this.genericsPtr -= length;
-		System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments = new TypeReference[length], 0, length);
-		this.intPtr--;  // pop type arguments source start.
-	}
-	
-	// There is some ambiguity between type reference and name reference here.
-	NameReference nameReference = getUnspecifiedReference();
-	if (newForm) {
-		rexp = new ReferenceExpression(nameReference, typeArguments, newEnd);
-	} else {
-		rexp = new ReferenceExpression(nameReference, typeArguments, methodReference); 
-	}
-	pushOnExpressionStack(rexp);
-	if (!this.parsingJava8Plus) {
-		problemReporter().referenceExpressionsNotBelow18(rexp);
-	}
-}
 protected void consumeReferenceExpressionPrimaryForm() {
 	// ReferenceExpression ::= Primary '::' NonWildTypeArgumentsopt Identifier
 
@@ -10338,7 +10114,8 @@
 	TypeReference [] typeArguments = null;
 	SingleNameReference methodReference;
 	
-	methodReference = (SingleNameReference) getUnspecifiedReferenceOptimized();
+	methodReference = new SingleNameReference(this.identifierStack[this.identifierPtr], this.identifierPositionStack[this.identifierPtr--]);
+	this.identifierLengthPtr--;
 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
 	if (length > 0) {
 		this.genericsPtr -= length;
@@ -10361,7 +10138,8 @@
 	TypeReference [] typeArguments = null;
 	SingleNameReference methodReference;
 	
-	methodReference = (SingleNameReference) getUnspecifiedReferenceOptimized();
+	methodReference = new SingleNameReference(this.identifierStack[this.identifierPtr], this.identifierPositionStack[this.identifierPtr--]);
+	this.identifierLengthPtr--;
 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
 	if (length > 0) {
 		this.genericsPtr -= length;
@@ -10384,8 +10162,7 @@
 }
 protected void consumeReferenceExpressionGenericTypeForm() {
 
-	// ReferenceExpression ::= Name PushModifiers BeginTypeArguments ReferenceExpressionTypeArgumentsAndTrunk '::' NonWildTypeArgumentsopt IdentifierOrNew
-	// ReferenceExpression ::= Modifiers Name PushRealModifiers BeginTypeArguments ReferenceExpressionTypeArgumentsAndTrunk '::' NonWildTypeArgumentsopt IdentifierOrNew
+	// ReferenceExpression ::= Name BeginTypeArguments ReferenceExpressionTypeArgumentsAndTrunk '::' NonWildTypeArgumentsopt IdentifierOrNew
 	
 	ReferenceExpression rexp;
 	TypeReference type = null;
@@ -10397,7 +10174,8 @@
 	if (newForm) {
 		newEnd = this.intStack[this.intPtr--] + 3; // "new"
 	} else {
-		methodReference = (SingleNameReference) getUnspecifiedReferenceOptimized();
+		methodReference = new SingleNameReference(this.identifierStack[this.identifierPtr], this.identifierPositionStack[this.identifierPtr--]);
+		this.identifierLengthPtr--;
 	}
 	
 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
@@ -10410,44 +10188,19 @@
 	int typeSourceEnd = this.intStack[this.intPtr--];
 	boolean qualified = this.intStack[this.intPtr--] != 0;
 	int dims = this.intStack[this.intPtr--];
-
 	if (qualified) {
-		TypeReference rightSide = getUnannotatedTypeReference(0); // until we add support for X. @Inner Y, by design the type after '.' is unannotated.
-		type = computeQualifiedGenericsFromRightSide(rightSide, dims);
+		Annotation [][] annotationsOnDimensions = dims == 0 ? null : getAnnotationsOnDimensions(dims);
+		TypeReference rightSide = getTypeReference(0);
+		type = computeQualifiedGenericsFromRightSide(rightSide, dims, annotationsOnDimensions);
 	} else {		
 		pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
-		type = getUnannotatedTypeReference(dims); // annotations attached below.
+		type = getTypeReference(dims);
 	}
 	this.intPtr--; // pop '<' position
-	int illegalModifiersSourceStart = this.intStack[this.intPtr--];
-	if (illegalModifiersSourceStart >= 0 && illegalModifiersSourceStart < type.sourceStart) {
-		type.sourceStart = illegalModifiersSourceStart;
-	}
 	type.sourceEnd = typeSourceEnd;
 	
 	rexp = newForm ? new ReferenceExpression(type, typeArguments, newEnd) : new ReferenceExpression(type, typeArguments, methodReference);
 
-	// Prefix annotations if any are on the expression stack, attach them now.
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		type.annotations = new Annotation[type.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				type.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int annotStart = type.annotations[0][0].sourceStart;
-		if (annotStart < type.sourceStart) {
-			type.sourceStart = annotStart;
-		}
-		type.bits |= ASTNode.HasTypeAnnotations;
-	}
-
-	int illegalModifiers = this.intStack[this.intPtr--];
-	if (illegalModifiers != ClassFileConstants.AccDefault) {
-		problemReporter().invalidLocationForModifiers(type);
-	}
-	resetModifiers();
 	pushOnExpressionStack(rexp);
 	if (!this.parsingJava8Plus) {
 		problemReporter().referenceExpressionsNotBelow18(rexp);
@@ -10467,8 +10220,9 @@
 	this.expressionLengthPtr--;
 	pushOnAstStack(new AssertStatement(this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--]));
 }
-protected void consumeSingleMemberAnnotation() {
-	// SingleMemberAnnotation ::= '@' Name '(' MemberValue ')'
+protected void consumeSingleMemberAnnotation(boolean isTypeAnnotation) {
+	// SingleMemberTypeAnnotation ::= TypeAnnotationName '(' SingleMemberAnnotationMemberValue ')'
+	// SingleMemberAnnotation ::= AnnotationName '(' SingleMemberAnnotationMemberValue ')'
 	SingleMemberAnnotation singleMemberAnnotation = null;
 
 	int oldIndex = this.identifierPtr;
@@ -10478,8 +10232,12 @@
 	singleMemberAnnotation.memberValue = this.expressionStack[this.expressionPtr--];
 	this.expressionLengthPtr--;
 	singleMemberAnnotation.declarationSourceEnd = this.rParenPos;
-	pushOnExpressionStack(singleMemberAnnotation);
-
+	
+	if (isTypeAnnotation) {
+		pushOnTypeAnnotationStack(singleMemberAnnotation);
+	} else {
+		pushOnExpressionStack(singleMemberAnnotation);
+	}
 
 	if(this.currentElement != null) {
 		annotationRecoveryCheckPoint(singleMemberAnnotation.sourceStart, singleMemberAnnotation.declarationSourceEnd);
@@ -10509,7 +10267,7 @@
 	// Resources ::= Resource
 }
 protected void consumeSingleStaticImportDeclarationName() {
-	// SingleTypeImportDeclarationName ::= 'import' 'static' Name
+	// SingleTypeImportDeclarationName ::= 'import' Name RejectTypeAnnotations
 	/* push an ImportRef build from the last name
 	stored in the identifier stack. */
 
@@ -10968,7 +10726,7 @@
 			this.endStatementPosition);
 }
 protected void consumeStaticImportOnDemandDeclarationName() {
-	// TypeImportOnDemandDeclarationName ::= 'import' 'static' Name '.' '*'
+	// StaticImportOnDemandDeclarationName ::= 'import' 'static' Name '.' RejectTypeAnnotations '*'
 	/* push an ImportRef build from the last name
 	stored in the identifier stack. */
 
@@ -11398,6 +11156,7 @@
 		case TokenNameLPAREN :
 			this.lParenPos = this.scanner.startPosition;
 			break;
+		case TokenNameAT308:
 		case TokenNameAT :
 			pushOnIntStack(this.scanner.startPosition);
 			break;
@@ -11511,67 +11270,11 @@
 	pushOnGenericsStack(getTypeReference(0));
 	this.intPtr--;
 }
-protected void consumeTypeArgumentReferenceType1WithTypeAnnotations() {
-	concatGenericsLists();
-	TypeReference typeReference = getUnannotatedTypeReference(0);
-	// copy from expression stack to type annotation stack
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.bits |= ASTNode.HasTypeAnnotations;
-		typeReference.sourceStart = typeReferenceSourceStart;
-	}
-	pushOnGenericsStack(typeReference);
-	// remove the 0 pushed by ZeroTypeAnnotation
-	this.typeAnnotationLengthPtr--;
-	this.intPtr--;
-	if (this.modifiers != ClassFileConstants.AccDefault) {
-		problemReporter().invalidLocationForModifiers(typeReference);
-	}
-	resetModifiers();
-}
 protected void consumeTypeArgumentReferenceType2() {
 	concatGenericsLists();
 	pushOnGenericsStack(getTypeReference(0));
 	this.intPtr--;
 }
-protected void consumeTypeArgumentReferenceType2WithTypeAnnotations() {
-	concatGenericsLists();
-	TypeReference typeReference = getUnannotatedTypeReference(0);
-	// copy from expression stack to type annotation stack
-	int length;
-	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
-		typeReference.annotations = new Annotation[typeReference.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.expressionStack,
-				(this.expressionPtr -= length) + 1,
-				typeReference.annotations[0] = new Annotation[length],
-				0,
-				length);
-		int typeReferenceSourceStart = typeReference.annotations[0][0].sourceStart;
-		if (this.modifiersSourceStart < typeReferenceSourceStart) {
-			typeReferenceSourceStart = this.modifiersSourceStart;
-		}
-		typeReference.bits |= ASTNode.HasTypeAnnotations;
-		typeReference.sourceStart = typeReferenceSourceStart;
-	}
-	pushOnGenericsStack(typeReference);
-	this.intPtr--;
-	if (this.modifiers != ClassFileConstants.AccDefault) {
-		problemReporter().invalidLocationForModifiers(typeReference);
-	}
-	resetModifiers();
-}
 protected void consumeTypeArguments() {
 	concatGenericsLists();
 	this.intPtr--;
@@ -11688,7 +11391,7 @@
 	}
 }
 protected void consumeTypeImportOnDemandDeclarationName() {
-	// TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*'
+	// TypeImportOnDemandDeclarationName ::= 'import' Name '.' RejectTypeAnnotations '*'
 	/* push an ImportRef build from the last name
 	stored in the identifier stack. */
 
@@ -11754,7 +11457,7 @@
 	}
 }
 protected void consumeTypeParameterHeader() {
-	//TypeParameterHeader ::= Identifier
+	//TypeParameterHeader ::= TypeAnnotationsopt Identifier
 	TypeParameter typeParameter = new TypeParameter();
 	int length;
 	if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
@@ -11953,12 +11656,14 @@
 	final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
 	wildcard.sourceEnd = this.intStack[this.intPtr--];
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	pushOnGenericsStack(wildcard);
 }
 protected void consumeWildcard1() {
 	final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
 	wildcard.sourceEnd = this.intStack[this.intPtr--];
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	pushOnGenericsStack(wildcard);
 }
 protected void consumeWildcard1WithBounds() {
@@ -11969,6 +11674,7 @@
 	final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
 	wildcard.sourceEnd = this.intStack[this.intPtr--];
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	pushOnGenericsStack(wildcard);
 }
 protected void consumeWildcard2WithBounds() {
@@ -11979,6 +11685,7 @@
 	final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
 	wildcard.sourceEnd = this.intStack[this.intPtr--];
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	pushOnGenericsStack(wildcard);
 }
 protected void consumeWildcard3WithBounds() {
@@ -11991,6 +11698,7 @@
 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
 	this.intPtr--; // remove end position of the '?'
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	this.genericsStack[this.genericsPtr] = wildcard;
 }
 protected void consumeWildcardBounds1Super() {
@@ -12000,6 +11708,7 @@
 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
 	this.intPtr--; // remove end position of the '?'
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	this.genericsStack[this.genericsPtr] = wildcard;
 }
 protected void consumeWildcardBounds2Extends() {
@@ -12008,6 +11717,7 @@
 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
 	this.intPtr--; // remove end position of the '?'
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	this.genericsStack[this.genericsPtr] = wildcard;
 }
 protected void consumeWildcardBounds2Super() {
@@ -12017,6 +11727,7 @@
 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
 	this.intPtr--; // remove end position of the '?'
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	this.genericsStack[this.genericsPtr] = wildcard;
 }
 protected void consumeWildcardBounds3Extends() {
@@ -12025,6 +11736,7 @@
 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
 	this.intPtr--; // remove end position of the '?'
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	this.genericsStack[this.genericsPtr] = wildcard;
 }
 protected void consumeWildcardBounds3Super() {
@@ -12034,6 +11746,7 @@
 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
 	this.intPtr--; // remove end position of the '?'
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	this.genericsStack[this.genericsPtr] = wildcard;
 }
 protected void consumeWildcardBoundsExtends() {
@@ -12042,6 +11755,7 @@
 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
 	this.intPtr--; // remove end position of the '?'
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	pushOnGenericsStack(wildcard);
 }
 protected void consumeWildcardBoundsSuper() {
@@ -12051,6 +11765,7 @@
 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
 	this.intPtr--; // remove end position of the '?'
 	wildcard.sourceStart = this.intStack[this.intPtr--];
+	annotateTypeReference(wildcard);
 	pushOnGenericsStack(wildcard);
 }
 protected void consumeWildcardWithBounds() {
@@ -12710,11 +12425,28 @@
 	exp.bits |= Binding.TYPE;
 	return exp;
 }
+protected void annotateTypeReference(TypeReference ref) {
+	int length;
+	if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
+		if (ref.annotations == null)
+			ref.annotations = new Annotation[ref.getAnnotatableLevels()][];
+		System.arraycopy(
+				this.typeAnnotationStack,
+				(this.typeAnnotationPtr -= length) + 1,
+				ref.annotations[0] = new Annotation[length],
+				0,
+				length);
+		if (ref.sourceStart > ref.annotations[0][0].sourceStart) {
+			ref.sourceStart = ref.annotations[0][0].sourceStart;
+		}
+		ref.bits |= ASTNode.HasTypeAnnotations;
+	}
+}
 protected TypeReference getTypeReference(int dim) {
 //{ObjectTeams: wrap to introduce 2nd parameter
 	return getTypeReference(dim, false);  
 }
-protected TypeReference getTypeReference(int dim, boolean liftingTypeAllowed) {
+protected void getTypeReference(int dims, boolean liftingTypeAllowed) {
 	if (this.astPtr > -1 && this.astStack[this.astPtr] instanceof LiftingTypeReference) {
 		LiftingTypeReference ltr = completeLiftingTypeReference(dim);
 		if (liftingTypeAllowed)
@@ -12723,25 +12455,7 @@
 			problemReporter().syntaxErrorIllegalDeclaredLifting(this.referenceContext, ltr);
 		return ltr.baseReference; // don't surface illegal LTR
 	}
-// SH}
-	TypeReference ref = getUnannotatedTypeReference(dim);
-	int length;
-	if (this.typeAnnotationLengthPtr >= 0
-			&& (length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
-		//	if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
-		ref.annotations = new Annotation[ref.getAnnotatableLevels()][];
-		System.arraycopy(
-				this.typeAnnotationStack,
-				(this.typeAnnotationPtr -= length) + 1,
-				ref.annotations[0] = new Annotation[length],
-				0,
-				length);
-		ref.sourceStart = ref.annotations[0][0].sourceStart;
-		ref.bits |= ASTNode.HasTypeAnnotations;
-	}
-	return ref;
-	}
-protected TypeReference getUnannotatedTypeReference(int dim) {
+//SH}
 	/* build a Reference on a variable that may be qualified or not
 	 This variable is a type reference and dim will be its dimensions*/
 
@@ -12766,7 +12480,7 @@
 			// generic type
 			ref = getTypeReferenceForGenericType(dim, length, numberOfIdentifiers);
 		} else if (length == 1) {
-			// single variable reference
+			// single type reference
 			this.genericsLengthPtr--; // pop the 0
 			if (dim == 0) {
 				ref =
@@ -12788,7 +12502,7 @@
 			}
 		} else {
 			this.genericsLengthPtr--;
-			//Qualified variable reference
+			//Qualified type reference
 			char[][] tokens = new char[length][];
 			this.identifierPtr -= length;
 			long[] positions = new long[length];
@@ -12809,6 +12523,23 @@
 			}
 		}
 	}
+	int levels = ref.getAnnotatableLevels();
+	for (int i = levels - 1; i >= 0; i--) {
+		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
+			if (ref.annotations == null)
+				ref.annotations = new Annotation[levels][];
+			System.arraycopy(
+					this.typeAnnotationStack,
+					(this.typeAnnotationPtr -= length) + 1,
+					ref.annotations[i] = new Annotation[length],
+					0,
+					length);
+			if (i == 0) {
+				ref.sourceStart = ref.annotations[0][0].sourceStart;
+			}
+			ref.bits |= ASTNode.HasTypeAnnotations;
+		}
+	}
 	return ref;
 }
 //{ObjectTeams: when retrieving a type from stacks and when finding a lifting type reference,
@@ -12894,8 +12625,13 @@
 	}
 }
 protected NameReference getUnspecifiedReference() {
+	return getUnspecifiedReference(true);
+}
+protected NameReference getUnspecifiedReference(boolean rejectTypeAnnotations) {
 	/* build a (unspecified) NameReference which may be qualified*/
-
+	if (rejectTypeAnnotations) { // Compensate for overpermissive grammar.
+		consumeNonTypeUseName();
+	}
 	int length;
 	NameReference ref;
 	if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1)
@@ -12927,7 +12663,7 @@
 	a field access. This optimization is IMPORTANT while it results
 	that when a NameReference is build, the type checker should always
 	look for that it is not a type reference */
-
+	consumeNonTypeUseName();
 	int length;
 	NameReference ref;
 	if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1) {
@@ -13142,7 +12878,6 @@
 	this.astLengthPtr = -1;
 	this.expressionPtr = -1;
 	this.expressionLengthPtr = -1;
-	this.unattachedAnnotationPtr = -1;
 	this.typeAnnotationLengthPtr = -1;
 	this.typeAnnotationPtr = -1;
 	this.identifierPtr = -1;
@@ -13490,10 +13225,10 @@
 public boolean atConflictScenario(int token) {
 	
 	/* Answer true if the parser is at a configuration where the scanner must look ahead and help disambiguate between (a) '<' as an operator and '<' as the
-	   start of <type argument> and (b) the use of '(' in '(' expression ')' and '( type ')' and '(' lambda formal parameters ')'. When requested thus,
-	   the scanner helps by fabricating synthetic tokens and injecting them into the stream ahead of the tokens that trigger conflicts in the absence
-	   of these artificial tokens. These manufactured token help transform the grammar into LALR(1) by splitting the states so that they have unambigious
-	   prefixes.
+	   start of <type argument> and (b) the use of '(' in '(' expression ')' and '( type ')' and '(' lambda formal parameters ')'. (c) whether the token @
+	   begins a Java SE5 style declaration annotation or if it begins a SE8 style type annotation. When requested thus, the scanner helps by fabricating 
+	   synthetic tokens and injecting them into the stream ahead of the tokens that trigger conflicts in the absence of these artificial tokens. These 
+	   manufactured token help transform the grammar into LALR(1) by splitting the states so that they have unambigious prefixes.
 	   
 	   We do this by claiming to the automaton that the next token seen is the (suitable) synthetic token and observing the response of the state machine. 
 	   Error signals we are NOT at a conflict site, while shift or shift/reduce signals that we are. Accept is impossible, while there may be intermediate
@@ -13522,7 +13257,9 @@
 	int stackTopState = this.stack[stackTop]; // single cell non write through "alternate stack" - the automaton's stack pointer either stays fixed during this manoeuvre or monotonically decreases.
 	int highWaterMark = stackTop;
 	
-	token = token == TokenNameLPAREN ? TokenNameBeginLambda : TokenNameBeginTypeArguments;
+	if (token != TokenNameAT) {
+		token = token == TokenNameLPAREN ? TokenNameBeginLambda : TokenNameBeginTypeArguments;
+	}
 	
 	// A rotated version of the automaton - cf. parse()'s for(;;)
 	for (;;) {  
@@ -15185,7 +14922,6 @@
 	this.astLengthPtr = -1;
 	this.expressionPtr = -1;
 	this.expressionLengthPtr = -1;
-	this.unattachedAnnotationPtr = -1;
 	this.typeAnnotationLengthPtr = -1;
 	this.typeAnnotationPtr = -1;
 	this.identifierPtr = -1;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
index b95e6bd..65c4b13 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
@@ -21,24 +21,22 @@
 /*An interface that contains static declarations for some basic information
  about the parser such as the number of rules in the grammar, the starting state, etc...*/
 public interface ParserBasicInformation {
-    public final static int
+	int ERROR_SYMBOL = 117,
+			MAX_NAME_LENGTH = 41,
+			NUM_STATES = 1062,
 
-      ERROR_SYMBOL      = 134,
-      MAX_NAME_LENGTH   = 50,
-      NUM_STATES        = 1395,
-
-      NT_OFFSET         = 134,
-      SCOPE_UBOUND      = 326,
-      SCOPE_SIZE        = 327,
-      LA_STATE_OFFSET   = 19203,
-      MAX_LA            = 1,
-      NUM_RULES         = 970,
-      NUM_TERMINALS     = 134,
-      NUM_NON_TERMINALS = 428,
-      NUM_SYMBOLS       = 562,
-      START_STATE       = 1138,
-      EOFT_SYMBOL       = 72,
-      EOLT_SYMBOL       = 72,
-      ACCEPT_ACTION     = 19202,
-      ERROR_ACTION      = 19203;
+			NT_OFFSET = 117,
+			SCOPE_UBOUND = 277,
+			SCOPE_SIZE = 278,
+			LA_STATE_OFFSET = 15569,
+			MAX_LA = 1,
+			NUM_RULES = 775,
+			NUM_TERMINALS = 117,
+			NUM_NON_TERMINALS = 347,
+			NUM_SYMBOLS = 464,
+			START_STATE = 831,
+			EOFT_SYMBOL = 60,
+			EOLT_SYMBOL = 60,
+			ACCEPT_ACTION = 15568,
+			ERROR_ACTION = 15569;
 }
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
index 1ab0a76..2034cd2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
@@ -1362,6 +1362,12 @@
 	} else if (token == TokenNameLESS && atReferenceExpression()) {
 		this.nextToken = token;
 		token = TokenNameBeginTypeArguments;
+	} else if (token == TokenNameAT && atTypeAnnotation()) {
+		token = TokenNameAT308;
+		if (atEllipsisAnnotation()) {
+			this.nextToken = token;
+			token = TokenNameAT308DOTDOTDOT;
+		}
 	}
 
 	this.lookBack[0] = this.lookBack[1];
@@ -5148,6 +5154,9 @@
 	   We morph one or the other specific token into EOF and see if the parser enters accept state. On true EOF, we return fake
 	   EOF to force an error. This is so that the interim goal reduction actually happens only when -> or :: occur in input at
 	   the expected place.
+	   
+	   To make matters interesting, type annotations can occur inside both lambda parameter list and reference expression trunks
+	   and declarative annotations can occur in lambda parameter lists. We need to discriminate between them. Sigh.
 	*/
 	private int fakeEofToken = TokenNameNotAToken; // if encountered in input stream, will be exposed as EOF instead.
 
@@ -5157,6 +5166,9 @@
 	
 	public int getNextToken() throws InvalidInputException {
 		int token = getNextToken0();
+		if (token == TokenNameAT && atTypeAnnotation()) {
+			token = TokenNameAT308;
+		}
 		return token == this.fakeEofToken ? TokenNameEOF : token == TokenNameEOF ? this.fakeEofToken : token; 
 	}
 
@@ -5166,13 +5178,7 @@
 }
 
 // Vanguard Parser - A Private utility helper class for the scanner.
-private static class VanguardParser implements ParserBasicInformation, TerminalTokens {
-	
-	private int[] stack = new int[StackIncrement];
-	private int stateStackTop;
-	private final static int StackIncrement = 255;
-	private int currentToken;
-	private final VanguardScanner scanner;
+private static class VanguardParser extends Parser {
 	
 	public VanguardParser(VanguardScanner scanner) {
 		this.scanner = scanner;
@@ -5200,11 +5206,21 @@
 				if (act <= NUM_RULES) {
 					this.stateStackTop--;
 				} else if (act > ERROR_ACTION) { /* shift-reduce */
-					this.currentToken = this.scanner.getNextToken();
+					this.unstackedAct = act;
+					try {
+						this.currentToken = this.scanner.getNextToken();
+					} finally {
+						this.unstackedAct = ERROR_ACTION;
+					}
 					act -= ERROR_ACTION;
 				} else {
 				    if (act < ACCEPT_ACTION) { /* shift */
-				    	this.currentToken = this.scanner.getNextToken();
+				    	this.unstackedAct = act;
+						try {
+							this.currentToken = this.scanner.getNextToken();
+						} finally {
+							this.unstackedAct = ERROR_ACTION;
+						}
 						continue ProcessTerminals;
 					}
 				    return true; // accept !
@@ -5226,12 +5242,18 @@
 	if (this.vanguardParser == null) {
 		this.vanguardScanner = new VanguardScanner(this.sourceLevel, this.complianceLevel);
 		this.vanguardParser = new VanguardParser(this.vanguardScanner);
+		this.vanguardScanner.setActiveParser(this.vanguardParser);
 	}
 	this.vanguardScanner.setSource(this.source);
 	this.vanguardScanner.resetTo(this.startPosition, this.eofPosition - 1);
 	return this.vanguardParser;
 }
-private final boolean atLambdaParameterList() { // Did the '(' we saw just now herald a lambda parameter list ?
+
+public void setFakeEofToken(int specialToken) {
+	throw new UnsupportedOperationException();   // for specific specializations only.
+}
+
+protected final boolean atLambdaParameterList() { // Did the '(' we saw just now herald a lambda parameter list ?
 
 	switch (this.lookBack[1]) {
 		case TokenNameEQUAL : 
@@ -5251,7 +5273,8 @@
 	}
 	return this.activeParser.atConflictScenario(TokenNameLPAREN) && getVanguardParser().parse(TokenNameARROW);
 }
-private final boolean atReferenceExpression() { // Did the '<' we saw just now herald a reference expression ?
+
+protected final boolean atReferenceExpression() { // Did the '<' we saw just now herald a reference expression ?
 	switch (this.lookBack[1]) {
 		case TokenNameIdentifier:
 			switch (this.lookBack[0]) {
@@ -5289,6 +5312,27 @@
 	}
 	return this.activeParser.atConflictScenario(TokenNameLESS) && getVanguardParser().parse(TokenNameCOLON_COLON);
 }
+protected final boolean atEllipsisAnnotation() { // Did the '@' we saw just now herald a type annotation on a ... ? Presumed to be at type annotation already.
+	switch (this.lookBack[1]) {
+		case TokenNamenew:
+		case TokenNameCOMMA:
+		case TokenNameextends:
+		case TokenNamesuper:
+		case TokenNameimplements:
+		case TokenNameDOT:
+		case TokenNameLBRACE:
+		case TokenNameinstanceof:
+		case TokenNameLESS:
+		case TokenNameGREATER:
+		case TokenNameAND:
+		case TokenNamethrows:
+			return false;
+	}
+	return getVanguardParser().parse(TokenNameELLIPSIS);
+}
+protected final boolean atTypeAnnotation() { // Did the '@' we saw just now herald a type annotation ? We should not ask the parser whether it would shift @308 !
+	return !this.activeParser.atConflictScenario(TokenNameAT);
+}
 
 public void setActiveParser(ConflictedParser parser) {
 	this.activeParser  = parser;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java
index 5074355..303f9e8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java
@@ -22,7 +22,6 @@
 import org.eclipse.jdt.internal.compiler.parser.Parser;
 import org.eclipse.jdt.internal.compiler.parser.ParserBasicInformation;
 import org.eclipse.jdt.internal.compiler.parser.RecoveryScanner;
-import org.eclipse.jdt.internal.compiler.parser.Scanner;
 import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
 import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
 import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
@@ -823,9 +822,9 @@
 			}
 	    }
 
-		/* Next, try deletion of the error token, preferring deletion as a criteria in
-		   case of identical, superfluous keyword tokens. See below.
-		*/
+		//
+		// Next, try deletion of the error token.
+		//
 		j = parseCheck(
 				stck,
 				stack_top,
@@ -841,25 +840,6 @@
 			repair.misspellIndex = k;
 			repair.code = DELETION_CODE;
 			repair.distance = j;
-		} else if (j == repair.distance) {
-			/* Handle some cases where deletion as a repair strategy is obviously superior to
-			   others. e.g: Object o = new new Object() {}; For some reason, with the new grammar
-			   rules to support type annotations in place, the scopeTrial's choice above wins out
-			   with the repair strategy being to insert a semicolon after the first new. That looks
-			   very suspicious. It is not clear if that is due to the bug in the implementation of
-			   scopeTrial or in the jikespg parser generator or in the grammar.
-			
-			   The current fix is a temporary point-fix to address this problem. It does make sense
-			   as a rule, but is a bit ad-hoc in nature and the reason why scopeTrial succeeds needs
-			   to be understood.
-			*/
-			LexStream.Token previousToken = this.lexStream.token(repair.bufferPosition + 1);
-			LexStream.Token curToken = this.lexStream.token(repair.bufferPosition + 2);
-			if (previousToken != null && curToken != null && previousToken.kind == curToken.kind && Scanner.isKeyword(curToken.kind)) {
-				repair.misspellIndex = k;
-				repair.code = DELETION_CODE;
-				repair.distance = j;
-			}
 		}
 
 		//
@@ -2667,6 +2647,6 @@
 		   '<' should not be tagged for disambiguation. If a synthetic token gets injected there, there will be syntax
 		   error. See that this is not a problem for the regular/normal parser.
 		*/ 
-		return (token == TokenNameLPAREN || (token == TokenNameLESS && !this.lexStream.awaitingColonColon()));
+		return (token == TokenNameLPAREN || token == TokenNameAT || (token == TokenNameLESS && !this.lexStream.awaitingColonColon()));
 	}
 }
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index e27211e..eae9567 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -2893,14 +2893,6 @@
 		methodDecl.sourceStart,
 		methodDecl.sourceEnd);
 }
-public void invalidLocationForModifiers(ASTNode location) {
-	this.handle(
-			IProblem.InvalidLocationForModifiers,
-			NoArgument,
-			NoArgument,
-			location.sourceStart,
-			location.sourceEnd);
-}
 public void illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument) {
 	String[] arguments = new String[] {new String(localDecl.name)};
 	this.handle(
@@ -4901,6 +4893,14 @@
 			annotation.sourceStart,
 			annotation.sourceEnd);	
 }
+public void illegalTypeAnnotationsInStaticMemberAccess(Annotation first, Annotation last) {
+	this.handle(
+			IProblem.IllegalTypeAnnotationsInStaticMemberAccess,
+			NoArgument,
+			NoArgument,
+			first.sourceStart,
+			last.sourceEnd);
+}
 public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, Object location) {
 	this.referenceContext = compUnitDecl;
 	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
@@ -7618,6 +7618,11 @@
 	String errorTokenName,
 	String expectedToken) {
 
+	if (currentKind == TerminalTokens.TokenNameAT && expectedToken != null && expectedToken.equals("@")) { //$NON-NLS-1$
+		// In the diagnose parser case, we don't have the wherewithal to discriminate when we should hand out @308 vs @. So we always answer @.
+		// We should silently recover so swallow the message.
+		return;
+	}
 	String eTokenName;
 	if (isKeyword(currentKind) ||
 		isLiteral(currentKind) ||
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
index d9ba1ea..b38a9e1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -593,7 +593,7 @@
 637 = Syntax error, type annotations are available only when source level is at least 1.8
 638 = Explicit ''this'' parameter is allowed only in instance methods of non-anonymous classes and inner class constructors
 639 = Syntax error, type annotations are illegal here
-640 = Syntax error, modifiers are illegal here
+640 = Type annotations are not allowed on type names used to access static members
 641 = Type annotation is illegal for a method that returns void
 642 = Only the first formal parameter may be declared explicitly as ''this''
 643 = Explicit declaration of ''this'' parameter is allowed only at source level 1.8 or above
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
index e49a10b..cd06c88 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -113,6 +113,7 @@
 				length);
 		}
 		alloc.type = getTypeReference(0);
+		rejectIllegalLeadingTypeAnnotations(alloc.type);
 
 		length = this.genericsLengthStack[this.genericsLengthPtr--];
 		this.genericsPtr -= length;
@@ -380,6 +381,17 @@
 			this.identifierLengthPtr--;
 		} else {
 			this.identifierLengthStack[this.identifierLengthPtr]--;
+			int length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--];
+			Annotation [] typeAnnotations;
+			if (length != 0) {
+				System.arraycopy(
+						this.typeAnnotationStack,
+						(this.typeAnnotationPtr -= length) + 1,
+						typeAnnotations = new Annotation[length],
+						0,
+						length);
+				problemReporter().misplacedTypeAnnotations(typeAnnotations[0], typeAnnotations[typeAnnotations.length - 1]);
+			}
 			m.receiver = getUnspecifiedReference();
 			m.sourceStart = m.receiver.sourceStart;
 		}
@@ -635,8 +647,11 @@
 	}
 	return super.endParse(act);
 }
-protected NameReference getUnspecifiedReference() {
+protected NameReference getUnspecifiedReference(boolean rejectTypeAnnotations) {
 	/* build a (unspecified) NameReference which may be qualified*/
+	if (rejectTypeAnnotations) {
+		consumeNonTypeUseName();
+	}
 
 	if (this.scanner.startPosition >= this.codeSnippetStart
 		&& this.scanner.startPosition <= this.codeSnippetEnd+1+this.lineSeparatorLength /*14838*/){
@@ -665,7 +680,7 @@
 		}
 		return ref;
 	} else {
-		return super.getUnspecifiedReference();
+		return super.getUnspecifiedReference(rejectTypeAnnotations);
 	}
 }
 protected NameReference getUnspecifiedReferenceOptimized() {
@@ -675,6 +690,7 @@
 	a field access. This optimization is IMPORTANT while it results
 	that when a NameReference is build, the type checker should always
 	look for that it is not a type reference */
+	consumeNonTypeUseName();
 
 	if (this.scanner.startPosition >= this.codeSnippetStart
 		&& this.scanner.startPosition <= this.codeSnippetEnd+1+this.lineSeparatorLength /*14838*/){
@@ -802,7 +818,6 @@
 
 	// reset stacks in consistent state
 	this.expressionPtr = -1;
-	this.unattachedAnnotationPtr = -1;
 	this.typeAnnotationLengthPtr = -1;
 	this.typeAnnotationPtr = -1;
 	this.identifierPtr = -1;
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java
index db0bab7..ba8b275 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java
@@ -5,10 +5,6 @@
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  * 
- * This is an implementation of an early-draft specification developed under the Java
- * Community Process (JCP) and is made available for testing and evaluation purposes
- * only. The code is not compatible with any specification of the JCP.
- * 
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *     Brock Janiczak - Contribution for bug 150741
@@ -194,8 +190,8 @@
 		TerminalTokens.TokenNamevoid
 	};
 	private static final int[] CLOSING_GENERICS_EXPECTEDTOKENS = new int[] {
-		TerminalTokens.TokenNameGREATER,
 		TerminalTokens.TokenNameRIGHT_SHIFT,
+		TerminalTokens.TokenNameGREATER,
 		TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT,
 	};
 //{ObjectTeams: make robust against grammar changes:	
diff --git a/org.eclipse.jdt.core/grammar/java.g b/org.eclipse.jdt.core/grammar/java.g
index c2aec49..0f78b8d 100644
--- a/org.eclipse.jdt.core/grammar/java.g
+++ b/org.eclipse.jdt.core/grammar/java.g
@@ -121,6 +121,8 @@
 	BeginLambda
 	BeginTypeArguments
 	ElidedSemicolonAndRightBrace
+	AT308
+	AT308DOTDOTDOT
 
 -- {ObjectTeams
 	BINDIN
@@ -181,6 +183,8 @@
 	'='    ::= EQUAL
 	'@'	   ::= AT
 	'...'  ::= ELLIPSIS
+	'@308' ::= AT308
+	'@308...' ::= AT308DOTDOTDOT
 	
 -- {ObjectTeams
 	'<-'   ::= BINDIN
@@ -203,8 +207,9 @@
 Goal ::= '>>' StaticInitializer
 Goal ::= '>>' Initializer
 -- error recovery
-Goal ::= '>>>' Header1 RecoveryExitHeader
-Goal ::= '!' Header2 RecoveryExitHeader
+-- Modifiersopt is used to properly consume a header and exit the rule reduction at the end of the parse() method
+Goal ::= '>>>' Header1 Modifiersopt
+Goal ::= '!' Header2 Modifiersopt
 Goal ::= '*' BlockStatements
 Goal ::= '*' CatchHeader
 -- JDOM
@@ -226,6 +231,8 @@
 -- JSR 335 Reconnaissance missions.
 Goal ::= '->' ParenthesizedLambdaParameterList
 Goal ::= '::' ReferenceExpressionTypeArgumentsAndTrunk
+-- JSR 308 Reconnaissance mission.
+Goal ::= '...' TypeAnnotations
 --{ObjectTeams new goals:
 Goal ::= ':' CallinParameterMappings
 Goal ::= ';' CalloutParameterMappings
@@ -235,10 +242,6 @@
 -- SH}
 /:$readableName Goal:/
 
-RecoveryExitHeader ::= $empty
-RecoveryExitHeader ::= '...'
-/:$readableName RecoveryExitHeader:/
-
 -- {ObjectTeams
 -- insert new Goals for Delta-Compiling
 -- for Callin/Callout-Binding
@@ -257,47 +260,19 @@
 BooleanLiteral -> false
 /:$readableName BooleanLiteral:/
 
--- Type is a wrapper that automatically allows for jsr308 style
--- annotations to prefix a (Java7) Type. If type annotations
--- are illegal in a certain place, use TypeInternal instead.
--- If type annotations are legal, but so are java7 style
--- declaration annotations, use Type0 instead.
-
-Type ::= TypeInternal
--- consumeUnannotatedType inserts 0 at the suitable place in the type
--- annotation stacks, so that the TOS(typeAnnotationsLengthStack) is the right
--- length of the type annotations 0 or otherwise.
-/.$putCase consumeUnannotatedType();  $break ./
-Type ::= TypeAnnotations TypeInternal
-/:$compliance 1.8:/
-/:$readableName Type:/
-
--- Type0 is to be used in places where type annotations are legal
--- but are not consumed as TypeAnnotations, but as modifiers. This
--- is because from the parser's point of view there are places where
--- java7 style declarations annotations can occur in the same place
--- and it is too early to tell which is which.
-Type0 ::= TypeInternal
--- consumeUnannotatedType inserts 0 at the suitable place in the type
--- annotation stacks, so that the TOS(typeAnnotationsLengthStack) is the right
--- length of the type annotations 0 or otherwise.
-/.$putCase consumeUnannotatedType();  $break ./
-/:$readableName Type:/
-
--- TypeInternal is the Java7 Type
-TypeInternal ::= PrimitiveType
+Type ::= PrimitiveType
 /.$putCase consumePrimitiveType(); $break ./
-TypeInternal -> ReferenceType0
+Type -> ReferenceType
 /:$readableName Type:/
 
-PrimitiveType -> NumericType
+PrimitiveType -> TypeAnnotationsopt NumericType
 /:$readableName PrimitiveType:/
 NumericType -> IntegralType
 NumericType -> FloatingPointType
 /:$readableName NumericType:/
 
-PrimitiveType -> 'boolean'
-PrimitiveType -> 'void'
+PrimitiveType -> TypeAnnotationsopt 'boolean'
+PrimitiveType -> TypeAnnotationsopt 'void'
 IntegralType -> 'byte'
 IntegralType -> 'short'
 IntegralType -> 'int'
@@ -308,74 +283,29 @@
 FloatingPointType -> 'double'
 /:$readableName FloatingPointType:/
 
----------------------------- JSR308-------------------------------------------
--- ReferenceType has been wrapped now, so that it can be used by itself without
--- having to spell out the rule once with Modifiers & once without.
--- If type annotations are not legal prefixes to ReferenceType at some point, use 
--- ReferenceType0 instead. Otherwise reject the annotations in the parser.
-
-ReferenceType ::= ReferenceType0
--- consumeUnannotatedType inserts 0 at the suitable place in the type
--- annotation stacks, so that the TOS(typeAnnotationsLengthStack) is the right
--- length of the type annotations 0 or otherwise.
-/.$putCase consumeUnannotatedType();  $break ./
-ReferenceType ::= Modifiers ReferenceType0
-/.$putCase consumeAnnotatedType();  $break ./
-/:$compliance 1.8:/
+ReferenceType ::= ClassOrInterfaceType
+/.$putCase consumeReferenceType(); $break ./
+ReferenceType -> ArrayType
 /:$readableName ReferenceType:/
 
-ReferenceType0 ::= ClassOrInterfaceType0
-/.$putCase consumeReferenceType();  $break ./
-ReferenceType0 -> ArrayType
-/:$readableName ReferenceType:/
-
-Annotationsopt ::= $empty
-/.$putCase consumeZeroTypeAnnotations(true); $break ./
-Annotationsopt -> TypeAnnotations
-/:$compliance 1.8:/
-/:$readableName Annotationsopt:/
-
--- ClassOrInterfaceType has now been wrapped so that it automatically includes
--- JSR308 style optional annotations. Use ClassOrInterfaceType0 if annotations
--- are illegal in some place - otherwise reject the annotations in the parser.
-ClassOrInterfaceType ::= Annotationsopt ClassOrInterfaceType0
+---------------------------------------------------------------
+-- 1.5 feature
+---------------------------------------------------------------
+ClassOrInterfaceType -> ClassOrInterface
+ClassOrInterfaceType -> GenericType
 /:$readableName Type:/
 
-ClassOrInterfaceType0 -> ClassOrInterface0
-ClassOrInterfaceType0 -> GenericType
-/:$readableName Type:/
----------------------------- JSR308-------------------------------------------
-
--- ClassOrInterface has been wrapped now so that it ALWAYS PUSHES
--- A 0 IN THE TYPE ANNOTATIONS LENGTH STACK. If this behavior is
--- not desirable, then (a) use ClassOrInterface0 if possible or (b)
--- if that is not possible due to conflicts, then this 0 will have
--- to be popped suitably when erroneous/extraneous. See the use of
--- the production PopZeroTypeAnnotations for examples.
-
-ClassOrInterface ::= ClassOrInterface0
-/.$putCase consumeZeroTypeAnnotations(true); $break ./
+ClassOrInterface ::= Name
+/.$putCase consumeClassOrInterfaceName(); $break ./
+ClassOrInterface ::= GenericType '.' Name
+/.$putCase consumeClassOrInterface(); $break ./
 /:$readableName Type:/
 
-ClassOrInterface0 ::= Name
-/.$putCase consumeClassOrInterfaceName();  $break ./
-ClassOrInterface0 ::= GenericTypeDotName
-/:$readableName Type:/
-
-PopZeroTypeAnnotations ::= $empty
-/.$putCase consumeZeroTypeAnnotations(false); $break ./
-/:$readableName PopZeroTypeAnnotations:/
-
-GenericType ::= ClassOrInterface TypeArguments PopZeroTypeAnnotations
-/.$putCase consumeGenericType();  $break ./
-/:$compliance 1.5:/
+GenericType ::= ClassOrInterface TypeArguments
+/.$putCase consumeGenericType(); $break ./
 /:$readableName GenericType:/
 
-GenericTypeDotName ::= GenericType '.' Name
-/.$putCase consumeClassOrInterface();  $break ./
-/:$readableName GenericTypeDotName:/
-
-GenericType ::= ClassOrInterface '<' '>' PopZeroTypeAnnotations
+GenericType ::= ClassOrInterface '<' '>'
 /.$putCase consumeGenericTypeWithDiamond(); $break ./
 /:$readableName GenericType:/
 /:$compliance 1.7:/
@@ -423,7 +353,8 @@
 -- ArrayType ::= ArrayType '[' ']'
 --
 
-ArrayTypeWithTypeArgumentsName ::= GenericTypeDotName
+ArrayTypeWithTypeArgumentsName ::= GenericType '.' Name
+/.$putCase consumeArrayTypeWithTypeArgumentsName(); $break ./
 /:$readableName ArrayTypeWithTypeArgumentsName:/
 
 ArrayType ::= PrimitiveType Dims
@@ -442,7 +373,10 @@
 --------------------------------------------------------------
 --------------------------------------------------------------
 
-Name -> SimpleName
+Name ::= SimpleName
+/.$putCase consumeZeroTypeAnnotations(); $break ./
+Name -> TypeAnnotations SimpleName
+/:$compliance 1.8:/
 Name -> QualifiedName
 /:$readableName Name:/
 /:$recovery_template Identifier:/
@@ -450,10 +384,78 @@
 SimpleName -> 'Identifier'
 /:$readableName SimpleName:/
 
+UnannotatableName -> SimpleName
+UnannotatableName ::= UnannotatableName '.' SimpleName
+/.$putCase consumeUnannotatableQualifiedName(); $break ./
+/:$readableName UnannotatableQualifiedName:/
+
 QualifiedName ::= Name '.' SimpleName 
-/.$putCase consumeQualifiedName(); $break ./
+/.$putCase consumeQualifiedName(false); $break ./
+QualifiedName ::= Name '.' TypeAnnotations SimpleName 
+/.$putCase consumeQualifiedName(true); $break ./
+/:$compliance 1.8:/
 /:$readableName QualifiedName:/
 
+TypeAnnotationsopt ::= $empty
+/.$putCase consumeZeroTypeAnnotations(); $break ./
+TypeAnnotationsopt -> TypeAnnotations
+/:$compliance 1.8:/
+/:$readableName TypeAnnotationsopt:/
+
+TypeAnnotations -> TypeAnnotation
+/:$compliance 1.8:/
+TypeAnnotations ::= TypeAnnotations TypeAnnotation
+/. $putCase consumeOneMoreTypeAnnotation(); $break ./
+/:$compliance 1.8:/
+/:$readableName TypeAnnotations:/
+
+TypeAnnotation ::= NormalTypeAnnotation
+/. $putCase consumeTypeAnnotation(); $break ./
+/:$compliance 1.8:/
+TypeAnnotation ::= MarkerTypeAnnotation
+/. $putCase consumeTypeAnnotation(); $break ./
+/:$compliance 1.8:/
+TypeAnnotation ::= SingleMemberTypeAnnotation
+/. $putCase consumeTypeAnnotation(); $break ./
+/:$compliance 1.8:/
+/:$readableName TypeAnnotation:/
+
+TypeAnnotationName ::= @308 UnannotatableName
+/.$putCase consumeAnnotationName() ; $break ./
+/:$readableName AnnotationName:/
+/:$compliance 1.8:/
+/:$recovery_template @ Identifier:/
+NormalTypeAnnotation ::= TypeAnnotationName '(' MemberValuePairsopt ')'
+/.$putCase consumeNormalAnnotation(true) ; $break ./
+/:$readableName NormalAnnotation:/
+/:$compliance 1.8:/
+MarkerTypeAnnotation ::= TypeAnnotationName
+/.$putCase consumeMarkerAnnotation(true) ; $break ./
+/:$readableName MarkerAnnotation:/
+/:$compliance 1.8:/
+SingleMemberTypeAnnotation ::= TypeAnnotationName '(' SingleMemberAnnotationMemberValue ')'
+/.$putCase consumeSingleMemberAnnotation(true) ; $break ./
+/:$readableName SingleMemberAnnotation:/
+/:$compliance 1.8:/
+
+RejectTypeAnnotations ::= $empty
+/.$putCase consumeNonTypeUseName(); $break ./
+/:$readableName RejectTypeAnnotations:/
+
+PushZeroTypeAnnotations ::= $empty
+/.$putCase consumeZeroTypeAnnotations(); $break ./
+/:$readableName ZeroTypeAnnotations:/
+
+VariableDeclaratorIdOrThis ::= 'this'
+/.$putCase consumeExplicitThisParameter(false); $break ./
+/:$compliance 1.8:/
+VariableDeclaratorIdOrThis ::= UnannotatableName '.' 'this'
+/.$putCase consumeExplicitThisParameter(true); $break ./
+/:$compliance 1.8:/
+VariableDeclaratorIdOrThis ::= VariableDeclaratorId
+/.$putCase consumeVariableDeclaratorIdParameter(); $break ./
+/:$readableName VariableDeclaratorId:/
+
 CompilationUnit ::= EnterCompilationUnit InternalCompilationUnit
 /.$putCase consumeCompilationUnit(); $break ./
 /:$readableName CompilationUnit:/
@@ -506,14 +508,9 @@
 /:$readableName Header1:/
 
 Header2 -> Header
-Header2 -> EnumConstantHeader RecoveryEnumConstantSeparatoropt
+Header2 -> EnumConstantHeader
 /:$readableName Header2:/
 
-RecoveryEnumConstantSeparatoropt ::= $empty
-RecoveryEnumConstantSeparatoropt ::= ','
-RecoveryEnumConstantSeparatoropt ::= ';'
-/:$readableName RecoveryEnumConstantSeparatoropt:/
-
 CatchHeader ::= 'catch' '(' CatchFormalParameter ')' '{'
 /.$putCase consumeCatchHeader(); $break ./
 /:$readableName CatchHeader:/
@@ -532,13 +529,13 @@
 /.$putCase consumePackageDeclaration(); $break ./
 /:$readableName PackageDeclaration:/
 
-PackageDeclarationName ::= Modifiers 'package' PushRealModifiers Name
+PackageDeclarationName ::= Modifiers 'package' PushRealModifiers Name RejectTypeAnnotations
 /.$putCase consumePackageDeclarationNameWithModifiers(); $break ./
 /:$readableName PackageDeclarationName:/
 /:$compliance 1.5:/
 
-PackageDeclarationName ::= PackageComment 'package' Name
-/.$putCase  consumePackageDeclarationName(); $break ./
+PackageDeclarationName ::= PackageComment 'package' Name RejectTypeAnnotations
+/.$putCase consumePackageDeclarationName(); $break ./
 /:$readableName PackageDeclarationName:/
 
 PackageComment ::= $empty
@@ -561,14 +558,14 @@
 /.$putCase consumeImportDeclaration(); $break ./
 /:$readableName SingleTypeImportDeclaration:/
 
--- {ObjectTeams: special case: allow 'team' in imported package/type name:			  
--- orig: SingleTypeImportDeclarationName ::= 'import' Name
+-- {ObjectTeams: special case: allow 'team' in imported package/type name:
+-- orig: SingleTypeImportDeclarationName ::= 'import' Name RejectTypeAnnotations
 SingleTypeImportDeclarationName ::= 'import' ImportName
 /.$putCase consumeSingleTypeImportDeclarationName(); $break ./
 /:$readableName SingleTypeImportDeclarationName:/
 
-ImportName -> Name
-ImportName ::= Name '.' 'team' '.' Name
+ImportName -> Name RejectTypeAnnotations
+ImportName ::= Name RejectTypeAnnotations '.' 'team' '.' Name RejectTypeAnnotations
 /.$putCase consumeNameContainingTeam(); $break ./
 /:$readableName Name:/
 -- SH}			  
@@ -577,7 +574,7 @@
 /.$putCase consumeImportDeclaration(); $break ./
 /:$readableName TypeImportOnDemandDeclaration:/
 
-TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*'
+TypeImportOnDemandDeclarationName ::= 'import' Name '.' RejectTypeAnnotations '*'
 /.$putCase consumeTypeImportOnDemandDeclarationName(); $break ./
 /:$readableName TypeImportOnDemandDeclarationName:/
 
@@ -786,7 +783,7 @@
 --    | 'transient'
 --    | 'volatile'
 
-FieldDeclaration ::= Modifiersopt Type0 VariableDeclarators ';'
+FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
 /.$putCase consumeFieldDeclaration(); $break ./
 /:$readableName FieldDeclaration:/
 
@@ -820,16 +817,6 @@
 /.$putCase consumeRestoreDiet(); $break ./
 /:$readableName RestoreDiet:/
 
-VariableDeclaratorIdOrThis ::= 'this'
-/.$putCase consumeExplicitThisParameter(false); $break ./
-/:$compliance 1.8:/
-VariableDeclaratorIdOrThis ::= Name '.' 'this'
-/.$putCase consumeExplicitThisParameter(true); $break ./
-/:$compliance 1.8:/
-VariableDeclaratorIdOrThis ::= VariableDeclaratorId
-/.$putCase consumeVariableDeclaratorIdParameter(); $break ./
-/:$readableName VariableDeclaratorId:/
-
 VariableDeclaratorId ::= 'Identifier' Dimsopt
 /:$readableName VariableDeclaratorId:/
 /:$recovery_template Identifier:/
@@ -868,7 +855,7 @@
 
 MethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
 /.$putCase consumeMethodHeaderNameWithTypeParameters(false); $break ./
-MethodHeaderName ::= Modifiersopt Type0 'Identifier' '('
+MethodHeaderName ::= Modifiersopt Type 'Identifier' '('
 /.$putCase consumeMethodHeaderName(false); $break ./
 /:$readableName MethodHeaderName:/
 
@@ -905,39 +892,20 @@
 /:$readableName PotentialNameArray:/
 
 --1.1 feature
---FormalParameter ::= Modifiersopt Type VariableDeclaratorId
---FormalParameter ::= Modifiersopt Type '...' VariableDeclaratorId
---The above rules have been rewritten by inlinng the type subgrammar
---to avoid the conflicts resulting from jsr308 changes.
-FormalParameter ::= Modifiersopt PrimitiveType DimsoptAnnotsopt VariableDeclaratorIdOrThis
+FormalParameter ::= Modifiersopt Type VariableDeclaratorIdOrThis
 /.$putCase consumeFormalParameter(false); $break ./
-FormalParameter ::= Modifiersopt PrimitiveType DimsoptAnnotsopt '...' VariableDeclaratorIdOrThis
+FormalParameter ::= Modifiersopt Type PushZeroTypeAnnotations '...' VariableDeclaratorIdOrThis
 /.$putCase consumeFormalParameter(true); $break ./
 /:$compliance 1.5:/
---{ObjectTeams: inserted LiftingTypeopt:
+--{ObjectTeams: inserted LiftingTypeopt: FIXME
+-- example:
 FormalParameter ::= Modifiersopt Name DimsoptAnnotsopt LiftingTypeopt PotentialNameArray VariableDeclaratorIdOrThis
 /.$putCase consumeFormalParameter(false); $break ./
-FormalParameter ::= Modifiersopt Name DimsoptAnnotsopt LiftingTypeopt PotentialNameArray '...' VariableDeclaratorIdOrThis
-/.$putCase consumeFormalParameter(true); $break ./
-/:$compliance 1.5:/
---{ObjectTeams: 
-FormalParameter ::= Modifiersopt BaseAnchoredType DimsoptAnnotsopt LiftingTypeopt PotentialNameArray VariableDeclaratorIdOrThis
-/.$putCase consumeFormalParameter(false); $break ./
-FormalParameter ::= Modifiersopt BaseAnchoredType DimsoptAnnotsopt LiftingTypeopt PotentialNameArray '...' VariableDeclaratorIdOrThis
-/.$putCase consumeFormalParameter(true); $break ./
-/:$compliance 1.5:/
--- SH}
-FormalParameter ::= Modifiersopt GenericType DimsoptAnnotsopt LiftingTypeopt VariableDeclaratorIdOrThis
-/.$putCase consumeFormalParameter(false); $break ./
-FormalParameter ::= Modifiersopt GenericType DimsoptAnnotsopt LiftingTypeopt '...' VariableDeclaratorIdOrThis
-/.$putCase consumeFormalParameter(true); $break ./
-/:$compliance 1.5:/
-FormalParameter ::= Modifiersopt GenericTypeDotName DimsoptAnnotsopt LiftingTypeopt VariableDeclaratorIdOrThis
-/.$putCase consumeFormalParameter(false); $break ./
-FormalParameter ::= Modifiersopt GenericTypeDotName DimsoptAnnotsopt LiftingTypeopt '...' VariableDeclaratorIdOrThis
+-- real:
+FormalParameter ::= Modifiersopt Type @308... TypeAnnotations '...' VariableDeclaratorIdOrThis
 /.$putCase consumeFormalParameter(true); $break ./
 /:$readableName FormalParameter:/
-/:$compliance 1.5:/
+/:$compliance 1.8:/
 /:$recovery_template Identifier Identifier:/
 -- SH}
 CatchFormalParameter ::= Modifiersopt CatchType CatchLiftingTypeopt VariableDeclaratorId
@@ -949,7 +917,7 @@
 /.$putCase consumeCatchType(); $break ./
 /:$readableName CatchType:/
 
-UnionType ::= Type0
+UnionType ::= Type
 /.$putCase consumeUnionTypeAsClassType(); $break ./
 UnionType ::= UnionType '|' Type
 /.$putCase consumeUnionType(); $break ./
@@ -1240,7 +1208,7 @@
 
 --18.8.4 Productions from 8.5: Static Initializers
 
-StaticInitializer ::=  StaticOnly Block
+StaticInitializer ::= StaticOnly Block
 /.$putCase consumeStaticInitializer(); $break./
 /:$readableName StaticInitializer:/
 
@@ -1405,6 +1373,7 @@
 InvalidInitializer -> Initializer
 /:$readableName InvalidInitializer:/
 
+
 InterfaceMemberDeclaration -> AbstractMethodDeclaration
 InterfaceMemberDeclaration -> InvalidConstructorDeclaration
 InterfaceMemberDeclaration -> InvalidInitializer
@@ -1471,13 +1440,13 @@
 /.$putCase consumeLocalVariableDeclarationStatement(); $break ./
 /:$readableName LocalVariableDeclarationStatement:/
 
-LocalVariableDeclaration ::= Type0 PushModifiers VariableDeclarators
+LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators
 /.$putCase consumeLocalVariableDeclaration(); $break ./
 -- 1.1 feature
 -- The modifiers part of this rule makes the grammar more permissive. 
 -- The only modifier here is final. We put Modifiers to allow multiple modifiers
 -- This will require to check the validity of the modifier
-LocalVariableDeclaration ::= Modifiers Type0 PushRealModifiers VariableDeclarators
+LocalVariableDeclaration ::= Modifiers Type PushRealModifiers VariableDeclarators
 /.$putCase consumeLocalVariableDeclaration(); $break ./
 /:$readableName LocalVariableDeclaration:/
 
@@ -1548,7 +1517,7 @@
 /:$readableName LabeledStatement:/
 
 Label ::= 'Identifier'
-/.$putCase consumeLabel(); $break ./
+/.$putCase consumeLabel() ; $break ./
 /:$readableName Label:/
 
 ExpressionStatement ::= StatementExpression ';'
@@ -1702,7 +1671,6 @@
 
 TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt
 /.$putCase consumeStatementTry(false, true); $break ./
-/:$compliance 1.7:/
 TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt Finally
 /.$putCase consumeStatementTry(true, true); $break ./
 /:$readableName TryStatementWithResources:/
@@ -1715,7 +1683,6 @@
 
 ;opt ::= $empty
 /.$putCase consumeResourceOptionalTrailingSemiColon(false); $break ./
-/:$compliance 1.7:/
 ;opt ::= ';'
 /.$putCase consumeResourceOptionalTrailingSemiColon(true); $break ./
 /:$readableName ;:/
@@ -1723,7 +1690,6 @@
 
 Resources ::= Resource
 /.$putCase consumeSingleResource(); $break ./
-/:$compliance 1.7:/
 Resources ::= Resources TrailingSemiColon Resource
 /.$putCase consumeMultipleResources(); $break ./
 /:$readableName Resources:/
@@ -1734,12 +1700,12 @@
 /:$readableName ;:/
 /:$compliance 1.7:/
 
-Resource ::= Type0 PushModifiers VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
+Resource ::= Type PushModifiers VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
 /.$putCase consumeResourceAsLocalVariableDeclaration(); $break ./
 /:$readableName Resource:/
 /:$compliance 1.7:/
 
-Resource ::= Modifiers Type0 PushRealModifiers VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
+Resource ::= Modifiers Type PushRealModifiers VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
 /.$putCase consumeResourceAsLocalVariableDeclaration(); $break ./
 /:$readableName Resource:/
 /:$compliance 1.7:/
@@ -1760,7 +1726,7 @@
 /.$putCase consumeStatementCatch() ; $break ./
 /:$readableName CatchClause:/
 
-Finally ::= 'finally'    Block
+Finally ::= 'finally' Block
 /:$readableName Finally:/
 /:$recovery_template finally { }:/
 
@@ -1771,27 +1737,10 @@
 /.$putCase consumeLeftParen(); $break ./
 /:$readableName (:/
 /:$recovery_template (:/
-PushRPARENForUnannotatedTypeCast ::= ')'
-/.$putCase consumeRightParenForUnannotatedTypeCast(); $break ./
-/:$readableName ):/
-/:$recovery_template ):/
-PushRPARENForNameUnannotatedTypeCast ::=  ')'
-/.$putCase consumeRightParenForNameUnannotatedTypeCast(); $break ./
-/:$readableName ):/
-/:$recovery_template ):/
 PushRPAREN ::= ')'
 /.$putCase consumeRightParen(); $break ./
 /:$readableName ):/
 /:$recovery_template ):/
-PushRPARENForAnnotatedTypeCast ::= ')'
-/.$putCase consumeRightParenForAnnotatedTypeCast(); $break ./
-/:$readableName ):/
-/:$recovery_template ):/
-
-PushRPARENForNameAndAnnotatedTypeCast ::= ')'
-/.$putCase consumeRightParenForNameAndAnnotatedTypeCast(); $break ./
-/:$readableName ):/
-/:$recovery_template ):/
 
 Primary -> PrimaryNoNewArray
 Primary -> ArrayCreationWithArrayInitializer
@@ -1814,7 +1763,6 @@
 -- SH}
 PrimaryNoNewArray -> FieldAccess
 --1.1 feature
--- javac doesn't permit type annotations here.
 PrimaryNoNewArray ::= Name '.' 'this'
 /.$putCase consumePrimaryNoNewArrayNameThis(); $break ./
 PrimaryNoNewArray ::= Name '.' 'super'
@@ -1857,42 +1805,26 @@
 ReferenceExpressionTypeArgumentsAndTrunk ::= OnlyTypeArguments Dimsopt 
 /.$putCase consumeReferenceExpressionTypeArgumentsAndTrunk(false); $break ./
 /:$compliance 1.8:/
-ReferenceExpressionTypeArgumentsAndTrunk ::= OnlyTypeArguments '.' ClassOrInterfaceType0 Dimsopt 
+ReferenceExpressionTypeArgumentsAndTrunk ::= OnlyTypeArguments '.' ClassOrInterfaceType Dimsopt 
 /.$putCase consumeReferenceExpressionTypeArgumentsAndTrunk(true); $break ./
 /:$readableName ReferenceExpressionTypeArgumentsAndTrunk:/
 /:$compliance 1.8:/
 
-ReferenceExpression ::= PrimitiveType Dims PushModifiers '::' NonWildTypeArgumentsopt IdentifierOrNew
+ReferenceExpression ::= PrimitiveType Dims '::' NonWildTypeArgumentsopt IdentifierOrNew
 /.$putCase consumeReferenceExpressionTypeForm(true, true); $break ./
 /:$compliance 1.8:/
 
-ReferenceExpression ::= Modifiers PrimitiveType Dims PushRealModifiers '::' NonWildTypeArgumentsopt IdentifierOrNew
-/.$putCase consumeReferenceExpressionTypeForm(true, true); $break ./
-/:$compliance 1.8:/
-
-ReferenceExpression ::= Name Dims PushModifiers '::' NonWildTypeArgumentsopt IdentifierOrNew
+ReferenceExpression ::= Name Dims '::' NonWildTypeArgumentsopt IdentifierOrNew
 /.$putCase consumeReferenceExpressionTypeForm(false, true); $break ./
 /:$compliance 1.8:/
 
-ReferenceExpression ::= Modifiers Name Dims PushRealModifiers '::' NonWildTypeArgumentsopt IdentifierOrNew
-/.$putCase consumeReferenceExpressionTypeForm(false, true); $break ./
-/:$compliance 1.8:/
-
-ReferenceExpression ::= Modifiers Name PushRealModifiers '::' NonWildTypeArgumentsopt IdentifierOrNew
-/.$putCase consumeReferenceExpressionTypeForm(false, false); $break ./
-/:$compliance 1.8:/
-
 ReferenceExpression ::= Name '::' NonWildTypeArgumentsopt IdentifierOrNew
-/.$putCase consumeReferenceExpressionNameForm(); $break ./
+/.$putCase consumeReferenceExpressionTypeForm(false, false); $break ./
 /:$compliance 1.8:/
 
 -- BeginTypeArguments is a synthetic token the scanner concocts to help disambiguate
 -- between '<' as an operator and '<' in '<' TypeArguments '>'
-ReferenceExpression ::= Name PushModifiers BeginTypeArguments ReferenceExpressionTypeArgumentsAndTrunk '::' NonWildTypeArgumentsopt IdentifierOrNew
-/.$putCase consumeReferenceExpressionGenericTypeForm(); $break ./
-/:$compliance 1.8:/
-
-ReferenceExpression ::= Modifiers Name PushRealModifiers BeginTypeArguments ReferenceExpressionTypeArgumentsAndTrunk '::' NonWildTypeArgumentsopt IdentifierOrNew
+ReferenceExpression ::= Name BeginTypeArguments ReferenceExpressionTypeArgumentsAndTrunk '::' NonWildTypeArgumentsopt IdentifierOrNew
 /.$putCase consumeReferenceExpressionGenericTypeForm(); $break ./
 /:$compliance 1.8:/
 
@@ -2032,18 +1964,18 @@
 /.$putCase consumeArgumentList(); $break ./
 /:$readableName ArgumentList:/
 
--- ArrayCreationHeader is used only in recovery and the consume* method is a NOP.
-ArrayCreationHeader ::= 'new' Annotationsopt PrimitiveType DimWithOrWithOutExprs
+ArrayCreationHeader ::= 'new' PrimitiveType DimWithOrWithOutExprs
 /.$putCase consumeArrayCreationHeader(); $break ./
+
 ArrayCreationHeader ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
 /.$putCase consumeArrayCreationHeader(); $break ./
 /:$readableName ArrayCreationHeader:/
 
-ArrayCreationWithoutArrayInitializer ::= 'new' Annotationsopt PrimitiveType DimWithOrWithOutExprs
+ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
 /.$putCase consumeArrayCreationExpressionWithoutInitializer(); $break ./
 /:$readableName ArrayCreationWithoutArrayInitializer:/
 
-ArrayCreationWithArrayInitializer ::= 'new' Annotationsopt PrimitiveType DimWithOrWithOutExprs ArrayInitializer
+ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
 /.$putCase consumeArrayCreationExpressionWithInitializer(); $break ./
 /:$readableName ArrayCreationWithArrayInitializer:/
 
@@ -2058,46 +1990,12 @@
 /.$putCase consumeDimWithOrWithOutExprs(); $break ./
 /:$readableName Dimensions:/
 
-DimWithOrWithOutExpr ::= '[' PushZeroTypeAnnotations Expression ']'
-DimWithOrWithOutExpr ::= TypeAnnotations '[' Expression ']'
-/:$compliance 1.8:/
-DimWithOrWithOutExpr ::= '[' PushZeroTypeAnnotations ']'
+DimWithOrWithOutExpr ::= TypeAnnotationsopt '[' Expression ']'
+DimWithOrWithOutExpr ::= TypeAnnotationsopt '[' ']'
 /. $putCase consumeDimWithOrWithOutExpr(); $break ./
-DimWithOrWithOutExpr ::= TypeAnnotations '[' ']'
-/. $putCase consumeDimWithOrWithOutExpr(); $break ./
-/:$compliance 1.8:/
 /:$readableName Dimension:/
 -- -----------------------------------------------
 
--- jsr 308
-
-DimsoptAnnotsopt -> $empty
-/. $putCase consumeEmptyDimsoptAnnotsopt(); $break ./
-/:$readableName AnnotationsDimensionsSequence:/
-DimsoptAnnotsopt -> DimsAnnotLoop
-/. $putCase consumeDimsWithTrailingAnnotsopt(); $break ./
-/:$readableName Dimensionsoptannotsopt:/
-DimsAnnotLoop ::= OneDimOrAnnot
-DimsAnnotLoop ::= DimsAnnotLoop OneDimOrAnnot
-/:$readableName DimsAnnotLoop:/
-
-OneDimOrAnnot ::= Annotation
-/. $putCase consumeTypeAnnotation(true); $break ./
--- Complain if source level < 1.8
-/:$compliance 1.8:/
-OneDimOrAnnot -> '[' ']'
-/. $putCase consumeOneDimLoop(true); $break ./
--- Bump up dimensions && mark zero annotations.
-/:$readableName OneDimensionOrAnnotation:/
-
-TypeAnnotations ::= Annotation
-/. $putCase consumeTypeAnnotation(false); $break ./
-/:$compliance 1.8:/
-TypeAnnotations ::= TypeAnnotations Annotation
-/. $putCase consumeOneMoreTypeAnnotation(); $break ./
-/:$compliance 1.8:/
-/:$readableName TypeAnnotations:/
-
 Dims ::= DimsLoop
 /. $putCase consumeDims(); $break ./
 /:$readableName Dimensions:/
@@ -2106,13 +2004,10 @@
 /:$readableName Dimensions:/
 OneDimLoop ::= '[' ']'
 /. $putCase consumeOneDimLoop(false); $break ./
--- Bump up dimensions && mark zero annotations.
-/:$readableName Dimension:/
 OneDimLoop ::= TypeAnnotations '[' ']'
 /:$compliance 1.8:/
-/. $putCase consumeOneDimLoopWithAnnotations(); $break ./
--- Bump up dimensions
-/:$readableName DimensionWithAnnotations:/
+/. $putCase consumeOneDimLoop(true); $break ./
+/:$readableName Dimension:/
 
 FieldAccess ::= Primary '.' 'Identifier'
 /.$putCase consumeFieldAccess(false); $break ./
@@ -2220,31 +2115,16 @@
 UnaryExpressionNotPlusMinus -> CastExpression
 /:$readableName Expression:/
 
-CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPARENForUnannotatedTypeCast InsideCastExpression UnaryExpression
+CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression UnaryExpression
 /.$putCase consumeCastExpressionWithPrimitiveType(); $break ./
-CastExpression ::= PushLPAREN Modifiers PrimitiveType Dimsopt PushRPARENForAnnotatedTypeCast InsideCastExpression UnaryExpression
-/:$compliance 1.8:/
-/.$putCase consumeCastExpressionWithPrimitiveTypeWithTypeAnnotations(); $break ./
-CastExpression ::= PushLPAREN Name OnlyTypeArgumentsForCastExpression Dimsopt PushRPARENForUnannotatedTypeCast InsideCastExpression UnaryExpressionNotPlusMinus
+CastExpression ::= PushLPAREN Name OnlyTypeArgumentsForCastExpression Dimsopt PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
 /.$putCase consumeCastExpressionWithGenericsArray(); $break ./
-CastExpression ::= PushLPAREN Modifiers Name OnlyTypeArgumentsForCastExpression Dimsopt PushRPARENForAnnotatedTypeCast InsideCastExpression UnaryExpressionNotPlusMinus
-/:$compliance 1.8:/
-/.$putCase consumeCastExpressionWithGenericsArrayWithTypeAnnotations(); $break ./
-CastExpression ::= PushLPAREN Name OnlyTypeArgumentsForCastExpression '.' ClassOrInterfaceType0 Dimsopt PushRPARENForUnannotatedTypeCast InsideCastExpressionWithQualifiedGenerics UnaryExpressionNotPlusMinus
+CastExpression ::= PushLPAREN Name OnlyTypeArgumentsForCastExpression '.' ClassOrInterfaceType Dimsopt PushRPAREN InsideCastExpressionWithQualifiedGenerics UnaryExpressionNotPlusMinus
 /.$putCase consumeCastExpressionWithQualifiedGenericsArray(); $break ./
-CastExpression ::= PushLPAREN Modifiers Name OnlyTypeArgumentsForCastExpression '.' ClassOrInterfaceType0 Dimsopt PushRPARENForAnnotatedTypeCast InsideCastExpressionWithAnnotatedQualifiedGenerics UnaryExpressionNotPlusMinus
-/:$compliance 1.8:/
-/.$putCase consumeCastExpressionWithQualifiedGenericsArrayWithTypeAnnotations(); $break ./
-CastExpression ::= PushLPAREN Name PushRPARENForNameUnannotatedTypeCast InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
+CastExpression ::= PushLPAREN Name PushRPAREN InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
 /.$putCase consumeCastExpressionLL1(); $break ./
-CastExpression ::= PushLPAREN Modifiers Name PushRPARENForNameAndAnnotatedTypeCast InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
-/:$compliance 1.8:/
-/.$putCase consumeCastExpressionLL1WithTypeAnnotations(); $break ./
-CastExpression ::= PushLPAREN Name Dims PushRPARENForUnannotatedTypeCast InsideCastExpression UnaryExpressionNotPlusMinus
+CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
 /.$putCase consumeCastExpressionWithNameArray(); $break ./
-CastExpression ::= PushLPAREN Modifiers Name Dims PushRPARENForAnnotatedTypeCast InsideCastExpression UnaryExpressionNotPlusMinus
-/:$compliance 1.8:/
-/.$putCase consumeCastExpressionWithNameArrayWithTypeAnnotations(); $break ./
 /:$readableName CastExpression:/
 
 OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments
@@ -2261,10 +2141,6 @@
 /.$putCase consumeInsideCastExpressionWithQualifiedGenerics(); $break ./
 /:$readableName InsideCastExpression:/
 
-InsideCastExpressionWithAnnotatedQualifiedGenerics ::= $empty
-/.$putCase consumeInsideCastExpressionWithAnnotatedQualifiedGenerics(); $break ./
-/:$readableName InsideCastExpression:/
-
 MultiplicativeExpression -> UnaryExpression
 MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression
 /.$putCase consumeBinaryExpression(OperatorIds.MULTIPLY); $break ./
@@ -2570,11 +2446,11 @@
 /.$putCase consumeEnhancedForStatement(); $break ./
 /:$readableName EnhancedForStatementNoShortIf:/
 
-EnhancedForStatementHeaderInit ::= 'for' '(' Type0 PushModifiers Identifier Dimsopt
+EnhancedForStatementHeaderInit ::= 'for' '(' Type PushModifiers Identifier Dimsopt
 /.$putCase consumeEnhancedForStatementHeaderInit(false); $break ./
 /:$readableName EnhancedForStatementHeaderInit:/
 
-EnhancedForStatementHeaderInit ::= 'for' '(' Modifiers Type0 PushRealModifiers Identifier Dimsopt
+EnhancedForStatementHeaderInit ::= 'for' '(' Modifiers Type PushRealModifiers Identifier Dimsopt
 /.$putCase consumeEnhancedForStatementHeaderInit(true); $break ./
 /:$readableName EnhancedForStatementHeaderInit:/
 
@@ -2599,7 +2475,7 @@
 /.$putCase consumeImportDeclaration(); $break ./
 /:$readableName SingleStaticImportDeclaration:/
 
-SingleStaticImportDeclarationName ::= 'import' 'static' Name
+SingleStaticImportDeclarationName ::= 'import' 'static' Name RejectTypeAnnotations
 /.$putCase consumeSingleStaticImportDeclarationName(); $break ./
 /:$readableName SingleStaticImportDeclarationName:/
 /:$compliance 1.5:/
@@ -2608,7 +2484,7 @@
 /.$putCase consumeImportDeclaration(); $break ./
 /:$readableName StaticImportOnDemandDeclaration:/
 
-StaticImportOnDemandDeclarationName ::= 'import' 'static' Name '.' '*'
+StaticImportOnDemandDeclarationName ::= 'import' 'static' Name '.' RejectTypeAnnotations '*'
 /.$putCase consumeStaticImportOnDemandDeclarationName(); $break ./
 /:$readableName StaticImportOnDemandDeclarationName:/
 /:$compliance 1.5:/
@@ -2683,11 +2559,8 @@
 /:$compliance 1.5:/
 ReferenceType1 ::= ClassOrInterface '<' TypeArgumentList2
 /.$putCase consumeTypeArgumentReferenceType1(); $break ./
-/:$compliance 1.5:/
-ReferenceType1 ::= Modifiers ClassOrInterface '<' TypeArgumentList2
-/:$compliance 1.8:/
-/.$putCase consumeTypeArgumentReferenceType1WithTypeAnnotations(); $break ./
 /:$readableName ReferenceType1:/
+/:$compliance 1.5:/
 
 TypeArgumentList2 -> TypeArgument2
 /:$compliance 1.5:/
@@ -2707,11 +2580,8 @@
 /:$compliance 1.5:/
 ReferenceType2 ::= ClassOrInterface '<' TypeArgumentList3
 /.$putCase consumeTypeArgumentReferenceType2(); $break ./
-/:$compliance 1.5:/
-ReferenceType2 ::= Modifiers ClassOrInterface '<' TypeArgumentList3
-/:$compliance 1.8:/
-/.$putCase consumeTypeArgumentReferenceType2WithTypeAnnotations(); $break ./
 /:$readableName ReferenceType2:/
+/:$compliance 1.5:/
 
 TypeArgumentList3 -> TypeArgument3
 TypeArgumentList3 ::= TypeArgumentList ',' TypeArgument3
@@ -2729,10 +2599,10 @@
 /:$readableName ReferenceType3:/
 /:$compliance 1.5:/
 
-Wildcard ::= '?'
+Wildcard ::= TypeAnnotationsopt '?'
 /.$putCase consumeWildcard(); $break ./
 /:$compliance 1.5:/
-Wildcard ::= '?' WildcardBounds
+Wildcard ::= TypeAnnotationsopt '?' WildcardBounds
 /.$putCase consumeWildcardWithBounds(); $break ./
 /:$readableName Wildcard:/
 /:$compliance 1.5:/
@@ -2745,10 +2615,10 @@
 /:$readableName WildcardBounds:/
 /:$compliance 1.5:/
 
-Wildcard1 ::= '?' '>'
+Wildcard1 ::= TypeAnnotationsopt '?' '>'
 /.$putCase consumeWildcard1(); $break ./
 /:$compliance 1.5:/
-Wildcard1 ::= '?' WildcardBounds1
+Wildcard1 ::= TypeAnnotationsopt '?' WildcardBounds1
 /.$putCase consumeWildcard1WithBounds(); $break ./
 /:$readableName Wildcard1:/
 /:$compliance 1.5:/
@@ -2761,10 +2631,10 @@
 /:$readableName WildcardBounds1:/
 /:$compliance 1.5:/
 
-Wildcard2 ::= '?' '>>'
+Wildcard2 ::= TypeAnnotationsopt '?' '>>'
 /.$putCase consumeWildcard2(); $break ./
 /:$compliance 1.5:/
-Wildcard2 ::= '?' WildcardBounds2
+Wildcard2 ::= TypeAnnotationsopt '?' WildcardBounds2
 /.$putCase consumeWildcard2WithBounds(); $break ./
 /:$readableName Wildcard2:/
 /:$compliance 1.5:/
@@ -2777,10 +2647,10 @@
 /:$readableName WildcardBounds2:/
 /:$compliance 1.5:/
 
-Wildcard3 ::= '?' '>>>'
+Wildcard3 ::= TypeAnnotationsopt '?' '>>>'
 /.$putCase consumeWildcard3(); $break ./
 /:$compliance 1.5:/
-Wildcard3 ::= '?' WildcardBounds3
+Wildcard3 ::= TypeAnnotationsopt '?' WildcardBounds3
 /.$putCase consumeWildcard3WithBounds(); $break ./
 /:$readableName Wildcard3:/
 /:$compliance 1.5:/
@@ -2793,17 +2663,10 @@
 /:$readableName WildcardBound3:/
 /:$compliance 1.5:/
 
-PushZeroTypeAnnotations ::= $empty
-/.$putCase consumeZeroTypeAnnotations(true); $break ./
-/:$readableName ZeroTypeAnnotations:/
-
-TypeParameterHeader ::= PushZeroTypeAnnotations Identifier
-/.$putCase consumeTypeParameterHeader(); $break ./
-/:$compliance 1.5:/
-TypeParameterHeader ::= TypeAnnotations Identifier
-/:$compliance 1.8:/
+TypeParameterHeader ::= TypeAnnotationsopt Identifier
 /.$putCase consumeTypeParameterHeader(); $break ./
 /:$readableName TypeParameter:/
+/:$compliance 1.5:/
 
 TypeParameters ::= '<' TypeParameterList1
 /.$putCase consumeTypeParameters(); $break ./
@@ -3116,7 +2979,7 @@
 
 AnnotationMethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
 /.$putCase consumeMethodHeaderNameWithTypeParameters(true); $break ./
-AnnotationMethodHeaderName ::= Modifiersopt Type0 'Identifier' '('
+AnnotationMethodHeaderName ::= Modifiersopt Type 'Identifier' '('
 /.$putCase consumeMethodHeaderName(true); $break ./
 /:$readableName MethodHeaderName:/
 /:$compliance 1.5:/
@@ -3158,14 +3021,14 @@
 /:$readableName Annotation:/
 /:$compliance 1.5:/
 
-AnnotationName ::= '@' Name
+AnnotationName ::= '@' UnannotatableName
 /.$putCase consumeAnnotationName() ; $break ./
 /:$readableName AnnotationName:/
 /:$compliance 1.5:/
 /:$recovery_template @ Identifier:/
 
 NormalAnnotation ::= AnnotationName '(' MemberValuePairsopt ')'
-/.$putCase consumeNormalAnnotation() ; $break ./
+/.$putCase consumeNormalAnnotation(false) ; $break ./
 /:$readableName NormalAnnotation:/
 /:$compliance 1.5:/
 
@@ -3237,7 +3100,7 @@
 /:$compliance 1.5:/
 
 MarkerAnnotation ::= AnnotationName
-/.$putCase consumeMarkerAnnotation() ; $break ./
+/.$putCase consumeMarkerAnnotation(false) ; $break ./
 /:$readableName MarkerAnnotation:/
 /:$compliance 1.5:/
 
@@ -3247,7 +3110,7 @@
 /:$compliance 1.5:/
 
 SingleMemberAnnotation ::= AnnotationName '(' SingleMemberAnnotationMemberValue ')'
-/.$putCase consumeSingleMemberAnnotation() ; $break ./
+/.$putCase consumeSingleMemberAnnotation(false) ; $break ./
 /:$readableName SingleMemberAnnotation:/
 /:$compliance 1.5:/
 --------------------------------------
@@ -3260,7 +3123,7 @@
 RecoveryMethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
 /.$putCase consumeRecoveryMethodHeaderNameWithTypeParameters(); $break ./
 /:$compliance 1.5:/
-RecoveryMethodHeaderName ::= Modifiersopt Type0 'Identifier' '('
+RecoveryMethodHeaderName ::= Modifiersopt Type 'Identifier' '('
 /.$putCase consumeRecoveryMethodHeaderName(); $break ./
 /:$readableName MethodHeaderName:/
 
@@ -3378,7 +3241,9 @@
 COMMA ::=    ','    
 DOT ::=    '.'    
 EQUAL ::=    '='    
-AT ::=    '@'    
+AT ::=    '@'
+AT308 ::= '@'
+AT308DOTDOTDOT ::= '@'
 ELLIPSIS ::=    '...'    
 ARROW ::= '->'
 COLON_COLON ::= '::'
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/DocumentElementParser.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/DocumentElementParser.java
index 63d23c4..1049a82 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/DocumentElementParser.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/DocumentElementParser.java
@@ -26,7 +26,6 @@
 
 public class DocumentElementParser extends Parser {
 	IDocumentElementRequestor requestor;
-	private int localIntPtr;
 	private int lastFieldEndPosition;
 	private int lastFieldBodyEndPosition;
 	private int typeStartPosition;
@@ -515,8 +514,6 @@
 		}
 	}
 
-	this.localIntPtr = this.intPtr;
-
 	if (extendedTypeDimension == 0) {
 		declaration.type = type;
 	} else {
@@ -586,6 +583,7 @@
 			localDeclaration.annotations = new Annotation[length],
 			0,
 			length);
+		localDeclaration.bits |= ASTNode.HasTypeAnnotations;
 	}
 	if (hasModifiers) {
 		localDeclaration.declarationSourceStart = declarationSourceStart1;
@@ -595,7 +593,7 @@
 		localDeclaration.declarationSourceStart = type.sourceStart;
 	}
 	localDeclaration.type = type;
-
+	localDeclaration.bits |= (type.bits & ASTNode.HasTypeAnnotations);
 	ForeachStatement iteratorForStatement =
 		new ForeachStatement(
 			localDeclaration,
@@ -622,7 +620,8 @@
 	this.identifierLengthPtr--;
 	//type
 	md.returnType = getTypeReference(this.intStack[this.intPtr--]);
-
+	rejectIllegalLeadingTypeAnnotations(md.returnType);
+	md.bits |= (md.returnType.bits & ASTNode.HasTypeAnnotations);
 	// consume type parameters
 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
 	this.genericsPtr -= length;
@@ -731,31 +730,35 @@
 	char[] parameterName = this.identifierStack[this.identifierPtr];
 	long namePositions = this.identifierPositionStack[this.identifierPtr--];
 	int extendedDimensions = this.intStack[this.intPtr--];
+	Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : getAnnotationsOnDimensions(extendedDimensions);
 	int endOfEllipsis = 0;
+	int length;
+	Annotation [] varArgsAnnotations = null;
 	if (isVarArgs) {
 		endOfEllipsis = this.intStack[this.intPtr--];
+		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
+			System.arraycopy(
+				this.typeAnnotationStack,
+				(this.typeAnnotationPtr -= length) + 1,
+				varArgsAnnotations = new Annotation[length],
+				0,
+				length);
+		} 
 	}
 	int firstDimensions = this.intStack[this.intPtr--];
-	TypeReference type = getUnannotatedTypeReference(extendedDimensions);
-	Annotation [] varArgsAnnotations = null;
-	int length;
-	if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
-		System.arraycopy(
-			this.typeAnnotationStack,
-			(this.typeAnnotationPtr -= length) + 1,
-			varArgsAnnotations = new Annotation[length],
-			0,
-			length);
-	} 
+	TypeReference type = getTypeReference(firstDimensions);
+
 	final int typeDimensions = firstDimensions + extendedDimensions + (isVarArgs ? 1 : 0);
-	if (typeDimensions != extendedDimensions) {
+	if (typeDimensions != firstDimensions) {
 		// jsr308 type annotations management
-		Annotation [][] annotationsOnFirstDimensions = firstDimensions == 0 ? null : getAnnotationsOnDimensions(firstDimensions);
-		Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : type.getAnnotationsOnDimensions();
-		Annotation [][] annotationsOnAllDimensions = null;
-		if (annotationsOnFirstDimensions != null || annotationsOnExtendedDimensions != null || varArgsAnnotations != null) {
+		Annotation [][] annotationsOnFirstDimensions = firstDimensions == 0 ? null : type.getAnnotationsOnDimensions();
+		Annotation [][] annotationsOnAllDimensions = annotationsOnFirstDimensions;
+		if (annotationsOnExtendedDimensions != null) {
 			annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions, annotationsOnFirstDimensions, extendedDimensions, annotationsOnExtendedDimensions); 
-			annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions + extendedDimensions, annotationsOnAllDimensions, isVarArgs ? 1 : 0, isVarArgs ? new Annotation[][]{varArgsAnnotations} : null);
+		}
+		if (varArgsAnnotations != null) {
+			annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions + extendedDimensions, annotationsOnAllDimensions, 
+																				1, new Annotation[][]{varArgsAnnotations});
 		}
 		type = copyDims(type, typeDimensions, annotationsOnAllDimensions);
 		type.sourceEnd = type.isParameterizedTypeReference() ? this.endStatementPosition : this.endPosition;
@@ -1581,63 +1584,4 @@
 	buffer.append(super.toString());
 	return buffer.toString();
 }
-/**
- * INTERNAL USE ONLY
- */
-protected TypeReference typeReference(
-	int dim,
-	int localIdentifierPtr,
-	int localIdentifierLengthPtr) {
-	/* build a Reference on a variable that may be qualified or not
-	 * This variable is a type reference and dim will be its dimensions.
-	 * We don't have any side effect on the stacks' pointers.
-	 */
-	Annotation [][] annotationsOnDimensions = dim == 0 ? null : getAnnotationsOnDimensions(dim);
-	int length;
-	TypeReference ref;
-	if ((length = this.identifierLengthStack[localIdentifierLengthPtr]) == 1) {
-		// single variable reference
-		if (dim == 0) {
-			ref =
-				new SingleTypeReference(
-					this.identifierStack[localIdentifierPtr],
-					this.identifierPositionStack[localIdentifierPtr--]);
-		} else {
-			ref =
-				new ArrayTypeReference(
-					this.identifierStack[localIdentifierPtr],
-					dim,
-					annotationsOnDimensions,
-					this.identifierPositionStack[localIdentifierPtr--]);
-			ref.sourceEnd = this.endPosition;
-		}
-	} else {
-		if (length < 0) { //flag for precompiled type reference on base types
-			ref = TypeReference.baseTypeReference(-length, dim, annotationsOnDimensions);
-			ref.sourceStart = this.intStack[this.localIntPtr--];
-			if (dim == 0) {
-				ref.sourceEnd = this.intStack[this.localIntPtr--];
-			} else {
-				this.localIntPtr--;
-				ref.sourceEnd = this.endPosition;
-			}
-		} else { //Qualified variable reference
-			char[][] tokens = new char[length][];
-			localIdentifierPtr -= length;
-			long[] positions = new long[length];
-			System.arraycopy(this.identifierStack, localIdentifierPtr + 1, tokens, 0, length);
-			System.arraycopy(
-				this.identifierPositionStack,
-				localIdentifierPtr + 1,
-				positions,
-				0,
-				length);
-			if (dim == 0)
-				ref = new QualifiedTypeReference(tokens, positions);
-			else
-				ref = new ArrayQualifiedTypeReference(tokens, dim, annotationsOnDimensions, positions);
-		}
-	}
-	return ref;
-}
 }
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java
index bbdd59a..48a2827 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java
@@ -436,9 +436,9 @@
 		this.requestor.acceptMethodReference(memberValuepair.name, 0, memberValuepair.sourceStart);
 	}
 }
-protected void consumeMarkerAnnotation() {
-	super.consumeMarkerAnnotation();
-	Annotation annotation = (Annotation)this.expressionStack[this.expressionPtr];
+protected void consumeMarkerAnnotation(boolean isTypeAnnotation) {
+	super.consumeMarkerAnnotation(isTypeAnnotation);
+	Annotation annotation = (Annotation) (isTypeAnnotation ? this.typeAnnotationStack[this.typeAnnotationPtr] : this.expressionStack[this.expressionPtr]);
 	if (this.reportReferenceInfo) { // accept annotation type reference
 		this.requestor.acceptAnnotationTypeReference(annotation.type.getTypeName(), annotation.sourceStart, annotation.sourceEnd);
 	}
@@ -592,16 +592,16 @@
 	handleMessageSend(((BaseCallMessageSend) this.expressionStack[this.expressionPtr]).getMessageSend());
 }
 //SH}
-protected void consumeNormalAnnotation() {
-	super.consumeNormalAnnotation();
-	Annotation annotation = (Annotation)this.expressionStack[this.expressionPtr];
+protected void consumeNormalAnnotation(boolean isTypeAnnotation) {
+	super.consumeNormalAnnotation(isTypeAnnotation);
+	Annotation annotation = (Annotation) (isTypeAnnotation ? this.typeAnnotationStack[this.typeAnnotationPtr] : this.expressionStack[this.expressionPtr]);
 	if (this.reportReferenceInfo) { // accept annotation type reference
 		this.requestor.acceptAnnotationTypeReference(annotation.type.getTypeName(), annotation.sourceStart, annotation.sourceEnd);
 	}
 }
-protected void consumeSingleMemberAnnotation() {
-	super.consumeSingleMemberAnnotation();
-	SingleMemberAnnotation member = (SingleMemberAnnotation) this.expressionStack[this.expressionPtr];
+protected void consumeSingleMemberAnnotation(boolean isTypeAnnotation) {
+	super.consumeSingleMemberAnnotation(isTypeAnnotation);
+	SingleMemberAnnotation member = (SingleMemberAnnotation) (isTypeAnnotation ? this.typeAnnotationStack[this.typeAnnotationPtr] : this.expressionStack[this.expressionPtr]);
 	if (this.reportReferenceInfo) {
 		this.requestor.acceptMethodReference(TypeConstants.VALUE, 0, member.sourceStart);
 	}
@@ -863,7 +863,7 @@
 		return null;
 	}
 }
-public TypeReference getUnannotatedTypeReference(int dim) {
+public TypeReference getTypeReference(int dim) {
 	/* build a Reference on a variable that may be qualified or not
 	 * This variable is a type reference and dim will be its dimensions
 	 */
@@ -912,7 +912,7 @@
 				}
 			}
 		} else if (length == 1) {
-			// single variable reference
+			// single type reference
 			this.genericsLengthPtr--; // pop the 0
 			if (dim == 0) {
 				ref =
@@ -931,11 +931,14 @@
 						annotationsOnDimensions,
 						this.identifierPositionStack[this.identifierPtr--]);
 				ref.sourceEnd = this.endPosition;
+				if (annotationsOnDimensions != null) {
+					ref.bits |= ASTNode.HasTypeAnnotations;
+				}
 				if (this.reportReferenceInfo) {
 					this.requestor.acceptTypeReference(((ArrayTypeReference)ref).token, ref.sourceStart);
 				}
 			}
-		} else {//Qualified variable reference
+		} else { // Qualified type reference
 			this.genericsLengthPtr--;
 			char[][] tokens = new char[length][];
 			this.identifierPtr -= length;
@@ -957,17 +960,39 @@
 				ref =
 					new ArrayQualifiedTypeReference(tokens, dim, annotationsOnDimensions, positions);
 				ref.sourceEnd = this.endPosition;
+				if (annotationsOnDimensions != null) {
+					ref.bits |= ASTNode.HasTypeAnnotations;
+				}
 				if (this.reportReferenceInfo) {
 					this.requestor.acceptTypeReference(((ArrayQualifiedTypeReference)ref).tokens, ref.sourceStart, ref.sourceEnd);
 				}
 			}
 		}
 	}
+	int levels = ref.getAnnotatableLevels();
+	for (int i = levels - 1; i >= 0; i--) {
+		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
+			if (ref.annotations == null)
+				ref.annotations = new Annotation[levels][];
+			System.arraycopy(
+					this.typeAnnotationStack,
+					(this.typeAnnotationPtr -= length) + 1,
+					ref.annotations[i] = new Annotation[length],
+					0,
+					length);
+			if (i == 0) {
+				ref.sourceStart = ref.annotations[0][0].sourceStart;
+			}
+			ref.bits |= ASTNode.HasTypeAnnotations;
+		}
+	}
 	return ref;
 }
-public NameReference getUnspecifiedReference() {
+public NameReference getUnspecifiedReference(boolean rejectTypeAnnotations) {
 	/* build a (unspecified) NameReference which may be qualified*/
-
+    if (rejectTypeAnnotations) {
+    	consumeNonTypeUseName();
+    }
 	int length;
 	if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1) {
 		// single variable reference
@@ -1005,7 +1030,7 @@
 	a field access. This optimization is IMPORTANT while it results
 	that when a NameReference is build, the type checker should always
 	look for that it is not a type reference */
-
+	consumeNonTypeUseName();
 	int length;
 	if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1) {
 		// single variable reference
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
index 823c8cc..813cb83 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -416,10 +416,10 @@
 	this.patternLocator.match((LocalDeclaration) this.astStack[this.astPtr], this.nodeSet);
 }
 
-protected void consumeMarkerAnnotation() {
-	super.consumeMarkerAnnotation();
+protected void consumeMarkerAnnotation(boolean isTypeAnnotation) {
+	super.consumeMarkerAnnotation(isTypeAnnotation);
 	if (this.patternFineGrain == 0 || (this.patternFineGrain & IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE) != 0) {
-		Annotation annotation = (Annotation) this.expressionStack[this.expressionPtr];
+		Annotation annotation = (Annotation) (isTypeAnnotation ? this.typeAnnotationStack[this.typeAnnotationPtr] : this.expressionStack[this.expressionPtr]);
 		this.patternLocator.match(annotation, this.nodeSet);
 	}
 }
@@ -595,11 +595,11 @@
 	}
 }
 
-protected void consumeNormalAnnotation() {
-	super.consumeNormalAnnotation();
+protected void consumeNormalAnnotation(boolean isTypeAnnotation) {
+	super.consumeNormalAnnotation(isTypeAnnotation);
 	if (this.patternFineGrain == 0 || (this.patternFineGrain & IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE) != 0) {
 		// this is always an Annotation
-		Annotation annotation = (Annotation) this.expressionStack[this.expressionPtr];
+		Annotation annotation = (Annotation) (isTypeAnnotation ? this.typeAnnotationStack[this.typeAnnotationPtr] : this.expressionStack[this.expressionPtr]);
 		this.patternLocator.match(annotation, this.nodeSet);
 	}
 }
@@ -633,11 +633,11 @@
 	this.intPtr--;
 }
 
-protected void consumeSingleMemberAnnotation() {
-	super.consumeSingleMemberAnnotation();
+protected void consumeSingleMemberAnnotation(boolean isTypeAnnotation) {
+	super.consumeSingleMemberAnnotation(isTypeAnnotation);
 	if (this.patternFineGrain == 0 || (this.patternFineGrain & IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE) != 0) {
 		// this is always an Annotation
-		Annotation annotation = (Annotation) this.expressionStack[this.expressionPtr];
+		Annotation annotation = (Annotation) (isTypeAnnotation ? this.typeAnnotationStack[this.typeAnnotationPtr] : this.expressionStack[this.expressionPtr]);
 		this.patternLocator.match(annotation, this.nodeSet);
 	}
 }
@@ -877,14 +877,14 @@
 		this.nodeSet.addTrustedMatch(result, true);
 	return result;
 }
-protected TypeReference getUnannotatedTypeReference(int dim) {
+protected TypeReference getTypeReference(int dim) {
 //{ObjectTeams: wrap to introduce 2nd parameter
-	return getUnannotatedTypeReference(dim, false);  
+	return getTypeReference(dim, false);  
 }
-protected TypeReference getUnannotatedTypeReference(int dim, boolean liftingTypeAllowed) {
+protected TypeReference getTypeReference(int dim, boolean liftingTypeAllowed) {
 // FIXME:
 //*orig:
-	TypeReference typeRef = super.getUnannotatedTypeReference(dim);
+	TypeReference typeRef = super.getTypeReference(dim);
 // OT previous:
 //	TypeReference typeRef = super.getUnannotatedTypeReference(dim, liftingTypeAllowed);
 // SH}
@@ -893,8 +893,8 @@
 	}
 	return typeRef;
 }
-protected NameReference getUnspecifiedReference() {
-	NameReference nameRef = super.getUnspecifiedReference();
+protected NameReference getUnspecifiedReference(boolean rejectTypeAnnotations) {
+	NameReference nameRef = super.getUnspecifiedReference(rejectTypeAnnotations);
 	if (this.patternFineGrain == 0) {
 		this.patternLocator.match(nameRef, this.nodeSet); // NB: Don't check container since unspecified reference can happen anywhere
 	} else if ((this.patternFineGrain & IJavaSearchConstants.QUALIFIED_REFERENCE) != 0) {