Merge
authorlana
Tue, 11 Feb 2014 11:25:59 -0800
changeset 22704 2740ebeb238c
parent 22703 322d8adeabe1 (diff)
parent 22683 e8de566e9375 (current diff)
child 22705 b71c9454e7ee
Merge
--- a/langtools/make/BuildLangtools.gmk	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/make/BuildLangtools.gmk	Tue Feb 11 11:25:59 2014 -0800
@@ -27,179 +27,21 @@
 default: all
 
 include $(SPEC)
-include MakeBase.gmk
-include JavaCompilation.gmk
-
-# The BOOT_JAVAC setup uses the bootdir compiler to compile the tools
-# and the bootstrap javac, to be run by the bootdir jvm.
-$(eval $(call SetupJavaCompiler,BOOT_JAVAC, \
-    JAVAC := $(JAVAC), \
-    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
-    SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
-    FLAGS := -XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror))
-
-# javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied.
-RESOURCE_SUFFIXES := .gif .xml .css .js javax.tools.JavaCompilerTool
-
-# Now setup the compilation of the properties compilation tool. You can depend
-# upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we
-# add src/share/classes to the sourcepath. This is necessary since the GenStubs
-# program needs to be linked and run towards the new javac sources.
-$(eval $(call SetupJavaCompilation,BUILD_TOOLS, \
-    SETUP := BOOT_JAVAC, \
-    DISABLE_SJAVAC := true, \
-    ADD_JAVAC_FLAGS := -Xprefer:source, \
-    SRC := $(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes, \
-    INCLUDES := compileproperties genstubs, \
-    BIN := $(LANGTOOLS_OUTPUTDIR)/btclasses))
-
-# The compileprops tools compiles a properties file into a resource bundle.
-TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/btclasses compileproperties.CompileProperties -quiet
-
-# Lookup the properties that need to be compiled into resource bundles.
-PROPSOURCES := $(shell $(FIND) $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties")
-
-# Strip away prefix and suffix, leaving for example only: "com/sun/tools/javac/resources/javac_zh_CN"
-PROPPATHS := $(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties, %, $(PROPSOURCES))
-
-# Generate the list of java files to be created.
-PROPJAVAS := $(patsubst %, $(LANGTOOLS_OUTPUTDIR)/gensrc/%.java, $(PROPPATHS))
 
-# Generate the package dirs for the tobe generated java files.
-PROPDIRS := $(dir $(PROPJAVAS))
-
-# Now generate a sequence of "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle"
-# suitable to be fed into the CompileProperties command.
-PROPCMDLINE := $(subst _SPACE_, $(SPACE), $(join $(addprefix -compile_SPACE_, $(PROPSOURCES)), \
-    $(addsuffix _SPACE_java.util.ListResourceBundle, $(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/, $(addsuffix .java, $(PROPPATHS))))))
+gensrc-langtools:
+	+$(MAKE) -f $(LANGTOOLS_TOPDIR)/make/GensrcLangtools.gmk
 
-# Now setup the rule for the generation of the resource bundles.
-$(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d: $(PROPSOURCES) $(BUILD_TOOLS)
-	$(RM) -r $(@D)/*
-	$(MKDIR) -p $(@D) $(PROPDIRS)
-	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties
-	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties
-	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties
-	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties
-	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties
-	$(ECHO) Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles
-	$(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \
-	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \
-	        $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \
-	        java.util.ListResourceBundle \
-	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \
-	        $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \
-	        java.util.ListResourceBundle \
-	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \
-	        $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \
-	        java.util.ListResourceBundle \
-	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties \
-	        $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.java \
-	        java.util.ListResourceBundle \
-	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties \
-	        $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.java \
-	        java.util.ListResourceBundle
-	$(ECHO) PROPS_ARE_CREATED = yes > $@
-
-# Trigger the generation of the resource bundles. After the resource bundles have
-# been compiled, then the makefile will restart and the newly created java files
-# will become part of the build further along in the makefile.
--include $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d
+interim-langtools: gensrc-langtools
+	+$(MAKE) -f $(LANGTOOLS_TOPDIR)/make/CompileInterim.gmk
 
-ifeq ($(PROPS_ARE_CREATED), yes)
-  # Setup the rules to build a dist/bootstrap/lib/javac.jar, ie a smaller intermediate javac
-  # that can be compiled with an old javac. The intermediate javac is then used
-  # to compile javac again and to build the complete new jdk.
-  $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS, \
-      SETUP := BOOT_JAVAC, \
-      DISABLE_SJAVAC := true, \
-      SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \
-      EXCLUDES := com/sun/tools/javac/nio, \
-      COPY := $(RESOURCE_SUFFIXES), \
-      BIN := $(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap))
-
-  $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC, $(BUILD_BOOTSTRAP_LANGTOOLS), \
-      SRCS := $(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap, \
-      JAR := $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar, \
-      SUFFIXES := .class $(RESOURCE_SUFFIXES)))
+genstubs-langtools: interim-langtools
+	+$(MAKE) -f $(LANGTOOLS_TOPDIR)/make/GenstubsLangtools.gmk
 
-  # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not
-  # yet built. It is currently not needed but might be again in the future. The following
-  # exercises the functionality to verify that it works.
-  TOOL_GENSTUBS_CMD = $(JAVA) \
-       "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
-       -classpath $(LANGTOOLS_OUTPUTDIR)/btclasses \
-       genstubs.GenStubs
-
-  # We fetch source from the JDK...
-  JDKS = $(JDK_TOPDIR)/src/share/classes
-
-  # Build the list of classes to generate stubs from. java/util/function/Predicate.java isn't
-  # currently needed, but is used as a demo for now.
-
-  STUBSOURCES := $(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \
-      -e "$(JDKS)/java/util/function/Predicate.java")
-
-  # Rewrite the file names into class names because the GenStubs tool require this.
-  STUBCLASSES := $(subst /,., $(patsubst $(JDKS)/%.java, %, $(STUBSOURCES)))
+compile-langtools: gensrc-langtools interim-langtools genstubs-langtools
+	+$(MAKE) -f $(LANGTOOLS_TOPDIR)/make/CompileLangtools.gmk
 
-  # Now setup the build recipe for genstubs.
-  $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d: $(STUBSOURCES) $(BUILD_TOOLS) \
-      $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
-      $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d
-	$(MKDIR) -p $(@D)
-	$(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs
-	$(ECHO) $(LOG_INFO) Generating stubs from JDK sources.
-	($(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) && $(ECHO) STUBS_ARE_CREATED = yes > $@)
-	if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs > /dev/null 2>&1; then \
-	  $(ECHO) $(LOG_INFO) No changes in the stubs!; \
-	  $(RM) -r $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \
-	else \
-	  $(ECHO) $(LOG_INFO) Changes in stubs detected!; \
-	  $(RM) -r $(@D); \
-	  $(MV) $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \
-	fi
-	$(ECHO) STUBS_ARE_CREATED = yes > $@
-
-  # Trigger a generation of the genstubs java source code and a restart
-  # of the makefile to make sure that the following build setup use the
-  # newly created java files.
-  -include $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d
+all: compile-langtools
 
-  ifeq ($(STUBS_ARE_CREATED), yes)
-    # Setup a compiler configuration using the intermediate javac in dist/bootstrap/lib/javac.jar
-    # that generates code for the new jdk that is being built.
-    # The code compiled by this compiler setup, cannot necessarily be run with the bootstrap jvm.
-    $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \
-        JVM := $(JAVA), \
-        JAVAC := "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
-            -cp $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
-            com.sun.tools.javac.Main, \
-        FLAGS := -XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror, \
-        SERVER_DIR := $(SJAVAC_SERVER_DIR), \
-        SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
+.PHONY: default all
+.PHONY: gensrc-langtools interim-langtools genstubs-langtools compile-langtools
 
-    $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC, \
-        SETUP := GENERATE_NEWBYTECODE, \
-        SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \
-            $(LANGTOOLS_OUTPUTDIR)/genstubs, \
-        EXCLUDES := java/util java/io java/nio, \
-        COPY := $(RESOURCE_SUFFIXES), \
-        BIN := $(LANGTOOLS_OUTPUTDIR)/classes))
-
-    $(eval $(call SetupArchive,ARCHIVE_FULL_JAVAC, $(BUILD_FULL_JAVAC), \
-        SETUP := GENERATE_NEWBYTECODE, \
-        SRCS := $(LANGTOOLS_OUTPUTDIR)/classes, \
-        SUFFIXES := .class $(RESOURCE_SUFFIXES), \
-        JAR := $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar))
-
-    $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE, \
-        SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \
-        ZIP := $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip))
-
-    all: $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar \
-        $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip \
-        $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar
-
-  endif
-endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/CommonLangtools.gmk	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# The BOOT_JAVAC setup uses the boot jdk compiler to compile the tools
+# and the interim javac, to be run by the boot jdk.
+$(eval $(call SetupJavaCompiler,BOOT_JAVAC, \
+    JAVAC := $(JAVAC), \
+    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
+    SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
+    FLAGS := -XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror))
+
+# javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied.
+RESOURCE_SUFFIXES := .gif .xml .css .js javax.tools.JavaCompilerTool
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/CompileInterim.gmk	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# This must be the first rule
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+include JavaCompilation.gmk
+
+include CommonLangtools.gmk
+
+# Setup the rules to build the interim langtools jar, which is compiled by
+# the boot javac and can be run on the boot jdk. This will be used to compile
+# the rest of the product. Include the Genstubs build tool in this compilation
+# as it will be used together with the interim javac.
+$(eval $(call SetupJavaCompilation,BUILD_INTERIM_LANGTOOLS, \
+    SETUP := BOOT_JAVAC, \
+    DISABLE_SJAVAC := true, \
+    SRC := $(LANGTOOLS_TOPDIR)/src/share/classes \
+        $(LANGTOOLS_OUTPUTDIR)/gensrc \
+        $(LANGTOOLS_TOPDIR)/make/tools, \
+    EXCLUDES := com/sun/tools/javac/nio compileproperties anttasks crules, \
+    COPY := $(RESOURCE_SUFFIXES), \
+    BIN := $(LANGTOOLS_OUTPUTDIR)/interim_classes, \
+    JAR := $(INTERIM_LANGTOOLS_JAR)))
+
+all: $(BUILD_INTERIM_LANGTOOLS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/CompileLangtools.gmk	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,62 @@
+#
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# This must be the first rule
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+include JavaCompilation.gmk
+
+include CommonLangtools.gmk
+
+# Setup a compiler configuration using javac from the interim langtools jar
+# that generates code for the new jdk that is being built. The code compiled 
+# by this compiler setup, cannot necessarily be run with the bootstrap jvm.
+$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \
+    JVM := $(JAVA), \
+    JAVAC := $(NEW_JAVAC), \
+    FLAGS := -XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror, \
+    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
+    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
+
+$(eval $(call SetupJavaCompilation,BUILD_FULL_LANGTOOLS, \
+    SETUP := GENERATE_NEWBYTECODE, \
+    SRC := $(LANGTOOLS_TOPDIR)/src/share/classes \
+        $(LANGTOOLS_OUTPUTDIR)/gensrc \
+        $(LANGTOOLS_OUTPUTDIR)/genstubs, \
+    EXCLUDES := java/util java/io java/nio, \
+    COPY := $(RESOURCE_SUFFIXES), \
+    BIN := $(LANGTOOLS_OUTPUTDIR)/classes, \
+    JAR := $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar))
+
+# Construct the source zip separately to avoid picking up the genstubs sources.
+$(eval $(call SetupZipArchive,ZIP_FULL_LANGTOOLS_SOURCE, \
+    SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \
+    ZIP := $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip))
+
+all: \
+    $(BUILD_FULL_LANGTOOLS) \
+    $(ZIP_FULL_LANGTOOLS_SOURCE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/GensrcLangtools.gmk	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,111 @@
+#
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# This must be the first rule
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+include JavaCompilation.gmk
+
+include CommonLangtools.gmk
+
+################################################################################
+# Setup the compilation of the properties compilation tool. You can depend
+# upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we
+# add src/share/classes to the sourcepath. This is necessary since the GenStubs
+# program needs to be linked and run with the new javac sources.
+$(eval $(call SetupJavaCompilation,BUILD_TOOLS, \
+    SETUP := BOOT_JAVAC, \
+    DISABLE_SJAVAC := true, \
+    ADD_JAVAC_FLAGS := -Xprefer:source, \
+    SRC := $(LANGTOOLS_TOPDIR)/make/tools, \
+    INCLUDES := compileproperties, \
+    BIN := $(LANGTOOLS_OUTPUTDIR)/buildtools_classes))
+
+################################################################################
+# The compileprops tools compiles a properties file into a resource bundle.
+TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/buildtools_classes \
+    compileproperties.CompileProperties -quiet
+
+# Lookup the properties that need to be compiled into resource bundles.
+PROPSOURCES := $(shell $(FIND) $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties")
+
+# Strip away prefix and suffix, leaving for example only: 
+# "com/sun/tools/javac/resources/javac_zh_CN"
+PROPPATHS := $(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties, %, $(PROPSOURCES))
+
+# Generate the list of java files to be created.
+PROPJAVAS := $(patsubst %, $(LANGTOOLS_OUTPUTDIR)/gensrc/%.java, $(PROPPATHS))
+
+# Generate the package dirs for the tobe generated java files.
+PROPDIRS := $(dir $(PROPJAVAS))
+
+# Now generate a sequence of:
+# "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle"
+# suitable to be fed into the CompileProperties command.
+PROPCMDLINE := $(subst _SPACE_, $(SPACE), \
+    $(join $(addprefix -compile_SPACE_, $(PROPSOURCES)), \
+    $(addsuffix _SPACE_java.util.ListResourceBundle, \
+    $(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/, \
+    $(addsuffix .java, $(PROPPATHS))))))
+
+# Now setup the rule for the generation of the resource bundles.
+$(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props: $(PROPSOURCES) $(BUILD_TOOLS)
+	$(RM) -r $(@D)/*
+	$(MKDIR) -p $(@D) $(PROPDIRS)
+	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
+	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties
+	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
+	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties
+	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
+	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties
+	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
+	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties
+	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
+	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties
+	$(ECHO) Compiling $(words $(PROPSOURCES) javah javap javac jdeps javadoc) \
+	    properties into resource bundles
+	$(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \
+	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \
+	        $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \
+	        java.util.ListResourceBundle \
+	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \
+	        $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \
+	        java.util.ListResourceBundle \
+	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \
+	        $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \
+	        java.util.ListResourceBundle \
+	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties \
+	        $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.java \
+	        java.util.ListResourceBundle \
+	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties \
+	        $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.java \
+	        java.util.ListResourceBundle
+	$(TOUCH) $@
+
+all: $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props
+
+################################################################################
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/GenstubsLangtools.gmk	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,70 @@
+#
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# This must be the first rule
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+
+include CommonLangtools.gmk
+
+# GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not
+# yet built. It is currently not needed but might be again in the future. The following
+# exercises the functionality to verify that it works.
+TOOL_GENSTUBS_CMD = $(JAVA) \
+     "-Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR)" \
+     genstubs.GenStubs
+
+# We fetch source from the JDK...
+JDKS := $(JDK_TOPDIR)/src/share/classes
+
+# Build the list of classes to generate stubs from. java/util/function/Predicate.java isn't
+# currently needed, but is used as a demo for now.
+
+STUBSOURCES := $(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \
+    -e "$(JDKS)/java/util/function/Predicate.java")
+
+# Rewrite the file names into class names because the GenStubs tool require this.
+STUBCLASSES := $(subst /,., $(patsubst $(JDKS)/%.java, %, $(STUBSOURCES)))
+
+# Now setup the build recipe for genstubs.
+$(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs: $(STUBSOURCES)
+	$(MKDIR) -p $(@D)
+	$(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs
+	$(ECHO) $(LOG_INFO) Generating stubs from JDK sources.
+	$(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES)
+	if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs \
+	    > /dev/null 2>&1; then \
+	  $(ECHO) $(LOG_INFO) No changes in the stubs!; \
+	  $(RM) -r $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \
+	else \
+	  $(ECHO) $(LOG_INFO) Changes in stubs detected!; \
+	  $(RM) -r $(@D); \
+	  $(MV) $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \
+	fi
+	$(TOUCH) $@
+
+all: $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs
--- a/langtools/src/share/classes/com/sun/tools/classfile/Attribute.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/classfile/Attribute.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -71,10 +71,6 @@
             // defer init of standardAttributeClasses until after options set up
         }
 
-        public void setCompat(boolean compat) {
-            this.compat = compat;
-        }
-
         public Attribute createAttribute(ClassReader cr, int name_index, byte[] data)
                 throws IOException {
             if (standardAttributes == null) {
@@ -109,9 +105,10 @@
         protected void init() {
             standardAttributes = new HashMap<>();
             standardAttributes.put(AnnotationDefault, AnnotationDefault_attribute.class);
-            standardAttributes.put(BootstrapMethods, BootstrapMethods_attribute.class);
+            standardAttributes.put(BootstrapMethods,  BootstrapMethods_attribute.class);
             standardAttributes.put(CharacterRangeTable, CharacterRangeTable_attribute.class);
             standardAttributes.put(Code,              Code_attribute.class);
+            standardAttributes.put(CompilationID,     CompilationID_attribute.class);
             standardAttributes.put(ConstantValue,     ConstantValue_attribute.class);
             standardAttributes.put(Deprecated,        Deprecated_attribute.class);
             standardAttributes.put(EnclosingMethod,   EnclosingMethod_attribute.class);
@@ -120,29 +117,23 @@
             standardAttributes.put(LineNumberTable,   LineNumberTable_attribute.class);
             standardAttributes.put(LocalVariableTable, LocalVariableTable_attribute.class);
             standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class);
-
-            if (!compat) { // old javap does not recognize recent attributes
-                standardAttributes.put(MethodParameters, MethodParameters_attribute.class);
-                standardAttributes.put(CompilationID, CompilationID_attribute.class);
-                standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
-                standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
-                standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
-                standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class);
-                standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class);
-                standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class);
-                standardAttributes.put(Signature,     Signature_attribute.class);
-                standardAttributes.put(SourceID, SourceID_attribute.class);
-            }
-
+            standardAttributes.put(MethodParameters,  MethodParameters_attribute.class);
+            standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
+            standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
+            standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
+            standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class);
+            standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class);
+            standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class);
+            standardAttributes.put(Signature,         Signature_attribute.class);
             standardAttributes.put(SourceDebugExtension, SourceDebugExtension_attribute.class);
             standardAttributes.put(SourceFile,        SourceFile_attribute.class);
+            standardAttributes.put(SourceID,          SourceID_attribute.class);
             standardAttributes.put(StackMap,          StackMap_attribute.class);
             standardAttributes.put(StackMapTable,     StackMapTable_attribute.class);
             standardAttributes.put(Synthetic,         Synthetic_attribute.class);
         }
 
         private Map<String,Class<? extends Attribute>> standardAttributes;
-        private boolean compat; // don't support recent attrs in compatibility mode
     }
 
     public static Attribute read(ClassReader cr) throws IOException {
--- a/langtools/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java	Tue Feb 11 11:25:59 2014 -0800
@@ -425,11 +425,15 @@
         private final List<T> placeholderFor;
         private final Symbol on;
 
-        public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) {
+        public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx,
+                           List<T> placeholderFor, Symbol on) {
             super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(),
-                    ctx.isTypeCompound ?
-                            ((Attribute.TypeCompound)placeholderFor.head).position :
-                                new TypeAnnotationPosition());
+                  ctx.isTypeCompound ?
+                  ((Attribute.TypeCompound)placeholderFor.head).position :
+                  // TODO: Eventually, we will need to get rid of this
+                  // use of unknown, either by using null, or by
+                  // throwing an assertion failure here.
+                  TypeAnnotationPosition.unknown);
             this.ctx = ctx;
             this.placeholderFor = placeholderFor;
             this.on = on;
--- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java	Tue Feb 11 11:25:59 2014 -0800
@@ -119,13 +119,20 @@
         }
     }
 
-    public TargetType type = TargetType.UNKNOWN;
+    public static final List<TypePathEntry> emptyPath = List.nil();
+
+    // NOTE: All of these will be converted to final fields eventually.
+
+    public final TargetType type;
 
     // For generic/array types.
-    public List<TypePathEntry> location = List.nil();
+
+    // This field is in the process of being made final.  Do not
+    // introduce new mutations.
+    public List<TypePathEntry> location;
 
     // Tree position.
-    public int pos = -1;
+    public final int pos;
 
     // For type casts, type tests, new, locals (as start_pc),
     // and method and constructor reference type arguments.
@@ -138,13 +145,17 @@
     public int[] lvarIndex = null;
 
     // For type parameter bound
-    public int bound_index = Integer.MIN_VALUE;
+    public final int bound_index;
 
     // For type parameter and method parameter
-    public int parameter_index = Integer.MIN_VALUE;
+    public final int parameter_index;
 
     // For class extends, implements, and throws clauses
-    public int type_index = Integer.MIN_VALUE;
+
+    // This field is effectively final.  However, it needs to be
+    // modified by Gen for the time being.  Do not introduce new
+    // mutations.
+    public int type_index;
 
     // For exception parameters, index into exception table.
     // In com.sun.tools.javac.jvm.Gen.genCatch we first set the type_index
@@ -156,9 +167,10 @@
     // If this type annotation is within a lambda expression,
     // store a pointer to the lambda expression tree in order
     // to allow a later translation to the right method.
-    public JCLambda onLambda = null;
+    public final JCLambda onLambda;
 
-    public TypeAnnotationPosition() {}
+    // NOTE: This constructor will eventually go away, and be replaced
+    // by static builder methods.
 
     @Override
     public String toString() {
@@ -323,4 +335,847 @@
         }
         return loc.toList();
     }
+
+    // These methods are the new preferred way to create
+    // TypeAnnotationPositions
+
+    // Never make this a public constructor without creating a builder.
+    private TypeAnnotationPosition(final TargetType ttype,
+                                   final int pos,
+                                   final int parameter_index,
+                                   final JCLambda onLambda,
+                                   final int type_index,
+                                   final int bound_index,
+                                   final List<TypePathEntry> location) {
+        Assert.checkNonNull(location);
+        this.type = ttype;
+        this.pos = pos;
+        this.parameter_index = parameter_index;
+        this.onLambda = onLambda;
+        this.type_index = type_index;
+        this.bound_index = bound_index;
+        this.location = location;
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method return.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this parameter.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodReturn(final List<TypePathEntry> location,
+                     final JCLambda onLambda,
+                     final int pos) {
+        return new TypeAnnotationPosition(TargetType.METHOD_RETURN, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method return.
+     *
+     * @param location The type path.
+     */
+    public static TypeAnnotationPosition
+        methodReturn(final List<TypePathEntry> location) {
+        return methodReturn(location, null, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method return.
+     *
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition methodReturn(final int pos) {
+        return methodReturn(emptyPath, null, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method receiver.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this parameter.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodReceiver(final List<TypePathEntry> location,
+                     final JCLambda onLambda,
+                     final int pos) {
+        return new TypeAnnotationPosition(TargetType.METHOD_RECEIVER, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method receiver.
+     *
+     * @param location The type path.
+     */
+    public static TypeAnnotationPosition
+        methodReceiver(final List<TypePathEntry> location) {
+        return methodReceiver(location, null, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method receiver.
+     *
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition methodReceiver(final int pos) {
+        return methodReceiver(emptyPath, null, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method formal parameter.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this parameter.
+     * @param index The index of the parameter.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodParameter(final List<TypePathEntry> location,
+                        final JCLambda onLambda,
+                        final int parameter_index,
+                        final int pos) {
+        return new TypeAnnotationPosition(TargetType.METHOD_FORMAL_PARAMETER,
+                                          pos, parameter_index, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method formal parameter.
+     *
+     * @param onLambda The lambda for this parameter.
+     * @param index The index of the parameter.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodParameter(final JCLambda onLambda,
+                        final int parameter_index,
+                        final int pos) {
+        return methodParameter(emptyPath, onLambda,
+                               parameter_index, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method formal parameter.
+     *
+     * @param index The index of the parameter.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodParameter(final int parameter_index,
+                        final int pos) {
+        return methodParameter(null, parameter_index, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method formal parameter.
+     *
+     * @param location The type path.
+     * @param index The index of the parameter.
+     */
+    public static TypeAnnotationPosition
+        methodParameter(final List<TypePathEntry> location,
+                        final int parameter_index) {
+        return methodParameter(location, null, parameter_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method reference.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this method reference.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodRef(final List<TypePathEntry> location,
+                  final JCLambda onLambda,
+                  final int pos) {
+        return new TypeAnnotationPosition(TargetType.METHOD_REFERENCE, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method reference.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this method reference.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodRef(final List<TypePathEntry> location) {
+        return methodRef(location, null, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a constructor reference.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this constructor reference.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        constructorRef(final List<TypePathEntry> location,
+                       final JCLambda onLambda,
+                       final int pos) {
+        return new TypeAnnotationPosition(TargetType.CONSTRUCTOR_REFERENCE, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a constructor reference.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this constructor reference.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        constructorRef(final List<TypePathEntry> location) {
+        return constructorRef(location, null, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a field.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        field(final List<TypePathEntry> location,
+              final JCLambda onLambda,
+              final int pos) {
+        return new TypeAnnotationPosition(TargetType.FIELD, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a field.
+     *
+     * @param location The type path.
+     */
+    public static TypeAnnotationPosition
+        field(final List<TypePathEntry> location) {
+        return field(location, null, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a field.
+     *
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition field(final int pos) {
+        return field(emptyPath, null, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a local variable.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        localVariable(final List<TypePathEntry> location,
+                      final JCLambda onLambda,
+                      final int pos) {
+        return new TypeAnnotationPosition(TargetType.LOCAL_VARIABLE, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a local variable.
+     *
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        localVariable(final JCLambda onLambda,
+                      final int pos) {
+        return localVariable(emptyPath, onLambda, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a local variable.
+     *
+     * @param location The type path.
+     */
+    public static TypeAnnotationPosition
+        localVariable(final List<TypePathEntry> location) {
+        return localVariable(location, null, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for an exception parameter.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this parameter.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        exceptionParameter(final List<TypePathEntry> location,
+                           final JCLambda onLambda,
+                           final int pos) {
+        return new TypeAnnotationPosition(TargetType.EXCEPTION_PARAMETER, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for an exception parameter.
+     *
+     * @param onLambda The lambda for this parameter.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        exceptionParameter(final JCLambda onLambda,
+                           final int pos) {
+        return exceptionParameter(emptyPath, onLambda, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for an exception parameter.
+     *
+     * @param location The type path.
+     */
+    public static TypeAnnotationPosition
+        exceptionParameter(final List<TypePathEntry> location) {
+        return exceptionParameter(location, null, -1);
+    }
+
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a resource variable.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        resourceVariable(final List<TypePathEntry> location,
+                         final JCLambda onLambda,
+                         final int pos) {
+        return new TypeAnnotationPosition(TargetType.RESOURCE_VARIABLE, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a resource variable.
+     *
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        resourceVariable(final JCLambda onLambda,
+                         final int pos) {
+        return resourceVariable(emptyPath, onLambda, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a resource variable.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        resourceVariable(final List<TypePathEntry> location) {
+        return resourceVariable(location, null, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a new.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        newObj(final List<TypePathEntry> location,
+               final JCLambda onLambda,
+               final int pos) {
+        return new TypeAnnotationPosition(TargetType.NEW, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a new.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition newObj(final int pos) {
+        return newObj(emptyPath, null, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a new.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        newObj(final List<TypePathEntry> location) {
+        return newObj(location, null, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a class extension.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param type_index The index of the interface.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        classExtends(final List<TypePathEntry> location,
+                     final JCLambda onLambda,
+                     final int type_index,
+                     final int pos) {
+        return new TypeAnnotationPosition(TargetType.CLASS_EXTENDS, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          type_index, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a class extension.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param type_index The index of the interface.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        classExtends(final List<TypePathEntry> location,
+                     final JCLambda onLambda,
+                     final int pos) {
+        return classExtends(location, onLambda, -1, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a class extension.
+     *
+     * @param location The type path.
+     * @param type_index The index of the interface.
+     */
+    public static TypeAnnotationPosition
+        classExtends(final List<TypePathEntry> location,
+                     final int type_index) {
+        return classExtends(location, null, type_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a class extension.
+     *
+     * @param type_index The index of the interface.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition classExtends(final int type_index,
+                                                      final int pos) {
+        return classExtends(emptyPath, null, type_index, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a class extension.
+     *
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition classExtends(final int pos) {
+        return classExtends(-1, pos);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for an instanceof.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        instanceOf(final List<TypePathEntry> location,
+                   final JCLambda onLambda,
+                   final int pos) {
+        return new TypeAnnotationPosition(TargetType.INSTANCEOF, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+    /**
+     * Create a {@code TypeAnnotationPosition} for an instanceof.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        instanceOf(final List<TypePathEntry> location) {
+        return instanceOf(location, null, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a type cast.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param type_index The index into an intersection type.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        typeCast(final List<TypePathEntry> location,
+                 final JCLambda onLambda,
+                 final int type_index,
+                 final int pos) {
+        return new TypeAnnotationPosition(TargetType.CAST, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          type_index, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a type cast.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param type_index The index into an intersection type.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        typeCast(final List<TypePathEntry> location,
+                 final int type_index) {
+        return typeCast(location, null, type_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method
+     * invocation type argument.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param type_index The index of the type argument.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodInvocationTypeArg(final List<TypePathEntry> location,
+                                final JCLambda onLambda,
+                                final int type_index,
+                                final int pos) {
+        return new TypeAnnotationPosition(TargetType.METHOD_INVOCATION_TYPE_ARGUMENT,
+                                          pos, Integer.MIN_VALUE, onLambda,
+                                          type_index, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method
+     * invocation type argument.
+     *
+     * @param location The type path.
+     * @param type_index The index of the type argument.
+     */
+    public static TypeAnnotationPosition
+        methodInvocationTypeArg(final List<TypePathEntry> location,
+                                final int type_index) {
+        return methodInvocationTypeArg(location, null, type_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a constructor
+     * invocation type argument.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param type_index The index of the type argument.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        constructorInvocationTypeArg(final List<TypePathEntry> location,
+                                     final JCLambda onLambda,
+                                     final int type_index,
+                                     final int pos) {
+        return new TypeAnnotationPosition(TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
+                                          pos, Integer.MIN_VALUE, onLambda,
+                                          type_index, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a constructor
+     * invocation type argument.
+     *
+     * @param location The type path.
+     * @param type_index The index of the type argument.
+     */
+    public static TypeAnnotationPosition
+        constructorInvocationTypeArg(final List<TypePathEntry> location,
+                                     final int type_index) {
+        return constructorInvocationTypeArg(location, null, type_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a type parameter.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param parameter_index The index of the type parameter.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        typeParameter(final List<TypePathEntry> location,
+                      final JCLambda onLambda,
+                      final int parameter_index,
+                      final int pos) {
+        return new TypeAnnotationPosition(TargetType.CLASS_TYPE_PARAMETER, pos,
+                                          parameter_index, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a type parameter.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param parameter_index The index of the type parameter.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        typeParameter(final List<TypePathEntry> location,
+                      final int parameter_index) {
+        return typeParameter(location, null, parameter_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method type parameter.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param parameter_index The index of the type parameter.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodTypeParameter(final List<TypePathEntry> location,
+                            final JCLambda onLambda,
+                            final int parameter_index,
+                            final int pos) {
+        return new TypeAnnotationPosition(TargetType.METHOD_TYPE_PARAMETER,
+                                          pos, parameter_index, onLambda,
+                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method type parameter.
+     *
+     * @param location The type path.
+     * @param parameter_index The index of the type parameter.
+     */
+    public static TypeAnnotationPosition
+        methodTypeParameter(final List<TypePathEntry> location,
+                            final int parameter_index) {
+        return methodTypeParameter(location, null, parameter_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a throws clause.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param type_index The index of the exception.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodThrows(final List<TypePathEntry> location,
+                     final JCLambda onLambda,
+                     final int type_index,
+                     final int pos) {
+        return new TypeAnnotationPosition(TargetType.THROWS, pos,
+                                          Integer.MIN_VALUE, onLambda,
+                                          type_index, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a throws clause.
+     *
+     * @param location The type path.
+     * @param type_index The index of the exception.
+     */
+    public static TypeAnnotationPosition
+        methodThrows(final List<TypePathEntry> location,
+                     final int type_index) {
+        return methodThrows(location, null, type_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method reference
+     * type argument.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param parameter_index The index of the type argument.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodRefTypeArg(final List<TypePathEntry> location,
+                         final JCLambda onLambda,
+                         final int type_index,
+                         final int pos) {
+        return new TypeAnnotationPosition(TargetType.METHOD_REFERENCE_TYPE_ARGUMENT,
+                                          pos, Integer.MIN_VALUE, onLambda,
+                                          type_index, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method reference
+     * type argument.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param parameter_index The index of the type argument.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodRefTypeArg(final List<TypePathEntry> location,
+                         final int type_index) {
+        return methodRefTypeArg(location, null, type_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a constructor reference
+     * type argument.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param parameter_index The index of the type argument.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        constructorRefTypeArg(final List<TypePathEntry> location,
+                              final JCLambda onLambda,
+                              final int type_index,
+                              final int pos) {
+        return new TypeAnnotationPosition(TargetType.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT,
+                                          pos, Integer.MIN_VALUE, onLambda,
+                                          type_index, Integer.MIN_VALUE,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a constructor reference
+     * type argument.
+     *
+     * @param location The type path.
+     * @param parameter_index The index of the type argument.
+     */
+    public static TypeAnnotationPosition
+        constructorRefTypeArg(final List<TypePathEntry> location,
+                              final int type_index) {
+        return constructorRefTypeArg(location, null, type_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a type parameter bound.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param parameter_index The index of the type parameter.
+     * @param bound_index The index of the type parameter bound.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        typeParameterBound(final List<TypePathEntry> location,
+                           final JCLambda onLambda,
+                           final int parameter_index,
+                           final int bound_index,
+                           final int pos) {
+        return new TypeAnnotationPosition(TargetType.CLASS_TYPE_PARAMETER_BOUND,
+                                          pos, parameter_index, onLambda,
+                                          Integer.MIN_VALUE, bound_index,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a type parameter bound.
+     *
+     * @param location The type path.
+     * @param parameter_index The index of the type parameter.
+     * @param bound_index The index of the type parameter bound.
+     */
+    public static TypeAnnotationPosition
+        typeParameterBound(final List<TypePathEntry> location,
+                           final int parameter_index,
+                           final int bound_index) {
+        return typeParameterBound(location, null, parameter_index,
+                                  bound_index, -1);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method type
+     * parameter bound.
+     *
+     * @param location The type path.
+     * @param onLambda The lambda for this variable.
+     * @param parameter_index The index of the type parameter.
+     * @param bound_index The index of the type parameter bound.
+     * @param pos The position from the associated tree node.
+     */
+    public static TypeAnnotationPosition
+        methodTypeParameterBound(final List<TypePathEntry> location,
+                                 final JCLambda onLambda,
+                                 final int parameter_index,
+                                 final int bound_index,
+                                 final int pos) {
+        return new TypeAnnotationPosition(TargetType.METHOD_TYPE_PARAMETER_BOUND,
+                                          pos, parameter_index, onLambda,
+                                          Integer.MIN_VALUE, bound_index,
+                                          location);
+    }
+
+    /**
+     * Create a {@code TypeAnnotationPosition} for a method type
+     * parameter bound.
+     *
+     * @param location The type path.
+     * @param parameter_index The index of the type parameter.
+     * @param bound_index The index of the type parameter bound.
+     */
+    public static TypeAnnotationPosition
+        methodTypeParameterBound(final List<TypePathEntry> location,
+                                 final int parameter_index,
+                                 final int bound_index) {
+        return methodTypeParameterBound(location, null, parameter_index,
+                                        bound_index, -1);
+    }
+
+    // Consider this deprecated on arrival.  We eventually want to get
+    // rid of this value altogether.  Do not use it for anything new.
+    public static final TypeAnnotationPosition unknown =
+        new TypeAnnotationPosition(TargetType.UNKNOWN, -1,
+                                   Integer.MIN_VALUE, null,
+                                   Integer.MIN_VALUE, Integer.MIN_VALUE,
+                                   emptyPath);
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Tue Feb 11 11:25:59 2014 -0800
@@ -663,8 +663,15 @@
          * type annotations: determine the type annotation positions.
          */
 
-        private void resolveFrame(JCTree tree, JCTree frame,
-                List<JCTree> path, TypeAnnotationPosition p) {
+        // This method is considered deprecated, and will be removed
+        // in the near future.  Don't use it for anything new.
+        private TypeAnnotationPosition
+            resolveFrame(JCTree tree,
+                         JCTree frame,
+                         List<JCTree> path,
+                         JCLambda currentLambda,
+                         int outer_type_index,
+                         ListBuffer<TypePathEntry> location) {
             /*
             System.out.println("Resolving tree: " + tree + " kind: " + tree.getKind());
             System.out.println("    Framing tree: " + frame + " kind: " + frame.getKind());
@@ -675,87 +682,101 @@
 
             switch (frame.getKind()) {
                 case TYPE_CAST:
-                    JCTypeCast frameTC = (JCTypeCast) frame;
-                    p.type = TargetType.CAST;
-                    if (frameTC.clazz.hasTag(Tag.TYPEINTERSECTION)) {
-                        // This case was already handled by INTERSECTION_TYPE
-                    } else {
-                        p.type_index = 0;
-                    }
-                    p.pos = frame.pos;
-                    return;
+                    return TypeAnnotationPosition.typeCast(location.toList(),
+                                                           currentLambda,
+                                                           outer_type_index,
+                                                           frame.pos);
 
                 case INSTANCE_OF:
-                    p.type = TargetType.INSTANCEOF;
-                    p.pos = frame.pos;
-                    return;
+                    return TypeAnnotationPosition.instanceOf(location.toList(),
+                                                             currentLambda,
+                                                             frame.pos);
 
                 case NEW_CLASS:
-                    JCNewClass frameNewClass = (JCNewClass) frame;
+                    final JCNewClass frameNewClass = (JCNewClass) frame;
                     if (frameNewClass.def != null) {
                         // Special handling for anonymous class instantiations
-                        JCClassDecl frameClassDecl = frameNewClass.def;
+                        final JCClassDecl frameClassDecl = frameNewClass.def;
                         if (frameClassDecl.extending == tree) {
-                            p.type = TargetType.CLASS_EXTENDS;
-                            p.type_index = -1;
+                            return TypeAnnotationPosition
+                                .classExtends(location.toList(), currentLambda,
+                                              frame.pos);
                         } else if (frameClassDecl.implementing.contains(tree)) {
-                            p.type = TargetType.CLASS_EXTENDS;
-                            p.type_index = frameClassDecl.implementing.indexOf(tree);
+                            final int type_index =
+                                frameClassDecl.implementing.indexOf(tree);
+                            return TypeAnnotationPosition
+                                .classExtends(location.toList(), currentLambda,
+                                              type_index, frame.pos);
                         } else {
                             // In contrast to CLASS below, typarams cannot occur here.
-                            Assert.error("Could not determine position of tree " + tree +
-                                    " within frame " + frame);
+                            throw new AssertionError("Could not determine position of tree " + tree +
+                                                     " within frame " + frame);
                         }
                     } else if (frameNewClass.typeargs.contains(tree)) {
-                        p.type = TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT;
-                        p.type_index = frameNewClass.typeargs.indexOf(tree);
+                        final int type_index =
+                            frameNewClass.typeargs.indexOf(tree);
+                        return TypeAnnotationPosition
+                            .constructorInvocationTypeArg(location.toList(),
+                                                          currentLambda,
+                                                          type_index,
+                                                          frame.pos);
                     } else {
-                        p.type = TargetType.NEW;
+                        return TypeAnnotationPosition
+                            .newObj(location.toList(), currentLambda,
+                                    frame.pos);
                     }
-                    p.pos = frame.pos;
-                    return;
 
                 case NEW_ARRAY:
-                    p.type = TargetType.NEW;
-                    p.pos = frame.pos;
-                    return;
+                    return TypeAnnotationPosition
+                        .newObj(location.toList(), currentLambda, frame.pos);
 
                 case ANNOTATION_TYPE:
                 case CLASS:
                 case ENUM:
                 case INTERFACE:
-                    p.pos = frame.pos;
                     if (((JCClassDecl)frame).extending == tree) {
-                        p.type = TargetType.CLASS_EXTENDS;
-                        p.type_index = -1;
+                        return TypeAnnotationPosition
+                            .classExtends(location.toList(), currentLambda,
+                                          frame.pos);
                     } else if (((JCClassDecl)frame).implementing.contains(tree)) {
-                        p.type = TargetType.CLASS_EXTENDS;
-                        p.type_index = ((JCClassDecl)frame).implementing.indexOf(tree);
+                        final int type_index =
+                            ((JCClassDecl)frame).implementing.indexOf(tree);
+                        return TypeAnnotationPosition
+                            .classExtends(location.toList(), currentLambda,
+                                          type_index, frame.pos);
                     } else if (((JCClassDecl)frame).typarams.contains(tree)) {
-                        p.type = TargetType.CLASS_TYPE_PARAMETER;
-                        p.parameter_index = ((JCClassDecl)frame).typarams.indexOf(tree);
+                        final int parameter_index =
+                            ((JCClassDecl)frame).typarams.indexOf(tree);
+                        return TypeAnnotationPosition
+                            .typeParameter(location.toList(), currentLambda,
+                                           parameter_index, frame.pos);
                     } else {
-                        Assert.error("Could not determine position of tree " + tree +
-                                " within frame " + frame);
+                        throw new AssertionError("Could not determine position of tree " +
+                                                 tree + " within frame " + frame);
                     }
-                    return;
 
                 case METHOD: {
-                    JCMethodDecl frameMethod = (JCMethodDecl) frame;
-                    p.pos = frame.pos;
+                    final JCMethodDecl frameMethod = (JCMethodDecl) frame;
                     if (frameMethod.thrown.contains(tree)) {
-                        p.type = TargetType.THROWS;
-                        p.type_index = frameMethod.thrown.indexOf(tree);
+                        final int type_index = frameMethod.thrown.indexOf(tree);
+                        return TypeAnnotationPosition
+                            .methodThrows(location.toList(), currentLambda,
+                                          type_index, frame.pos);
                     } else if (frameMethod.restype == tree) {
-                        p.type = TargetType.METHOD_RETURN;
+                        return TypeAnnotationPosition
+                            .methodReturn(location.toList(), currentLambda,
+                                          frame.pos);
                     } else if (frameMethod.typarams.contains(tree)) {
-                        p.type = TargetType.METHOD_TYPE_PARAMETER;
-                        p.parameter_index = frameMethod.typarams.indexOf(tree);
+                        final int parameter_index =
+                            frameMethod.typarams.indexOf(tree);
+                        return TypeAnnotationPosition
+                            .methodTypeParameter(location.toList(),
+                                                 currentLambda,
+                                                 parameter_index, frame.pos);
                     } else {
-                        Assert.error("Could not determine position of tree " + tree +
-                                " within frame " + frame);
+                        throw new AssertionError("Could not determine position of tree " + tree +
+                                                 " within frame " + frame);
                     }
-                    return;
                 }
 
                 case PARAMETERIZED_TYPE: {
@@ -766,25 +787,30 @@
                     } else if (((JCTypeApply)frame).arguments.contains(tree)) {
                         JCTypeApply taframe = (JCTypeApply) frame;
                         int arg = taframe.arguments.indexOf(tree);
-                        p.location = p.location.prepend(new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT, arg));
+                        location = location.prepend(
+                            new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT,
+                                              arg));
 
                         Type typeToUse;
-                        if (newPath.tail != null && newPath.tail.head.hasTag(Tag.NEWCLASS)) {
-                            // If we are within an anonymous class instantiation, use its type,
-                            // because it contains a correctly nested type.
+                        if (newPath.tail != null &&
+                            newPath.tail.head.hasTag(Tag.NEWCLASS)) {
+                            // If we are within an anonymous class
+                            // instantiation, use its type, because it
+                            // contains a correctly nested type.
                             typeToUse = newPath.tail.head.type;
                         } else {
                             typeToUse = taframe.type;
                         }
 
-                        locateNestedTypes(typeToUse, p);
+                        location = locateNestedTypes(typeToUse, location);
                     } else {
-                        Assert.error("Could not determine type argument position of tree " + tree +
-                                " within frame " + frame);
+                        throw new AssertionError("Could not determine type argument position of tree " + tree +
+                                                 " within frame " + frame);
                     }
 
-                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
-                    return;
+                    return resolveFrame(newPath.head, newPath.tail.head,
+                                        newPath, currentLambda,
+                                        outer_type_index, location);
                 }
 
                 case MEMBER_REFERENCE: {
@@ -793,117 +819,140 @@
                     if (mrframe.expr == tree) {
                         switch (mrframe.mode) {
                         case INVOKE:
-                            p.type = TargetType.METHOD_REFERENCE;
-                            break;
+                            return TypeAnnotationPosition
+                                .methodRef(location.toList(), currentLambda,
+                                           frame.pos);
                         case NEW:
-                            p.type = TargetType.CONSTRUCTOR_REFERENCE;
-                            break;
+                            return TypeAnnotationPosition
+                                .constructorRef(location.toList(),
+                                                currentLambda,
+                                                frame.pos);
                         default:
-                            Assert.error("Unknown method reference mode " + mrframe.mode +
-                                    " for tree " + tree + " within frame " + frame);
+                            throw new AssertionError("Unknown method reference mode " + mrframe.mode +
+                                                     " for tree " + tree + " within frame " + frame);
                         }
-                        p.pos = frame.pos;
                     } else if (mrframe.typeargs != null &&
                             mrframe.typeargs.contains(tree)) {
-                        int arg = mrframe.typeargs.indexOf(tree);
-                        p.type_index = arg;
+                        final int type_index = mrframe.typeargs.indexOf(tree);
                         switch (mrframe.mode) {
                         case INVOKE:
-                            p.type = TargetType.METHOD_REFERENCE_TYPE_ARGUMENT;
-                            break;
+                            return TypeAnnotationPosition
+                                .methodRefTypeArg(location.toList(),
+                                                  currentLambda,
+                                                  type_index, frame.pos);
                         case NEW:
-                            p.type = TargetType.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT;
-                            break;
+                            return TypeAnnotationPosition
+                                .constructorRefTypeArg(location.toList(),
+                                                       currentLambda,
+                                                       type_index, frame.pos);
                         default:
-                            Assert.error("Unknown method reference mode " + mrframe.mode +
-                                    " for tree " + tree + " within frame " + frame);
+                            throw new AssertionError("Unknown method reference mode " + mrframe.mode +
+                                                   " for tree " + tree + " within frame " + frame);
                         }
-                        p.pos = frame.pos;
                     } else {
-                        Assert.error("Could not determine type argument position of tree " + tree +
-                                " within frame " + frame);
+                        throw new AssertionError("Could not determine type argument position of tree " + tree +
+                                               " within frame " + frame);
                     }
-                    return;
                 }
 
                 case ARRAY_TYPE: {
-                    ListBuffer<TypePathEntry> index = new ListBuffer<>();
-                    index = index.append(TypePathEntry.ARRAY);
+                    location = location.prepend(TypePathEntry.ARRAY);
                     List<JCTree> newPath = path.tail;
                     while (true) {
                         JCTree npHead = newPath.tail.head;
                         if (npHead.hasTag(JCTree.Tag.TYPEARRAY)) {
                             newPath = newPath.tail;
-                            index = index.append(TypePathEntry.ARRAY);
+                            location = location.prepend(TypePathEntry.ARRAY);
                         } else if (npHead.hasTag(JCTree.Tag.ANNOTATED_TYPE)) {
                             newPath = newPath.tail;
                         } else {
                             break;
                         }
                     }
-                    p.location = p.location.prependList(index.toList());
-                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
-                    return;
+                    return resolveFrame(newPath.head, newPath.tail.head,
+                                        newPath, currentLambda,
+                                        outer_type_index, location);
                 }
 
                 case TYPE_PARAMETER:
                     if (path.tail.tail.head.hasTag(JCTree.Tag.CLASSDEF)) {
-                        JCClassDecl clazz = (JCClassDecl)path.tail.tail.head;
-                        p.type = TargetType.CLASS_TYPE_PARAMETER_BOUND;
-                        p.parameter_index = clazz.typarams.indexOf(path.tail.head);
-                        p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree);
-                        if (((JCTypeParameter)frame).bounds.get(0).type.isInterface()) {
-                            // Account for an implicit Object as bound 0
-                            p.bound_index += 1;
-                        }
+                        final JCClassDecl clazz =
+                            (JCClassDecl)path.tail.tail.head;
+                        final int parameter_index =
+                            clazz.typarams.indexOf(path.tail.head);
+                        final int bound_index =
+                            ((JCTypeParameter)frame).bounds.get(0)
+                            .type.isInterface() ?
+                            ((JCTypeParameter)frame).bounds.indexOf(tree) + 1:
+                            ((JCTypeParameter)frame).bounds.indexOf(tree);
+                        return TypeAnnotationPosition
+                            .typeParameterBound(location.toList(),
+                                                currentLambda,
+                                                parameter_index, bound_index,
+                                                frame.pos);
                     } else if (path.tail.tail.head.hasTag(JCTree.Tag.METHODDEF)) {
-                        JCMethodDecl method = (JCMethodDecl)path.tail.tail.head;
-                        p.type = TargetType.METHOD_TYPE_PARAMETER_BOUND;
-                        p.parameter_index = method.typarams.indexOf(path.tail.head);
-                        p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree);
-                        if (((JCTypeParameter)frame).bounds.get(0).type.isInterface()) {
-                            // Account for an implicit Object as bound 0
-                            p.bound_index += 1;
-                        }
+                        final JCMethodDecl method =
+                            (JCMethodDecl)path.tail.tail.head;
+                        final int parameter_index =
+                            method.typarams.indexOf(path.tail.head);
+                        final int bound_index =
+                            ((JCTypeParameter)frame).bounds.get(0)
+                            .type.isInterface() ?
+                            ((JCTypeParameter)frame).bounds.indexOf(tree) + 1:
+                            ((JCTypeParameter)frame).bounds.indexOf(tree);
+                        return TypeAnnotationPosition
+                            .methodTypeParameterBound(location.toList(),
+                                                      currentLambda,
+                                                      parameter_index,
+                                                      bound_index,
+                                                      frame.pos);
                     } else {
-                        Assert.error("Could not determine position of tree " + tree +
-                                " within frame " + frame);
+                        throw new AssertionError("Could not determine position of tree " + tree +
+                                                 " within frame " + frame);
                     }
-                    p.pos = frame.pos;
-                    return;
 
                 case VARIABLE:
                     VarSymbol v = ((JCVariableDecl)frame).sym;
-                    p.pos = frame.pos;
-                    switch (v.getKind()) {
-                        case LOCAL_VARIABLE:
-                            p.type = TargetType.LOCAL_VARIABLE;
-                            break;
-                        case FIELD:
-                            p.type = TargetType.FIELD;
-                            break;
-                        case PARAMETER:
-                            if (v.getQualifiedName().equals(names._this)) {
-                                // TODO: Intro a separate ElementKind?
-                                p.type = TargetType.METHOD_RECEIVER;
-                            } else {
-                                p.type = TargetType.METHOD_FORMAL_PARAMETER;
-                                p.parameter_index = methodParamIndex(path, frame);
-                            }
-                            break;
-                        case EXCEPTION_PARAMETER:
-                            p.type = TargetType.EXCEPTION_PARAMETER;
-                            break;
-                        case RESOURCE_VARIABLE:
-                            p.type = TargetType.RESOURCE_VARIABLE;
-                            break;
-                        default:
-                            Assert.error("Found unexpected type annotation for variable: " + v + " with kind: " + v.getKind());
-                    }
                     if (v.getKind() != ElementKind.FIELD) {
                         v.owner.appendUniqueTypeAttributes(v.getRawTypeAttributes());
                     }
-                    return;
+                    switch (v.getKind()) {
+                        case LOCAL_VARIABLE:
+                            return TypeAnnotationPosition
+                                .localVariable(location.toList(), currentLambda,
+                                               frame.pos);
+                        case FIELD:
+                            return TypeAnnotationPosition.field(location.toList(),
+                                                                currentLambda,
+                                                                frame.pos);
+                        case PARAMETER:
+                            if (v.getQualifiedName().equals(names._this)) {
+                                return TypeAnnotationPosition
+                                    .methodReceiver(location.toList(),
+                                                    currentLambda,
+                                                    frame.pos);
+                            } else {
+                                final int parameter_index =
+                                    methodParamIndex(path, frame);
+                                return TypeAnnotationPosition
+                                    .methodParameter(location.toList(),
+                                                     currentLambda,
+                                                     parameter_index,
+                                                     frame.pos);
+                            }
+                        case EXCEPTION_PARAMETER:
+                            return TypeAnnotationPosition
+                                .exceptionParameter(location.toList(),
+                                                    currentLambda,
+                                                    frame.pos);
+                        case RESOURCE_VARIABLE:
+                            return TypeAnnotationPosition
+                                .resourceVariable(location.toList(),
+                                                  currentLambda,
+                                                  frame.pos);
+                        default:
+                            throw new AssertionError("Found unexpected type annotation for variable: " + v + " with kind: " + v.getKind());
+                    }
 
                 case ANNOTATED_TYPE: {
                     if (frame == tree) {
@@ -912,11 +961,7 @@
                         // not care about inner types.
                         JCAnnotatedType atypetree = (JCAnnotatedType) frame;
                         final Type utype = atypetree.underlyingType.type;
-                        if (utype == null) {
-                            // This might happen during DeferredAttr;
-                            // we will be back later.
-                            return;
-                        }
+                        Assert.checkNonNull(utype);
                         Symbol tsym = utype.tsym;
                         if (tsym.getKind().equals(ElementKind.TYPE_PARAMETER) ||
                                 utype.getKind().equals(TypeKind.WILDCARD) ||
@@ -925,83 +970,89 @@
                             // class/method as enclosing elements.
                             // There is actually nothing to do for them.
                         } else {
-                            locateNestedTypes(utype, p);
+                            location = locateNestedTypes(utype, location);
                         }
                     }
                     List<JCTree> newPath = path.tail;
-                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
-                    return;
+                    return resolveFrame(newPath.head, newPath.tail.head,
+                                        newPath, currentLambda,
+                                        outer_type_index, location);
                 }
 
                 case UNION_TYPE: {
                     List<JCTree> newPath = path.tail;
-                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
-                    return;
+                    return resolveFrame(newPath.head, newPath.tail.head,
+                                        newPath, currentLambda,
+                                        outer_type_index, location);
                 }
 
                 case INTERSECTION_TYPE: {
                     JCTypeIntersection isect = (JCTypeIntersection)frame;
-                    p.type_index = isect.bounds.indexOf(tree);
-                    List<JCTree> newPath = path.tail;
-                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
-                    return;
+                    final List<JCTree> newPath = path.tail;
+                    return resolveFrame(newPath.head, newPath.tail.head,
+                                        newPath, currentLambda,
+                                        isect.bounds.indexOf(tree), location);
                 }
 
                 case METHOD_INVOCATION: {
                     JCMethodInvocation invocation = (JCMethodInvocation)frame;
                     if (!invocation.typeargs.contains(tree)) {
-                        Assert.error("{" + tree + "} is not an argument in the invocation: " + invocation);
+                        throw new AssertionError("{" + tree + "} is not an argument in the invocation: " + invocation);
                     }
                     MethodSymbol exsym = (MethodSymbol) TreeInfo.symbol(invocation.getMethodSelect());
+                    final int type_index = invocation.typeargs.indexOf(tree);
                     if (exsym == null) {
-                        Assert.error("could not determine symbol for {" + invocation + "}");
+                        throw new AssertionError("could not determine symbol for {" + invocation + "}");
                     } else if (exsym.isConstructor()) {
-                        p.type = TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT;
+                        return TypeAnnotationPosition
+                            .constructorInvocationTypeArg(location.toList(),
+                                                          currentLambda,
+                                                          type_index,
+                                                          invocation.pos);
                     } else {
-                        p.type = TargetType.METHOD_INVOCATION_TYPE_ARGUMENT;
+                        return TypeAnnotationPosition
+                            .methodInvocationTypeArg(location.toList(),
+                                                     currentLambda,
+                                                     type_index,
+                                                     invocation.pos);
                     }
-                    p.pos = invocation.pos;
-                    p.type_index = invocation.typeargs.indexOf(tree);
-                    return;
                 }
 
                 case EXTENDS_WILDCARD:
                 case SUPER_WILDCARD: {
                     // Annotations in wildcard bounds
-                    p.location = p.location.prepend(TypePathEntry.WILDCARD);
-                    List<JCTree> newPath = path.tail;
-                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
-                    return;
+                    final List<JCTree> newPath = path.tail;
+                    return resolveFrame(newPath.head, newPath.tail.head,
+                                        newPath, currentLambda,
+                                        outer_type_index,
+                                        location.prepend(TypePathEntry.WILDCARD));
                 }
 
                 case MEMBER_SELECT: {
-                    List<JCTree> newPath = path.tail;
-                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
-                    return;
+                    final List<JCTree> newPath = path.tail;
+                    return resolveFrame(newPath.head, newPath.tail.head,
+                                        newPath, currentLambda,
+                                        outer_type_index, location);
                 }
 
                 default:
-                    Assert.error("Unresolved frame: " + frame + " of kind: " + frame.getKind() +
-                            "\n    Looking for tree: " + tree);
-                    return;
+                    throw new AssertionError("Unresolved frame: " + frame +
+                                             " of kind: " + frame.getKind() +
+                                             "\n    Looking for tree: " + tree);
             }
         }
 
-        private void locateNestedTypes(Type type, TypeAnnotationPosition p) {
-            // The number of "steps" to get from the full type to the
-            // left-most outer type.
-            ListBuffer<TypePathEntry> depth = new ListBuffer<>();
-
+        private ListBuffer<TypePathEntry>
+            locateNestedTypes(Type type,
+                              ListBuffer<TypePathEntry> depth) {
             Type encl = type.getEnclosingType();
             while (encl != null &&
                     encl.getKind() != TypeKind.NONE &&
                     encl.getKind() != TypeKind.ERROR) {
-                depth = depth.append(TypePathEntry.INNER_TYPE);
+                depth = depth.prepend(TypePathEntry.INNER_TYPE);
                 encl = encl.getEnclosingType();
             }
-            if (depth.nonEmpty()) {
-                p.location = p.location.prependList(depth.toList());
-            }
+            return depth;
         }
 
         private int methodParamIndex(List<JCTree> path, JCTree param) {
@@ -1052,18 +1103,18 @@
             }
             if (sigOnly) {
                 if (!tree.mods.annotations.isEmpty()) {
-                    // Nothing to do for separateAnnotationsKinds if
-                    // there are no annotations of either kind.
-                    TypeAnnotationPosition pos = new TypeAnnotationPosition();
-                    pos.type = TargetType.METHOD_RETURN;
                     if (tree.sym.isConstructor()) {
-                        pos.pos = tree.pos;
-                        // Use null to mark that the annotations go with the symbol.
+                        final TypeAnnotationPosition pos =
+                            TypeAnnotationPosition.methodReturn(tree.pos);
+                        // Use null to mark that the annotations go
+                        // with the symbol.
                         separateAnnotationsKinds(tree, null, tree.sym, pos);
                     } else {
-                        pos.pos = tree.restype.pos;
-                        separateAnnotationsKinds(tree.restype, tree.sym.type.getReturnType(),
-                                tree.sym, pos);
+                        final TypeAnnotationPosition pos =
+                            TypeAnnotationPosition.methodReturn(tree.restype.pos);
+                        separateAnnotationsKinds(tree.restype,
+                                                 tree.sym.type.getReturnType(),
+                                                 tree.sym, pos);
                     }
                 }
                 if (tree.recvparam != null && tree.recvparam.sym != null &&
@@ -1071,22 +1122,22 @@
                     // Nothing to do for separateAnnotationsKinds if
                     // there are no annotations of either kind.
                     // TODO: make sure there are no declaration annotations.
-                    TypeAnnotationPosition pos = new TypeAnnotationPosition();
-                    pos.type = TargetType.METHOD_RECEIVER;
-                    pos.pos = tree.recvparam.vartype.pos;
-                    separateAnnotationsKinds(tree.recvparam.vartype, tree.recvparam.sym.type,
-                            tree.recvparam.sym, pos);
+                    final TypeAnnotationPosition pos =
+                        TypeAnnotationPosition.methodReceiver(tree.recvparam.vartype.pos);
+                    separateAnnotationsKinds(tree.recvparam.vartype,
+                                             tree.recvparam.sym.type,
+                                             tree.recvparam.sym, pos);
                 }
                 int i = 0;
                 for (JCVariableDecl param : tree.params) {
                     if (!param.mods.annotations.isEmpty()) {
                         // Nothing to do for separateAnnotationsKinds if
                         // there are no annotations of either kind.
-                        TypeAnnotationPosition pos = new TypeAnnotationPosition();
-                        pos.type = TargetType.METHOD_FORMAL_PARAMETER;
-                        pos.parameter_index = i;
-                        pos.pos = param.vartype.pos;
-                        separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
+                        final TypeAnnotationPosition pos =
+                            TypeAnnotationPosition.methodParameter(i, param.vartype.pos);
+                        separateAnnotationsKinds(param.vartype,
+                                                 param.sym.type,
+                                                 param.sym, pos);
                     }
                     ++i;
                 }
@@ -1123,11 +1174,9 @@
                     if (!param.mods.annotations.isEmpty()) {
                         // Nothing to do for separateAnnotationsKinds if
                         // there are no annotations of either kind.
-                        TypeAnnotationPosition pos = new TypeAnnotationPosition();
-                        pos.type = TargetType.METHOD_FORMAL_PARAMETER;
-                        pos.parameter_index = i;
-                        pos.pos = param.vartype.pos;
-                        pos.onLambda = tree;
+                        final TypeAnnotationPosition pos =
+                            TypeAnnotationPosition.methodParameter(tree, i,
+                                                                   param.vartype.pos);
                         separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
                     }
                     ++i;
@@ -1157,28 +1206,24 @@
                 // Parameters are handled in visitMethodDef or visitLambda.
             } else if (tree.sym.getKind() == ElementKind.FIELD) {
                 if (sigOnly) {
-                    TypeAnnotationPosition pos = new TypeAnnotationPosition();
-                    pos.type = TargetType.FIELD;
-                    pos.pos = tree.pos;
+                    TypeAnnotationPosition pos =
+                        TypeAnnotationPosition.field(tree.pos);
                     separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos);
                 }
             } else if (tree.sym.getKind() == ElementKind.LOCAL_VARIABLE) {
-                TypeAnnotationPosition pos = new TypeAnnotationPosition();
-                pos.type = TargetType.LOCAL_VARIABLE;
-                pos.pos = tree.pos;
-                pos.onLambda = currentLambda;
+                final TypeAnnotationPosition pos =
+                    TypeAnnotationPosition.localVariable(currentLambda,
+                                                         tree.pos);
                 separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos);
             } else if (tree.sym.getKind() == ElementKind.EXCEPTION_PARAMETER) {
-                TypeAnnotationPosition pos = new TypeAnnotationPosition();
-                pos.type = TargetType.EXCEPTION_PARAMETER;
-                pos.pos = tree.pos;
-                pos.onLambda = currentLambda;
+                final TypeAnnotationPosition pos =
+                    TypeAnnotationPosition.exceptionParameter(currentLambda,
+                                                              tree.pos);
                 separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos);
             } else if (tree.sym.getKind() == ElementKind.RESOURCE_VARIABLE) {
-                TypeAnnotationPosition pos = new TypeAnnotationPosition();
-                pos.type = TargetType.RESOURCE_VARIABLE;
-                pos.pos = tree.pos;
-                pos.onLambda = currentLambda;
+                final TypeAnnotationPosition pos =
+                    TypeAnnotationPosition.resourceVariable(currentLambda,
+                                                            tree.pos);
                 separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos);
             } else if (tree.sym.getKind() == ElementKind.ENUM_CONSTANT) {
                 // No type annotations can occur here.
@@ -1222,7 +1267,8 @@
 
         private void copyNewClassAnnotationsToOwner(JCNewClass tree) {
             Symbol sym = tree.def.sym;
-            TypeAnnotationPosition pos = new TypeAnnotationPosition();
+            final TypeAnnotationPosition pos =
+                TypeAnnotationPosition.newObj(tree.pos);
             ListBuffer<Attribute.TypeCompound> newattrs = new ListBuffer<>();
 
             for (Attribute.TypeCompound old : sym.getRawTypeAttributes()) {
@@ -1230,8 +1276,6 @@
                                                            pos));
             }
 
-            pos.type = TargetType.NEW;
-            pos.pos = tree.pos;
             sym.owner.appendUniqueTypeAttributes(newattrs.toList());
         }
 
@@ -1240,16 +1284,16 @@
             if (tree.def != null &&
                     !tree.def.mods.annotations.isEmpty()) {
                 JCClassDecl classdecl = tree.def;
-                TypeAnnotationPosition pos = new TypeAnnotationPosition();
-                pos.type = TargetType.CLASS_EXTENDS;
-                pos.pos = tree.pos;
+                TypeAnnotationPosition pos;
+
                 if (classdecl.extending == tree.clazz) {
-                    pos.type_index = -1;
+                    pos = TypeAnnotationPosition.classExtends(tree.pos);
                 } else if (classdecl.implementing.contains(tree.clazz)) {
-                    pos.type_index = classdecl.implementing.indexOf(tree.clazz);
+                    final int index = classdecl.implementing.indexOf(tree.clazz);
+                    pos = TypeAnnotationPosition.classExtends(index, tree.pos);
                 } else {
                     // In contrast to CLASS elsewhere, typarams cannot occur here.
-                    Assert.error("Could not determine position of tree " + tree);
+                    throw new AssertionError("Could not determine position of tree " + tree);
                 }
                 Type before = classdecl.sym.type;
                 separateAnnotationsKinds(classdecl, tree.clazz.type, classdecl.sym, pos);
@@ -1277,14 +1321,16 @@
 
             // handle annotations associated with dimensions
             for (int i = 0; i < dimAnnosCount; ++i) {
-                TypeAnnotationPosition p = new TypeAnnotationPosition();
-                p.pos = tree.pos;
-                p.onLambda = currentLambda;
-                p.type = TargetType.NEW;
+                ListBuffer<TypePathEntry> location =
+                    new ListBuffer<TypePathEntry>();
                 if (i != 0) {
                     depth = depth.append(TypePathEntry.ARRAY);
-                    p.location = p.location.appendList(depth.toList());
+                    location = location.appendList(depth.toList());
                 }
+                final TypeAnnotationPosition p =
+                    TypeAnnotationPosition.newObj(location.toList(),
+                                                  currentLambda,
+                                                  tree.pos);
 
                 setTypeAnnotationPos(tree.dimAnnotations.get(i), p);
             }
@@ -1297,12 +1343,14 @@
             while (elemType != null) {
                 if (elemType.hasTag(JCTree.Tag.ANNOTATED_TYPE)) {
                     JCAnnotatedType at = (JCAnnotatedType)elemType;
-                    TypeAnnotationPosition p = new TypeAnnotationPosition();
-                    p.type = TargetType.NEW;
-                    p.pos = tree.pos;
-                    p.onLambda = currentLambda;
-                    locateNestedTypes(elemType.type, p);
-                    p.location = p.location.prependList(depth.toList());
+                    final ListBuffer<TypePathEntry> locationbuf =
+                        locateNestedTypes(elemType.type,
+                                          new ListBuffer<TypePathEntry>());
+                    final List<TypePathEntry> location =
+                        locationbuf.toList().prependList(depth.toList());
+                    final TypeAnnotationPosition p =
+                        TypeAnnotationPosition.newObj(location, currentLambda,
+                                                      tree.pos);
                     setTypeAnnotationPos(at.annotations, p);
                     elemType = at.underlyingType;
                 } else if (elemType.hasTag(JCTree.Tag.TYPEARRAY)) {
@@ -1324,9 +1372,9 @@
                 System.err.println("    tree: " + tree + " kind: " + tree.getKind());
                 System.err.println("    frame: " + frame + " kind: " + frame.getKind());
                 */
-                TypeAnnotationPosition p = new TypeAnnotationPosition();
-                p.onLambda = currentLambda;
-                resolveFrame(tree, frame, frames.toList(), p);
+                final TypeAnnotationPosition p =
+                    resolveFrame(tree, frame, frames.toList(), currentLambda, 0,
+                                 new ListBuffer<TypePathEntry>());
                 setTypeAnnotationPos(annotations, p);
             }
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Tue Feb 11 11:25:59 2014 -0800
@@ -299,7 +299,13 @@
         if (typeAnnotation) {
             if (a.attribute == null || !(a.attribute instanceof Attribute.TypeCompound)) {
                 // Create a new TypeCompound
-                Attribute.TypeCompound tc = new Attribute.TypeCompound(a.type, buf.toList(), new TypeAnnotationPosition());
+
+                Attribute.TypeCompound tc =
+                    new Attribute.TypeCompound(a.type, buf.toList(),
+                // TODO: Eventually, we will get rid of this use of
+                // unknown, because we'll get a position from
+                // MemberEnter (task 8027262).
+                                               TypeAnnotationPosition.unknown);
                 a.attribute = tc;
                 return tc;
             } else {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Feb 11 11:25:59 2014 -0800
@@ -4078,11 +4078,9 @@
             @Override
             public void run() {
                 List<Attribute.TypeCompound> compounds = fromAnnotations(annotations);
-                if (annotations.size() == compounds.size()) {
-                    // All annotations were successfully converted into compounds
+                Assert.check(annotations.size() == compounds.size());
                     tree.type = tree.type.unannotatedType().annotatedType(compounds);
                 }
-            }
         });
     }
 
@@ -4093,18 +4091,8 @@
 
         ListBuffer<Attribute.TypeCompound> buf = new ListBuffer<>();
         for (JCAnnotation anno : annotations) {
-            if (anno.attribute != null) {
-                // TODO: this null-check is only needed for an obscure
-                // ordering issue, where annotate.flush is called when
-                // the attribute is not set yet. For an example failure
-                // try the referenceinfos/NestedTypes.java test.
-                // Any better solutions?
-                buf.append((Attribute.TypeCompound) anno.attribute);
-            }
-            // Eventually we will want to throw an exception here, but
-            // we can't do that just yet, because it gets triggered
-            // when attempting to attach an annotation that isn't
-            // defined.
+            Assert.checkNonNull(anno.attribute);
+            buf.append((Attribute.TypeCompound) anno.attribute);
         }
         return buf.toList();
     }
@@ -4661,10 +4649,19 @@
 
         private void initTypeIfNeeded(JCTree that) {
             if (that.type == null) {
-                that.type = syms.unknownType;
+                if (that.hasTag(METHODDEF)) {
+                    that.type = dummyMethodType();
+                } else {
+                    that.type = syms.unknownType;
+                }
             }
         }
 
+        private Type dummyMethodType() {
+            return new MethodType(List.<Type>nil(), syms.unknownType,
+                            List.<Type>nil(), syms.methodClass);
+        }
+
         @Override
         public void scan(JCTree tree) {
             if (tree == null) return;
@@ -4720,7 +4717,8 @@
         @Override
         public void visitNewClass(JCNewClass that) {
             if (that.constructor == null) {
-                that.constructor = new MethodSymbol(0, names.init, syms.unknownType, syms.noSymbol);
+                that.constructor = new MethodSymbol(0, names.init,
+                        dummyMethodType(), syms.noSymbol);
             }
             if (that.constructorType == null) {
                 that.constructorType = syms.unknownType;
@@ -4730,22 +4728,28 @@
 
         @Override
         public void visitAssignop(JCAssignOp that) {
-            if (that.operator == null)
-                that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol);
+            if (that.operator == null) {
+                that.operator = new OperatorSymbol(names.empty, dummyMethodType(),
+                        -1, syms.noSymbol);
+            }
             super.visitAssignop(that);
         }
 
         @Override
         public void visitBinary(JCBinary that) {
-            if (that.operator == null)
-                that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol);
+            if (that.operator == null) {
+                that.operator = new OperatorSymbol(names.empty, dummyMethodType(),
+                        -1, syms.noSymbol);
+            }
             super.visitBinary(that);
         }
 
         @Override
         public void visitUnary(JCUnary that) {
-            if (that.operator == null)
-                that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol);
+            if (that.operator == null) {
+                that.operator = new OperatorSymbol(names.empty, dummyMethodType(),
+                        -1, syms.noSymbol);
+            }
             super.visitUnary(that);
         }
 
@@ -4761,7 +4765,8 @@
         public void visitReference(JCMemberReference that) {
             super.visitReference(that);
             if (that.sym == null) {
-                that.sym = new MethodSymbol(0, names.empty, syms.unknownType, syms.noSymbol);
+                that.sym = new MethodSymbol(0, names.empty, dummyMethodType(),
+                        syms.noSymbol);
             }
             if (that.targets == null) {
                 that.targets = List.nil();
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2778,7 +2778,7 @@
         validateDocumented(t.tsym, s, pos);
         validateInherited(t.tsym, s, pos);
         validateTarget(t.tsym, s, pos);
-        validateDefault(t.tsym, s, pos);
+        validateDefault(t.tsym, pos);
     }
 
     private void validateValue(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) {
@@ -2897,7 +2897,9 @@
 
 
     /** Checks that s is a subset of t, with respect to ElementType
-     * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE}
+     * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE},
+     * and {TYPE_USE} covers the set {ANNOTATION_TYPE, TYPE, TYPE_USE,
+     * TYPE_PARAMETER}.
      */
     private boolean isTargetSubsetOf(Set<Name> s, Set<Name> t) {
         // Check that all elements in s are present in t
@@ -2910,6 +2912,12 @@
                 } else if (n1 == names.TYPE && n2 == names.ANNOTATION_TYPE) {
                     currentElementOk = true;
                     break;
+                } else if (n1 == names.TYPE_USE &&
+                        (n2 == names.TYPE ||
+                         n2 == names.ANNOTATION_TYPE ||
+                         n2 == names.TYPE_PARAMETER)) {
+                    currentElementOk = true;
+                    break;
                 }
             }
             if (!currentElementOk)
@@ -2918,7 +2926,7 @@
         return true;
     }
 
-    private void validateDefault(Symbol container, Symbol contained, DiagnosticPosition pos) {
+    private void validateDefault(Symbol container, DiagnosticPosition pos) {
         // validate that all other elements of containing type has defaults
         Scope scope = container.members();
         for(Symbol elm : scope.getElements()) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,6 +96,9 @@
     /** dump statistics about lambda code generation */
     private boolean dumpLambdaToMethodStats;
 
+    /** force serializable representation, for stress testing **/
+    private final boolean forceSerializable;
+
     /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */
     public static final int FLAG_SERIALIZABLE = 1 << 0;
 
@@ -130,6 +133,7 @@
         Options options = Options.instance(context);
         dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats");
         attr = Attr.instance(context);
+        forceSerializable = options.isSet("forceSerializable");
     }
     // </editor-fold>
 
@@ -1692,6 +1696,9 @@
 
             /** does this functional expression require serialization support? */
             boolean isSerializable() {
+                if (forceSerializable) {
+                    return true;
+                }
                 for (Type target : tree.targets) {
                     if (types.asSuper(target, syms.serializableType.tsym) != null) {
                         return true;
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1469,26 +1469,63 @@
         if (!TargetType.isValidTargetTypeValue(tag))
             throw this.badClassFile("bad.type.annotation.value", String.format("0x%02X", tag));
 
-        TypeAnnotationPosition position = new TypeAnnotationPosition();
         TargetType type = TargetType.fromTargetTypeValue(tag);
 
-        position.type = type;
-
         switch (type) {
         // instanceof
-        case INSTANCEOF:
+        case INSTANCEOF: {
+            final int offset = nextChar();
+            final TypeAnnotationPosition position =
+                TypeAnnotationPosition.instanceOf(readTypePath());
+            position.offset = offset;
+            return position;
+        }
         // new expression
-        case NEW:
+        case NEW: {
+            final int offset = nextChar();
+            final TypeAnnotationPosition position =
+                TypeAnnotationPosition.newObj(readTypePath());
+            position.offset = offset;
+            return position;
+        }
         // constructor/method reference receiver
-        case CONSTRUCTOR_REFERENCE:
-        case METHOD_REFERENCE:
-            position.offset = nextChar();
-            break;
+        case CONSTRUCTOR_REFERENCE: {
+            final int offset = nextChar();
+            final TypeAnnotationPosition position =
+                TypeAnnotationPosition.constructorRef(readTypePath());
+            position.offset = offset;
+            return position;
+        }
+        case METHOD_REFERENCE: {
+            final int offset = nextChar();
+            final TypeAnnotationPosition position =
+                TypeAnnotationPosition.methodRef(readTypePath());
+            position.offset = offset;
+            return position;
+        }
         // local variable
-        case LOCAL_VARIABLE:
+        case LOCAL_VARIABLE: {
+            final int table_length = nextChar();
+            final TypeAnnotationPosition position =
+                TypeAnnotationPosition.localVariable(readTypePath());
+
+            position.lvarOffset = new int[table_length];
+            position.lvarLength = new int[table_length];
+            position.lvarIndex = new int[table_length];
+
+            for (int i = 0; i < table_length; ++i) {
+                position.lvarOffset[i] = nextChar();
+                position.lvarLength[i] = nextChar();
+                position.lvarIndex[i] = nextChar();
+            }
+            return position;
+        }
         // resource variable
-        case RESOURCE_VARIABLE:
-            int table_length = nextChar();
+        case RESOURCE_VARIABLE: {
+            final int table_length = nextChar();
+            final TypeAnnotationPosition position =
+                TypeAnnotationPosition.resourceVariable(readTypePath());
+
             position.lvarOffset = new int[table_length];
             position.lvarLength = new int[table_length];
             position.lvarIndex = new int[table_length];
@@ -1498,67 +1535,125 @@
                 position.lvarLength[i] = nextChar();
                 position.lvarIndex[i] = nextChar();
             }
-            break;
+            return position;
+        }
         // exception parameter
-        case EXCEPTION_PARAMETER:
-            position.exception_index = nextChar();
-            break;
+        case EXCEPTION_PARAMETER: {
+            final int exception_index = nextChar();
+            final TypeAnnotationPosition position =
+                TypeAnnotationPosition.exceptionParameter(readTypePath());
+            position.exception_index = exception_index;
+            return position;
+        }
         // method receiver
         case METHOD_RECEIVER:
-            // Do nothing
-            break;
+            return TypeAnnotationPosition.methodReceiver(readTypePath());
         // type parameter
-        case CLASS_TYPE_PARAMETER:
-        case METHOD_TYPE_PARAMETER:
-            position.parameter_index = nextByte();
-            break;
+        case CLASS_TYPE_PARAMETER: {
+            final int parameter_index = nextByte();
+            return TypeAnnotationPosition
+                .typeParameter(readTypePath(), parameter_index);
+        }
+        case METHOD_TYPE_PARAMETER: {
+            final int parameter_index = nextByte();
+            return TypeAnnotationPosition
+                .methodTypeParameter(readTypePath(), parameter_index);
+        }
         // type parameter bound
-        case CLASS_TYPE_PARAMETER_BOUND:
-        case METHOD_TYPE_PARAMETER_BOUND:
-            position.parameter_index = nextByte();
-            position.bound_index = nextByte();
-            break;
+        case CLASS_TYPE_PARAMETER_BOUND: {
+            final int parameter_index = nextByte();
+            final int bound_index = nextByte();
+            return TypeAnnotationPosition
+                .typeParameterBound(readTypePath(), parameter_index,
+                                    bound_index);
+        }
+        case METHOD_TYPE_PARAMETER_BOUND: {
+            final int parameter_index = nextByte();
+            final int bound_index = nextByte();
+            return TypeAnnotationPosition
+                .methodTypeParameterBound(readTypePath(), parameter_index,
+                                          bound_index);
+        }
         // class extends or implements clause
-        case CLASS_EXTENDS:
-            position.type_index = nextChar();
-            break;
+        case CLASS_EXTENDS: {
+            final int type_index = nextChar();
+            return TypeAnnotationPosition.classExtends(readTypePath(),
+                                                       type_index);
+        }
         // throws
-        case THROWS:
-            position.type_index = nextChar();
-            break;
+        case THROWS: {
+            final int type_index = nextChar();
+            return TypeAnnotationPosition.methodThrows(readTypePath(),
+                                                       type_index);
+        }
         // method parameter
-        case METHOD_FORMAL_PARAMETER:
-            position.parameter_index = nextByte();
-            break;
+        case METHOD_FORMAL_PARAMETER: {
+            final int parameter_index = nextByte();
+            return TypeAnnotationPosition.methodParameter(readTypePath(),
+                                                          parameter_index);
+        }
         // type cast
-        case CAST:
+        case CAST: {
+            final int offset = nextChar();
+            final int type_index = nextByte();
+            final TypeAnnotationPosition position =
+                TypeAnnotationPosition.typeCast(readTypePath(), type_index);
+            position.offset = offset;
+            return position;
+        }
         // method/constructor/reference type argument
-        case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
-        case METHOD_INVOCATION_TYPE_ARGUMENT:
-        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
-        case METHOD_REFERENCE_TYPE_ARGUMENT:
-            position.offset = nextChar();
-            position.type_index = nextByte();
-            break;
+        case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT: {
+            final int offset = nextChar();
+            final int type_index = nextByte();
+            final TypeAnnotationPosition position = TypeAnnotationPosition
+                .constructorInvocationTypeArg(readTypePath(), type_index);
+            position.offset = offset;
+            return position;
+        }
+        case METHOD_INVOCATION_TYPE_ARGUMENT: {
+            final int offset = nextChar();
+            final int type_index = nextByte();
+            final TypeAnnotationPosition position = TypeAnnotationPosition
+                .methodInvocationTypeArg(readTypePath(), type_index);
+            position.offset = offset;
+            return position;
+        }
+        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT: {
+            final int offset = nextChar();
+            final int type_index = nextByte();
+            final TypeAnnotationPosition position = TypeAnnotationPosition
+                .constructorRefTypeArg(readTypePath(), type_index);
+            position.offset = offset;
+            return position;
+        }
+        case METHOD_REFERENCE_TYPE_ARGUMENT: {
+            final int offset = nextChar();
+            final int type_index = nextByte();
+            final TypeAnnotationPosition position = TypeAnnotationPosition
+                .methodRefTypeArg(readTypePath(), type_index);
+            position.offset = offset;
+            return position;
+        }
         // We don't need to worry about these
         case METHOD_RETURN:
+            return TypeAnnotationPosition.methodReturn(readTypePath());
         case FIELD:
-            break;
+            return TypeAnnotationPosition.field(readTypePath());
         case UNKNOWN:
             throw new AssertionError("jvm.ClassReader: UNKNOWN target type should never occur!");
         default:
-            throw new AssertionError("jvm.ClassReader: Unknown target type for position: " + position);
+            throw new AssertionError("jvm.ClassReader: Unknown target type for position: " + type);
         }
+    }
 
-        { // See whether there is location info and read it
-            int len = nextByte();
-            ListBuffer<Integer> loc = new ListBuffer<>();
-            for (int i = 0; i < len * TypeAnnotationPosition.TypePathEntry.bytesPerEntry; ++i)
-                loc = loc.append(nextByte());
-            position.location = TypeAnnotationPosition.getTypePathFromBinary(loc.toList());
-        }
+    List<TypeAnnotationPosition.TypePathEntry> readTypePath() {
+        int len = nextByte();
+        ListBuffer<Integer> loc = new ListBuffer<>();
+        for (int i = 0; i < len * TypeAnnotationPosition.TypePathEntry.bytesPerEntry; ++i)
+            loc = loc.append(nextByte());
 
-        return position;
+        return TypeAnnotationPosition.getTypePathFromBinary(loc.toList());
+
     }
 
     Attribute readAttributeValue() {
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Tue Feb 11 11:25:59 2014 -0800
@@ -103,8 +103,6 @@
      */
     private LVTRanges lvtRanges;
 
-    private final boolean typeAnnoAsserts;
-
     protected Gen(Context context) {
         context.put(genKey, this);
 
@@ -141,7 +139,6 @@
         debugCode = options.isSet("debugcode");
         allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic");
         pool = new Pool(types);
-        typeAnnoAsserts = options.isSet("TypeAnnotationAsserts");
 
         generateIproxies =
             target.requiresIproxy() ||
@@ -564,13 +561,10 @@
         ListBuffer<Attribute.TypeCompound> fieldTAs = new ListBuffer<>();
         ListBuffer<Attribute.TypeCompound> nonfieldTAs = new ListBuffer<>();
         for (TypeCompound ta : tas) {
+            Assert.check(ta.getPosition().type != TargetType.UNKNOWN);
             if (ta.getPosition().type == TargetType.FIELD) {
                 fieldTAs.add(ta);
             } else {
-                if (typeAnnoAsserts) {
-                    Assert.error("Type annotation does not have a valid positior");
-                }
-
                 nonfieldTAs.add(ta);
             }
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1173,8 +1173,10 @@
                             DCText string = quotedString();
                             if (string != null) {
                                 skipWhitespace();
-                                if (ch == '@')
+                                if (ch == '@'
+                                        || ch == EOI && bp == buf.length - 1) {
                                     return m.at(pos).See(List.<DCTree>of(string));
+                                }
                             }
                             break;
 
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3648,12 +3648,20 @@
                 params.append(lastParam);
             }
             this.allowThisIdent = false;
-            while ((lastParam.mods.flags & Flags.VARARGS) == 0 && token.kind == COMMA) {
+            while (token.kind == COMMA) {
+                if ((lastParam.mods.flags & Flags.VARARGS) != 0) {
+                    error(lastParam, "varargs.must.be.last");
+                }
                 nextToken();
                 params.append(lastParam = formalParameter(lambdaParameters));
             }
         }
-        accept(RPAREN);
+        if (token.kind == RPAREN) {
+            nextToken();
+        } else {
+            setErrorEndPos(token.pos);
+            reportSyntaxError(S.prevToken().endPos, "expected3", COMMA, RPAREN, LBRACKET);
+        }
         return params.toList();
     }
 
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -597,6 +597,9 @@
 compiler.err.varargs.and.receiver =\
     varargs notation not allowed on receiver parameter
 
+compiler.err.varargs.must.be.last =\
+    varargs parameter must be the last parameter
+
 compiler.err.array.and.receiver =\
     legacy array notation not allowed on receiver parameter
 
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Tue Feb 11 11:25:59 2014 -0800
@@ -2299,6 +2299,9 @@
 
         // Attribute.Compound if tag is ANNOTATION
         // Attribute.TypeCompound if tag is TYPE_ANNOTATION
+        //
+        // NOTE: This field is slated for removal in the future.  Do
+        // not use it for anything new.
         public Attribute.Compound attribute;
 
         protected JCAnnotation(Tag tag, JCTree annotationType, List<JCExpression> args) {
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Bits.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Bits.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -345,25 +345,4 @@
         }
     }
 
-    /** Test Bits.nextBit(int). */
-    public static void main(String[] args) {
-        java.util.Random r = new java.util.Random();
-        Bits bits = new Bits();
-        for (int i=0; i<125; i++) {
-            int k;
-            do {
-                k = r.nextInt(250);
-            } while (bits.isMember(k));
-            System.out.println("adding " + k);
-            bits.incl(k);
-        }
-        int count = 0;
-        for (int i = bits.nextBit(0); i >= 0; i = bits.nextBit(i+1)) {
-            System.out.println("found " + i);
-            count ++;
-        }
-        if (count != 125) {
-            throw new Error();
-        }
-    }
 }
--- a/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -227,10 +227,7 @@
     }
 
     public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) {
-        if (options.compat) // BUG 6622216 javap names some attributes incorrectly
-            print("Constant value: ");
-        else
-            print("ConstantValue: ");
+        print("ConstantValue: ");
         constantWriter.write(attr.constantvalue_index);
         println();
         return null;
@@ -291,20 +288,10 @@
 
     public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) {
         boolean first = true;
-        if (options.compat) {
-            writeInnerClassHeader();
-            first = false;
-        }
         for (int i = 0 ; i < attr.classes.length; i++) {
             InnerClasses_attribute.Info info = attr.classes[i];
             //access
             AccessFlags access_flags = info.inner_class_access_flags;
-            if (options.compat) {
-                // BUG 6622215: javap ignores certain relevant access flags
-                access_flags = access_flags.ignore(ACC_STATIC | ACC_PROTECTED | ACC_PRIVATE | ACC_INTERFACE | ACC_SYNTHETIC | ACC_ENUM);
-                // BUG 6622232: javap gets whitespace confused
-                print("   ");
-            }
             if (options.checkAccess(access_flags)) {
                 if (first) {
                     writeInnerClassHeader();
@@ -346,11 +333,7 @@
     }
 
     private void writeInnerClassHeader() {
-        if (options.compat) // BUG 6622216: javap names some attributes incorrectly
-            print("InnerClass");
-        else
-            print("InnerClasses");
-        println(":");
+        println("InnerClasses:");
         indent(+1);
     }
 
@@ -711,10 +694,7 @@
     }
 
     String toHex(byte b, int w) {
-        if (options.compat) // BUG 6622260: javap prints negative bytes incorrectly in hex
-            return toHex((int) b, w);
-        else
-            return toHex(b & 0xff, w);
+        return toHex(b & 0xff, w);
     }
 
     static String toHex(int i) {
--- a/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -120,7 +120,7 @@
     public void write(ClassFile cf) {
         setClassFile(cf);
 
-        if ((options.sysInfo || options.verbose) && !options.compat) {
+        if (options.sysInfo || options.verbose) {
             if (uri != null) {
                 if (uri.getScheme().equals("file"))
                     println("Classfile " + uri.getPath());
@@ -152,7 +152,7 @@
             println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\"");
         }
 
-        if ((options.sysInfo || options.verbose) && !options.compat) {
+        if (options.sysInfo || options.verbose) {
             indent(-1);
         }
 
@@ -205,8 +205,7 @@
             attrWriter.write(cf, cf.attributes, constant_pool);
             println("minor version: " + cf.minor_version);
             println("major version: " + cf.major_version);
-            if (!options.compat)
-              writeList("flags: ", flags.getClassFlags(), "\n");
+            writeList("flags: ", flags.getClassFlags(), "\n");
             indent(-1);
             constantWriter.writeConstantPool();
         } else {
@@ -372,7 +371,7 @@
         }
         print(" ");
         print(getFieldName(f));
-        if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents
+        if (options.showConstants) {
             Attribute a = f.attributes.get(Attribute.ConstantValue);
             if (a instanceof ConstantValue_attribute) {
                 print(" = ");
@@ -385,21 +384,23 @@
 
         indent(+1);
 
+        boolean showBlank = false;
+
         if (options.showDescriptors)
             println("descriptor: " + getValue(f.descriptor));
 
-        if (options.verbose && !options.compat)
+        if (options.verbose)
             writeList("flags: ", flags.getFieldFlags(), "\n");
 
         if (options.showAllAttrs) {
             for (Attribute attr: f.attributes)
                 attrWriter.write(f, attr, constant_pool);
-            println();
+            showBlank = true;
         }
 
         indent(-1);
 
-        if (options.showDisassembled || options.showLineAndLocalVariableTables)
+        if (showBlank || options.showDisassembled || options.showLineAndLocalVariableTables)
             println();
     }
 
@@ -485,7 +486,7 @@
             println("descriptor: " + getValue(m.descriptor));
         }
 
-        if (options.verbose && !options.compat) {
+        if (options.verbose) {
             writeList("flags: ", flags.getMethodFlags(), "\n");
         }
 
@@ -498,27 +499,23 @@
                 report("Unexpected or invalid value for Code attribute");
         }
 
-        if (options.showDisassembled && !options.showAllAttrs) {
-            if (code != null) {
+        if (options.showAllAttrs) {
+            Attribute[] attrs = m.attributes.attrs;
+            for (Attribute attr: attrs)
+                attrWriter.write(m, attr, constant_pool);
+        } else if (code != null) {
+            if (options.showDisassembled) {
                 println("Code:");
                 codeWriter.writeInstrs(code);
                 codeWriter.writeExceptionTable(code);
             }
-        }
 
-        if (options.showLineAndLocalVariableTables) {
-            if (code != null) {
+            if (options.showLineAndLocalVariableTables) {
                 attrWriter.write(code, code.attributes.get(Attribute.LineNumberTable), constant_pool);
                 attrWriter.write(code, code.attributes.get(Attribute.LocalVariableTable), constant_pool);
             }
         }
 
-        if (options.showAllAttrs) {
-            Attribute[] attrs = m.attributes.attrs;
-            for (Attribute attr: attrs)
-                attrWriter.write(m, attr, constant_pool);
-        }
-
         indent(-1);
 
         // set pendingNewline to write a newline before the next method (if any)
@@ -555,13 +552,11 @@
     }
 
     Signature_attribute getSignature(Attributes attributes) {
-        if (options.compat) // javap does not recognize recent attributes
-            return null;
         return (Signature_attribute) attributes.get(Attribute.Signature);
     }
 
     String adjustVarargs(AccessFlags flags, String params) {
-        if (flags.is(ACC_VARARGS) && !options.compat) {
+        if (flags.is(ACC_VARARGS)) {
             int i = params.lastIndexOf("[]");
             if (i > 0)
                 return params.substring(0, i) + "..." + params.substring(i+2);
--- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -195,48 +195,12 @@
             }
         },
 
-//        new Option(false, "-all") {
-//            void process(JavapTask task, String opt, String arg) {
-//                task.options.showAllAttrs = true;
-//            }
-//        },
-
-        new Option(false, "-h") {
-            void process(JavapTask task, String opt, String arg) throws BadArgs {
-                throw task.new BadArgs("err.h.not.supported");
-            }
-        },
-
-        new Option(false, "-verify", "-verify-verbose") {
-            void process(JavapTask task, String opt, String arg) throws BadArgs {
-                throw task.new BadArgs("err.verify.not.supported");
-            }
-        },
-
         new Option(false, "-sysinfo") {
             void process(JavapTask task, String opt, String arg) {
                 task.options.sysInfo = true;
             }
         },
 
-        new Option(false, "-Xold") {
-            void process(JavapTask task, String opt, String arg) throws BadArgs {
-                task.log.println(task.getMessage("warn.Xold.not.supported"));
-            }
-        },
-
-        new Option(false, "-Xnew") {
-            void process(JavapTask task, String opt, String arg) throws BadArgs {
-                // ignore: this _is_ the new version
-            }
-        },
-
-        new Option(false, "-XDcompat") {
-            void process(JavapTask task, String opt, String arg) {
-                task.options.compat = true;
-            }
-        },
-
         new Option(false, "-XDdetails") {
             void process(JavapTask task, String opt, String arg) {
                 task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class);
@@ -466,7 +430,7 @@
         } catch (BadArgs e) {
             reportError(e.key, e.args);
             if (e.showUsage) {
-                log.println(getMessage("main.usage.summary", progname));
+                printLines(getMessage("main.usage.summary", progname));
             }
             return EXIT_CMDERR;
         } catch (InternalError e) {
@@ -520,7 +484,7 @@
                 throw new BadArgs("err.unknown.option", arg).showUsage(true);
         }
 
-        if (!options.compat && options.accessOptions.size() > 1) {
+        if (options.accessOptions.size() > 1) {
             StringBuilder sb = new StringBuilder();
             for (String opt: options.accessOptions) {
                 if (sb.length() > 0)
@@ -581,8 +545,6 @@
         SourceWriter sourceWriter = SourceWriter.instance(context);
         sourceWriter.setFileManager(fileManager);
 
-        attributeFactory.setCompat(options.compat);
-
         int result = EXIT_OK;
 
         for (String className: classes) {
@@ -877,27 +839,33 @@
     }
 
     private void showHelp() {
-        log.println(getMessage("main.usage", progname));
+        printLines(getMessage("main.usage", progname));
         for (Option o: recognizedOptions) {
             String name = o.aliases[0].substring(1); // there must always be at least one name
             if (name.startsWith("X") || name.equals("fullversion") || name.equals("h") || name.equals("verify"))
                 continue;
-            log.println(getMessage("main.opt." + name));
+            printLines(getMessage("main.opt." + name));
         }
         String[] fmOptions = { "-classpath", "-cp", "-bootclasspath" };
         for (String o: fmOptions) {
             if (fileManager.isSupportedOption(o) == -1)
                 continue;
             String name = o.substring(1);
-            log.println(getMessage("main.opt." + name));
+            printLines(getMessage("main.opt." + name));
         }
 
     }
 
     private void showVersion(boolean full) {
-        log.println(version(full ? "full" : "release"));
+        printLines(version(full ? "full" : "release"));
     }
 
+    private void printLines(String msg) {
+        log.println(msg.replace("\n", nl));
+    }
+
+    private static final String nl = System.getProperty("line.separator");
+
     private static final String versionRBName = "com.sun.tools.javap.resources.version";
     private static ResourceBundle versionRB;
 
--- a/langtools/src/share/classes/com/sun/tools/javap/Options.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javap/Options.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,4 @@
     public boolean showInnerClasses;
     public int indentWidth = 2;   // #spaces per indentWidth level
     public int tabColumn = 40;    // column number for comments
-
-    public boolean compat;             // bug-for-bug compatibility mode with old javap
 }
--- a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties	Tue Feb 11 11:25:59 2014 -0800
@@ -6,7 +6,6 @@
 err.crash=A serious internal error has occurred: {0}\nPlease file a bug report, and include the following information:\n{1}
 err.end.of.file=unexpected end of file while reading {0}
 err.file.not.found=file not found: {0}
-err.h.not.supported=-h is no longer available - use the 'javah' program
 err.incompatible.options=bad combination of options: {0}
 err.internal.error=internal error: {0} {1} {2}
 err.invalid.arg.for.option=invalid argument for option: {0}
@@ -15,11 +14,9 @@
 err.no.classes.specified=no classes specified
 err.not.standard.file.manager=can only specify class files when using a standard file manager
 err.unknown.option=unknown option: {0}
-err.verify.not.supported=-verify not supported
 err.no.SourceFile.attribute=no SourceFile attribute
 err.source.file.not.found=source file not found
 err.bad.innerclasses.attribute=bad InnerClasses attribute for {0}
-warn.Xold.not.supported=-Xold is no longer available
 
 main.usage.summary=\
 Usage: {0} <options> <classes>\n\
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.java	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8030816
+ * @summary javac can't compile program with lambda expression
+ * @compile/fail/ref=CrashLambdaExpressionWithNonAccessibleIdTest.out -XDrawDiagnostics CrashLambdaExpressionWithNonAccessibleIdTest.java
+ */
+
+/* This test must make sure that javac won't crash when compiling lambda
+ * containing an anonymous innerclass based on an unresolvable type.
+ */
+public class CrashLambdaExpressionWithNonAccessibleIdTest {
+    void m() {
+        m1(()-> {
+            new A(){
+                public void m11() {}
+            };
+        });
+
+    }
+
+    void m1(Runnable r) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.out	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,3 @@
+CrashLambdaExpressionWithNonAccessibleIdTest.java:15:35: compiler.err.missing.ret.stmt
+CrashLambdaExpressionWithNonAccessibleIdTest.java:14:17: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, CrashLambdaExpressionWithNonAccessibleIdTest, null)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTarget.java	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8029017
+ * @summary sanity testing of ElementType validation for repeating annotations
+ * @compile TypeUseTarget.java
+ */
+
+import java.lang.annotation.*;
+
+public class TypeUseTarget {}
+
+
+// Case 1:
+@Target({
+    ElementType.TYPE_USE,
+})
+@Repeatable(Case1Container.class)
+@interface Case1 {}
+
+@Target({
+    ElementType.ANNOTATION_TYPE,
+    ElementType.TYPE,
+    ElementType.TYPE_USE,
+    ElementType.TYPE_PARAMETER,
+})
+@interface Case1Container {
+  Case1[] value();
+}
+
+
+// Case 2:
+@Target({
+    ElementType.TYPE_USE,
+})
+@Repeatable(Case2Container.class)
+@interface Case2 {}
+
+@Target({
+    ElementType.ANNOTATION_TYPE,
+    ElementType.TYPE,
+    ElementType.TYPE_USE,
+})
+@interface Case2Container {
+  Case2[] value();
+}
+
+
+// Case 3:
+@Target({
+    ElementType.TYPE_USE,
+})
+@Repeatable(Case3Container.class)
+@interface Case3 {}
+
+@Target({
+    ElementType.ANNOTATION_TYPE,
+    ElementType.TYPE,
+})
+@interface Case3Container {
+  Case3[] value();
+}
+
+
+// Case 4:
+@Target({
+    ElementType.TYPE_USE,
+})
+@Repeatable(Case4Container.class)
+@interface Case4 {}
+
+@Target({
+    ElementType.ANNOTATION_TYPE,
+})
+@interface Case4Container {
+  Case4[] value();
+}
+
+
+// Case 5:
+@Target({
+    ElementType.TYPE_USE,
+})
+@Repeatable(Case5Container.class)
+@interface Case5 {}
+
+@Target({
+    ElementType.TYPE,
+})
+@interface Case5Container {
+  Case5[] value();
+}
+
+
+// Case 6:
+@Target({
+    ElementType.TYPE_USE,
+})
+@Repeatable(Case6Container.class)
+@interface Case6 {}
+
+@Target({
+    ElementType.TYPE_PARAMETER,
+})
+@interface Case6Container {
+  Case6[] value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.java	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,100 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 8029017
+ * @summary sanity testing of ElementType validation for repeating annotations
+ * @compile/fail/ref=TypeUseTargetNeg.out -XDrawDiagnostics TypeUseTargetNeg.java
+ */
+
+import java.lang.annotation.*;
+
+public class TypeUseTargetNeg {}
+
+// Case 1:
+@Target({
+    ElementType.TYPE_USE,
+})
+@Repeatable(FooContainer.class)
+@interface Foo {}
+
+@Target({
+    ElementType.ANNOTATION_TYPE,
+    ElementType.TYPE,
+    ElementType.TYPE_USE,
+    ElementType.TYPE_PARAMETER,
+    ElementType.FIELD,
+
+})
+@interface FooContainer {
+  Foo[] value();
+}
+
+
+// Case 2:
+@Target({
+    ElementType.TYPE_USE,
+})
+@Repeatable(BarContainer.class)
+@interface Bar {}
+
+@Target({
+    ElementType.ANNOTATION_TYPE,
+    ElementType.TYPE,
+    ElementType.TYPE_USE,
+    ElementType.METHOD,
+})
+@interface BarContainer {
+  Bar[] value();
+}
+
+
+// Case 3:
+@Target({
+    ElementType.TYPE_USE,
+})
+@Repeatable(BazContainer.class)
+@interface Baz {}
+
+@Target({
+    ElementType.ANNOTATION_TYPE,
+    ElementType.TYPE,
+    ElementType.PARAMETER,
+})
+@interface BazContainer {
+  Baz[] value();
+}
+
+
+// Case 4:
+@Target({
+    ElementType.TYPE_USE,
+})
+@Repeatable(QuxContainer.class)
+@interface Qux {}
+
+@interface QuxContainer {
+  Qux[] value();
+}
+
+
+// Case 5:
+@Target({})
+@Repeatable(QuuxContainer.class)
+@interface Quux {}
+
+@Target({
+    ElementType.TYPE_PARAMETER,
+})
+@interface QuuxContainer {
+  Quux[] value();
+}
+
+// Case 6:
+@Repeatable(QuuuxContainer.class)
+@interface Quuux {}
+
+@Target({
+    ElementType.TYPE_USE,
+})
+@interface QuuuxContainer {
+  Quuux[] value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.out	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,7 @@
+TypeUseTargetNeg.java:16:1: compiler.err.invalid.repeatable.annotation.incompatible.target: FooContainer, Foo
+TypeUseTargetNeg.java:36:1: compiler.err.invalid.repeatable.annotation.incompatible.target: BarContainer, Bar
+TypeUseTargetNeg.java:54:1: compiler.err.invalid.repeatable.annotation.incompatible.target: BazContainer, Baz
+TypeUseTargetNeg.java:71:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuxContainer, Qux
+TypeUseTargetNeg.java:81:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuuxContainer, Quux
+TypeUseTargetNeg.java:92:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuuuxContainer, Quuux
+6 errors
--- a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug      8001457
+ * @bug      8001457 8027477
  * @author   sogoel
  * @summary  Reflection api tests
  * @build    Helper
@@ -159,7 +159,12 @@
                             "SingleOnSuperContainerAndSingleOnSub_Inherited_Legacy",
                             "ContainerAndSingleOnSuperSingleOnSub_Inherited_Legacy",
                             "SingleAnnoWithContainer",
-                            "SingleOnSuperContainerAndSingleOnSub_Inherited");
+                            "SingleOnSuperContainerAndSingleOnSub_Inherited",
+                            "RepeatableOnSuperSingleOnSub_Inherited",
+                            "SingleOnSuperRepeatableOnSub_Inherited",
+                            "ContainerOnSuperSingleOnSub_Inherited",
+                            "SingleOnSuperContainerOnSub_Inherited",
+                            "ContainerAndSingleOnSuperSingleOnSub_Inherited");
                     if (orderingTestFailures.contains(testCase.toString())) {
                         CHECKORDERING = false;
                     } else
@@ -1612,323 +1617,323 @@
                 return files;
             }
         },
-//         // Testcase not working as expected, JDK-8004912
-//         RepeatableOnSuperSingleOnSub_Inherited(
-//         "@ExpectedBase(value=Foo.class, "
-//                 + "getAnnotationVal = \"Foo\", "
-//                 + "getAnnotationsVals = {"
-//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
-//                 + //override every annotation on superClass
-//                 "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
-//                 + // ignores inherited annotations
-//                 "getDeclAnnoVal = \"Foo\", " // ignores inherited
-//                 + "getAnnosArgs = {\"Foo\"}, "
-//                 + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited
-//         "@ExpectedContainer(value=FooContainer.class, "
-//                 + "getAnnotationVal = \"FooContainer\", "
-//                 + "getAnnotationsVals = {"
-//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
-//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
-//                 + // ignores inherited annotations
-//                 "getDeclAnnoVal = \"NULL\", "
-//                 + "getAnnosArgs = {\"FooContainer\"}, "
-//                 + "getDeclAnnosArgs = {}) // ignores inherited ") {
+        // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
+        // fail with ordering issues
+        RepeatableOnSuperSingleOnSub_Inherited(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"@Foo(value=3)\", "
+                + "getAnnotationsVals = {"
+                + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + //override every annotation on superClass
+                "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, "
+                + // ignores inherited annotations
+                "getDeclAnnoVal = \"@Foo(value=3)\", " // ignores inherited
+                + "getAnnosArgs = {\"@Foo(value=3)\"}, "
+                + "getDeclAnnosArgs = { \"@Foo(value=3)\" })", // ignores inherited
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "
+                + "getAnnotationsVals = {"
+                + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, "
+                + // ignores inherited annotations
+                "getDeclAnnoVal = \"NULL\", "
+                + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + "getDeclAnnosArgs = {}) // ignores inherited ") {
 
-//             @Override
-//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
-//                     String className) {
-//                 String anno = "";
-//                 String replaceVal = "";
-//                 String contents = "";
-//                 JavaFileObject srcFileObj = null;
-//                 Iterable<? extends JavaFileObject> files = null;
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
 
-//                 String expectedVals = "\n" + getExpectedBase() + "\n"
-//                         + getExpectedContainer() + "\n";
-//                 StringBuilder commonStmts = getCommonStmts(true);
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(true);
 
-//                 /*
-//                 Sample testSrc:
-//                 @Retention(RetentionPolicy.RUNTIME)
-//                 @Inherited
-//                 @Repeatable(FooContainer.class)
-//                 @interface Foo {int value() default Integer.MAX_VALUE;}
+                /*
+                 Sample testSrc:
+                 @Retention(RetentionPolicy.RUNTIME)
+                 @Inherited
+                 @Repeatable(FooContainer.class)
+                 @interface Foo {int value() default Integer.MAX_VALUE;}
 
-//                 @Retention(RetentionPolicy.RUNTIME)
-//                 @Inherited
-//                 @interface FooContainer {
-//                 Foo[] value();
-//                 }
+                 @Retention(RetentionPolicy.RUNTIME)
+                 @Inherited
+                 @interface FooContainer {
+                 Foo[] value();
+                 }
 
-//                 @Foo() @Foo
-//                 class SuperClass { }
+                 @Foo(1) @Foo(2)
+                 class SuperClass { }
 
-//                 @ExpectedBase
-//                 @ExpectedContainer
-//                 @Foo
-//                 class SubClass extends SuperClass { }
-//                  */
-//                 //@Inherited only works for classes, no switch cases for method, field, package
-
-//                 if (srcType == SrcType.CLASS) {
-//                     //Contents for SuperClass
-//                     anno = Helper.ContentVars.REPEATABLEANNO.getVal();
-//                     replaceVal = commonStmts + "\n" + anno;
-//                     String superClassContents = srcType.getTemplate()
-//                             .replace("#CN", SUPERCLASS)
-//                             .replace("#REPLACE", replaceVal);
+                 @ExpectedBase
+                 @ExpectedContainer
+                 @Foo(3)
+                 class SubClass extends SuperClass { }
+                 */
+                //@Inherited only works for classes, no switch cases for method, field, package
+                if (srcType == SrcType.CLASS) {
+                    //Contents for SuperClass
+                    anno = Helper.ContentVars.REPEATABLEANNO.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
 
-//                     //Contents for SubClass that extends SuperClass
-//                     anno = "@Foo(0)";
-//                     replaceVal = expectedVals + "\n" + anno;
-//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
-//                             .replace("#CN", className)
-//                             .replace("#SN", SUPERCLASS)
-//                             .replace("#REPLACE", replaceVal);
-//                     contents = superClassContents + subClassContents;
-//                     srcFileObj = Helper.getFile(className, contents);
-//                     files = Arrays.asList(srcFileObj);
-//                 }
-//                 return files;
-//             }
-//         },
-//         //Testcase not working as expected, JDK-8004912
-//         SingleOnSuperRepeatableOnSub_Inherited(
-//         "@ExpectedBase(value=Foo.class, "
-//                 + "getAnnotationVal = \"Foo\", "
-//                 + "getAnnotationsVals = {"
-//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
-//                 + //override every annotation on superClass
-//                 "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
-//                 + // ignores inherited annotations
-//                 "getDeclAnnoVal = \"NULL\","// ignores inherited
-//                 + "getAnnosArgs = {\"Foo\", \"Foo\"}, "
-//                 + "getDeclAnnosArgs = { \"Foo\", \"Foo\"})",
-//         "@ExpectedContainer(value=FooContainer.class, "
-//                 + "getAnnotationVal = \"FooContainer\", "
-//                 + "getAnnotationsVals = {"
-//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
-//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
-//                 + // ignores inherited annotations
-//                 "getDeclAnnoVal = \"FooContainer\", "// ignores inherited
-//                 + "getAnnosArgs = {\"FooContainer\"}, "
-//                 + "getDeclAnnosArgs = {\"FooContainer\"})") {
+                    //Contents for SubClass that extends SuperClass
+                    anno = "@Foo(3)";
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
+        // fail with ordering issues
+        SingleOnSuperRepeatableOnSub_Inherited(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"@Foo(value=0)\", "
+                + "getAnnotationsVals = {"
+                + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + //override every annotation on superClass
+                "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + // ignores inherited annotations
+                "getDeclAnnoVal = \"NULL\","// ignores inherited
+                + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}, "
+                + "getDeclAnnosArgs = { \"@Foo(value=1)\", \"@Foo(value=2)\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "
+                + "getAnnotationsVals = {"
+                + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + // ignores inherited annotations
+                "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "// ignores inherited
+                + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") {
 
-//             @Override
-//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
-//                     String className) {
-//                 String anno = "";
-//                 String replaceVal = "";
-//                 String contents = "";
-//                 JavaFileObject srcFileObj = null;
-//                 Iterable<? extends JavaFileObject> files = null;
-
-//                 String expectedVals = "\n" + getExpectedBase() + "\n"
-//                         + getExpectedContainer() + "\n";
-//                 StringBuilder commonStmts = getCommonStmts(true);
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
 
-//                 /*
-//                 Sample testSrc:
-//                 @Retention(RetentionPolicy.RUNTIME)
-//                 @Inherited
-//                 @Repeatable(FooContainer.class)
-//                 @interface Foo {int value() default Integer.MAX_VALUE;}
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(true);
 
-//                 @Retention(RetentionPolicy.RUNTIME)
-//                 @Inherited
-//                 @interface FooContainer {
-//                 Foo[] value();
-//                 }
+                /*
+                 Sample testSrc:
+                 @Retention(RetentionPolicy.RUNTIME)
+                 @Inherited
+                 @Repeatable(FooContainer.class)
+                 @interface Foo {int value() default Integer.MAX_VALUE;}
 
-//                 @Foo()
-//                 class SuperClass { }
+                 @Retention(RetentionPolicy.RUNTIME)
+                 @Inherited
+                 @interface FooContainer {
+                 Foo[] value();
+                 }
 
-//                 @ExpectedBase
-//                 @ExpectedContainer
-//                 @Foo @Foo
-//                 class SubClass extends SuperClass { }
-//                  */
+                 @Foo(0)
+                 class SuperClass { }
 
-//                 //@Inherited only works for classes, no switch cases for method, field, package
-//                 if (srcType == SrcType.CLASS) {
-//                     //Contents for SuperClass
-//                     anno = "@Foo(0)";
-//                     replaceVal = commonStmts + "\n" + anno;
-//                     String superClassContents = srcType.getTemplate()
-//                             .replace("#CN", SUPERCLASS)
-//                             .replace("#REPLACE", replaceVal);
+                 @ExpectedBase
+                 @ExpectedContainer
+                 @Foo(1) @Foo(2)
+                 class SubClass extends SuperClass { }
+                 */
+                //@Inherited only works for classes, no switch cases for method, field, package
+                if (srcType == SrcType.CLASS) {
+                    //Contents for SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
 
-//                     //Contents for SubClass that extends SuperClass
-//                     anno = Helper.ContentVars.REPEATABLEANNO.getVal();
-//                     replaceVal = expectedVals + "\n" + anno;
-//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
-//                             .replace("#CN", className)
-//                             .replace("#SN", SUPERCLASS)
-//                             .replace("#REPLACE", replaceVal);
+                    //Contents for SubClass that extends SuperClass
+                    anno = Helper.ContentVars.REPEATABLEANNO.getVal();
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
 
-//                     contents = superClassContents + subClassContents;
-//                     srcFileObj = Helper.getFile(className, contents);
-//                     files = Arrays.asList(srcFileObj);
-//                 }
-//                 return files;
-//             }
-//         },
-//         //Testcase not working as expected, JDK-8004912
-//         ContainerOnSuperSingleOnSub_Inherited(
-//         "@ExpectedBase(value=Foo.class, "
-//                 + "getAnnotationVal = \"Foo\", "
-//                 + "getAnnotationsVals = {"
-//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
-//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
-//                 + "getDeclAnnoVal = \"Foo\","
-//                 + "getAnnosArgs = {\"Foo\"},"
-//                 + "getDeclAnnosArgs = {\"Foo\"})",
-//         "@ExpectedContainer(value=FooContainer.class, "
-//                 + "getAnnotationVal = \"FooContainer\", "
-//                 + "getAnnotationsVals = {"
-//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
-//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
-//                 + "getDeclAnnoVal = \"NULL\","
-//                 + "getAnnosArgs = {\"FooContainer\"},"
-//                 + "getDeclAnnosArgs = {})") {
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
+        // fail with ordering issues
+        ContainerOnSuperSingleOnSub_Inherited(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"@Foo(value=0)\", "
+                + "getAnnotationsVals = {"
+                + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"},"
+                + "getDeclAnnoVal = \"@Foo(value=0)\","
+                + "getAnnosArgs = {\"@Foo(value=0)\"},"
+                + "getDeclAnnosArgs = {\"@Foo(value=0)\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "
+                + "getAnnotationsVals = {"
+                + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"},"
+                + "getDeclAnnoVal = \"NULL\","
+                + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"},"
+                + "getDeclAnnosArgs = {})") {
 
-//             @Override
-//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
-//                     String className) {
-//                 String anno = "";
-//                 String replaceVal = "";
-//                 String contents = "";
-//                 JavaFileObject srcFileObj = null;
-//                 Iterable<? extends JavaFileObject> files = null;
-
-//                 String expectedVals = "\n" + getExpectedBase() + "\n"
-//                         + getExpectedContainer() + "\n";
-//                 StringBuilder commonStmts = getCommonStmts(true);
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
 
-//                 /*
-//                 Sample testSrc:
-//                 @Retention(RetentionPolicy.RUNTIME)
-//                 @Inherited
-//                 @Repeatable(FooContainer.class)
-//                 @interface Foo {int value() default Integer.MAX_VALUE;}
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(true);
 
-//                 @Retention(RetentionPolicy.RUNTIME)
-//                 @Inherited
-//                 @interface FooContainer {
-//                 Foo[] value();
-//                 }
+                /*
+                 Sample testSrc:
+                 @Retention(RetentionPolicy.RUNTIME)
+                 @Inherited
+                 @Repeatable(FooContainer.class)
+                 @interface Foo {int value() default Integer.MAX_VALUE;}
 
-//                 @FooContainer(value = {@Foo, @Foo})
-//                 class SuperClass { }
+                 @Retention(RetentionPolicy.RUNTIME)
+                 @Inherited
+                 @interface FooContainer {
+                 Foo[] value();
+                 }
+
+                 @FooContainer(value = {@Foo(1), @Foo(2)})
+                 class SuperClass { }
 
-//                 @ExpectedBase
-//                 @ExpectedContainer
-//                 @Foo
-//                 class SubClass extends SuperClass { }
-//                  */
+                 @ExpectedBase
+                 @ExpectedContainer
+                 @Foo(0)
+                 class SubClass extends SuperClass { }
+                 */
+                //@Inherited only works for classes, no switch cases for method, field, package
+                if (srcType == SrcType.CLASS) {
+                    //Contents for SuperClass
+                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
 
-//                 //@Inherited only works for classes, no switch cases for method, field, package
-//                 if (srcType == SrcType.CLASS) {
-//                     //Contents for SuperClass
-//                     anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
-//                     replaceVal = commonStmts + "\n" + anno;
-//                     String superClassContents = srcType.getTemplate()
-//                             .replace("#CN", SUPERCLASS)
-//                             .replace("#REPLACE", replaceVal);
-
-//                     //Contents for SubClass that extends SuperClass
-//                     anno = "@Foo(0)";
-//                     replaceVal = expectedVals + "\n" + anno;
-//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
-//                             .replace("#CN", className)
-//                             .replace("#SN", SUPERCLASS)
-//                             .replace("#REPLACE", replaceVal);
+                    //Contents for SubClass that extends SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
 
-//                     contents = superClassContents + subClassContents;
-//                     srcFileObj = Helper.getFile(className, contents);
-//                     files = Arrays.asList(srcFileObj);
-//                 }
-//                 return files;
-//             }
-//         },
-//         // TestCase not working as expected, JDK-8004912
-//         SingleOnSuperContainerOnSub_Inherited(
-//         "@ExpectedBase(value=Foo.class, "
-//                 + "getAnnotationVal = \"Foo\", "
-//                 + "getAnnotationsVals = {"
-//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
-//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
-//                 + "getDeclAnnoVal = \"NULL\","
-//                 + "getAnnosArgs = {\"Foo\", \"Foo\"},"
-//                 + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
-//         "@ExpectedContainer(value=FooContainer.class, "
-//                 + "getAnnotationVal = \"FooContainer\", "
-//                 + "getAnnotationsVals = {"
-//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
-//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
-//                 + "getDeclAnnoVal = \"FooContainer\","
-//                 + "getAnnosArgs = {\"FooContainer\"},"
-//                 + "getDeclAnnosArgs = {\"FooContainer\"})") {
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
+        // fail with ordering issues
+        SingleOnSuperContainerOnSub_Inherited(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"@Foo(value=0)\", "
+                + "getAnnotationsVals = {"
+                + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"},"
+                + "getDeclAnnoVal = \"NULL\","
+                + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"},"
+                + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "
+                + "getAnnotationsVals = {"
+                + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"},"
+                + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\","
+                + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"},"
+                + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") {
 
-//             @Override
-//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
-//                     String className) {
-//                 String anno = "";
-//                 String replaceVal = "";
-//                 String contents = "";
-//                 JavaFileObject srcFileObj = null;
-//                 Iterable<? extends JavaFileObject> files = null;
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                     String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
 
-//                 String expectedVals = "\n" + getExpectedBase() + "\n"
-//                         + getExpectedContainer() + "\n";
-//                 StringBuilder commonStmts = getCommonStmts(true);
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(true);
 
-//                 /*
-//                 Sample testSrc:
-//                 @Retention(RetentionPolicy.RUNTIME)
-//                 @Inherited
-//                 @Repeatable(FooContainer.class)
-//                 @interface Foo {int value() default Integer.MAX_VALUE;}
+                /*
+                 Sample testSrc:
+                 @Retention(RetentionPolicy.RUNTIME)
+                 @Inherited
+                 @Repeatable(FooContainer.class)
+                 @interface Foo {int value() default Integer.MAX_VALUE;}
 
-//                 @Retention(RetentionPolicy.RUNTIME)
-//                 @Inherited
-//                 @interface FooContainer {
-//                 Foo[] value();
-//                 }
+                 @Retention(RetentionPolicy.RUNTIME)
+                 @Inherited
+                 @interface FooContainer {
+                 Foo[] value();
+                 }
 
-//                 @Foo
-//                 class SuperClass { }
-
-//                 @ExpectedBase
-//                 @ExpectedContainer
-//                 @FooContainer(value = {@Foo, @Foo})
-//                 class SubClass extends SuperClass { }
-//                  */
+                 @Foo(0)
+                 class SuperClass { }
 
-//                 //@Inherited only works for classes, no switch cases for method, field, package
-//                 if (srcType == SrcType.CLASS) {
-//                     //Contents for SuperClass
-//                     anno = "@Foo(0)";
-//                     replaceVal = commonStmts + "\n" + anno;
-//                     String superClassContents = srcType.getTemplate()
-//                             .replace("#CN", SUPERCLASS)
-//                             .replace("#REPLACE", replaceVal);
+                 @ExpectedBase
+                 @ExpectedContainer
+                 @FooContainer(value = {@Foo(1), @Foo(2)})
+                 class SubClass extends SuperClass { }
+                 */
+                //@Inherited only works for classes, no switch cases for method, field, package
+                if (srcType == SrcType.CLASS) {
+                    //Contents for SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
 
-//                     //Contents for SubClass that extends SuperClass
-//                     anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
-//                     replaceVal = expectedVals + "\n" + anno;
-//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
-//                             .replace("#CN", className)
-//                             .replace("#SN", SUPERCLASS)
-//                             .replace("#REPLACE", replaceVal);
+                    //Contents for SubClass that extends SuperClass
+                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
 
-//                     contents = superClassContents + subClassContents;
-//                     srcFileObj = Helper.getFile(className, contents);
-//                     files = Arrays.asList(srcFileObj);
-//                 }
-//                 return files;
-//             }
-//         },
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
         // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
         // fail with ordering issues
         SingleOnSuperContainerAndSingleOnSub_Inherited(
@@ -2009,87 +2014,88 @@
                 return files;
             }
         },
-//          // TestCase not working as expected, JDK-8004912
-//          ContainerAndSingleOnSuperSingleOnSub_Inherited(
-//          "@ExpectedBase(value=Foo.class, "
-//                  + "getAnnotationVal = \"Foo\", "
-//                  + "getAnnotationsVals = {"
-//                  +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
-//                  + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
-//                  + "getDeclAnnoVal = \"Foo\","
-//                  + "getAnnosArgs = {\"Foo\"},"
-//                  + "getDeclAnnosArgs = {\"Foo\"})",
-//          "@ExpectedContainer(value=FooContainer.class, "
-//                  + "getAnnotationVal = \"FooContainer\", "
-//                  + "getAnnotationsVals = {"
-//                  +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
-//                  + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
-//                  + "getDeclAnnoVal = \"NULL\","
-//                  + "getAnnosArgs = {\"FooContainer\"},"
-//                  + "getDeclAnnosArgs = {})") {
+        // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
+        // fail with ordering issues
+        ContainerAndSingleOnSuperSingleOnSub_Inherited(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"@Foo(value=0)\", "
+                + "getAnnotationsVals = {"
+                + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"},"
+                + "getDeclAnnoVal = \"@Foo(value=0)\","
+                + "getAnnosArgs = {\"@Foo(value=0)\"},"
+                + "getDeclAnnosArgs = {\"@Foo(value=0)\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "
+                + "getAnnotationsVals = {"
+                + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"},"
+                + "getDeclAnnoVal = \"NULL\","
+                + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"},"
+                + "getDeclAnnosArgs = {})") {
 
-//              @Override
-//              public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
-//                      String className) {
-//                  String anno = "";
-//                  String replaceVal = "";
-//                  String contents = "";
-//                  JavaFileObject srcFileObj = null;
-//                  Iterable<? extends JavaFileObject> files = null;
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
 
-//                  String expectedVals = "\n" + getExpectedBase() + "\n"
-//                          + getExpectedContainer() + "\n";
-//                  StringBuilder commonStmts = getCommonStmts(true);
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(true);
 
-//                  /*
-//                  Sample testSrc:
-//                  @Retention(RetentionPolicy.RUNTIME)
-//                  @Inherited
-//                  @Repeatable(FooContainer.class)
-//                  @interface Foo {int value() default Integer.MAX_VALUE;}
+                /*
+                 Sample testSrc:
+                 @Retention(RetentionPolicy.RUNTIME)
+                 @Inherited
+                 @Repeatable(FooContainer.class)
+                 @interface Foo {int value() default Integer.MAX_VALUE;}
 
-//                  @Retention(RetentionPolicy.RUNTIME)
-//                  @Inherited
-//                  @interface FooContainer {
-//                  Foo[] value();
-//                  }
+                 @Retention(RetentionPolicy.RUNTIME)
+                 @Inherited
+                 @interface FooContainer {
+                 Foo[] value();
+                 }
 
-//                  @FooContainer(value = {@Foo, @Foo})
-//                  @Foo
-//                  class SuperClass { }
+                 @FooContainer(value = {@Foo(1), @Foo(2)})
+                 @Foo(3)
+                 class SuperClass { }
 
-//                  @ExpectedBase
-//                  @ExpectedContainer
-//                  @Foo
-//                  class SubClass extends SuperClass { }
-//                   */
+                 @ExpectedBase
+                 @ExpectedContainer
+                 @Foo(0)
+                 class SubClass extends SuperClass { }
+                 */
 
-//                  //@Inherited only works for classes, no switch cases for method, field, package
-//                  if (srcType == SrcType.CLASS) {
-//                      //Contents for SuperClass
-//                      anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
-//                              + Helper.ContentVars.BASEANNO.getVal();
-//                      replaceVal = commonStmts + "\n" + anno;
-//                      String superClassContents = srcType.getTemplate()
-//                              .replace("#CN", SUPERCLASS)
-//                              .replace("#REPLACE", replaceVal);
+                //@Inherited only works for classes, no switch cases for method, field, package
+                if (srcType == SrcType.CLASS) {
+                    //Contents for SuperClass
+                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+                            + "@Foo(3)" ;
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
 
-//                      //Contents for SubClass that extends SuperClass
-//                      anno = "@Foo(0)";
-//                      replaceVal = expectedVals + "\n" + anno;
-//                      String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
-//                              .replace("#CN", className)
-//                              .replace("#SN", SUPERCLASS)
-//                              .replace("#REPLACE", replaceVal);
+                    //Contents for SubClass that extends SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
 
-//                      contents = superClassContents + subClassContents;
-//                      srcFileObj = Helper.getFile(className, contents);
-//                      files = Arrays.asList(srcFileObj);
-//                  }
-//                  return files;
-//              }
-//         }
-            ;
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        };
+
          private String expectedBase, expectedContainer;
 
          private TestCase(String expectedBase, String expectedContainer) {
@@ -2942,7 +2948,7 @@
         System.out.print("Actual Arr Values: ");
         for (Annotation a : actualAnnos) {
             if (a != null && a.annotationType() != null) {
-                System.out.print("[" + a.annotationType().getSimpleName() + "]");
+                System.out.print("[" + a.toString() + "]");
             } else {
                 System.out.println("[null]");
             }
--- a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      7151010 8006547 8007766
+ * @bug      7151010 8006547 8007766 8029017
  * @summary  Default test cases for running combinations for Target values
  * @build    Helper
  * @run main TargetAnnoCombo
@@ -145,11 +145,19 @@
 
             Set<ElementType> tempBaseSet = EnumSet.noneOf(ElementType.class);
             tempBaseSet.addAll(baseAnnotations);
+
             // If BaseAnno has TYPE, then ANNOTATION_TYPE is allowed by default.
             if (baseAnnotations.contains(TYPE)) {
                 tempBaseSet.add(ANNOTATION_TYPE);
             }
 
+            // If BaseAnno has TYPE_USE, then add the extra allowed types
+            if (baseAnnotations.contains(TYPE_USE)) {
+                tempBaseSet.add(ANNOTATION_TYPE);
+                tempBaseSet.add(TYPE);
+                tempBaseSet.add(TYPE_PARAMETER);
+            }
+
             // If containerAnno has no @Target, only valid case if baseAnnoTarget has
             // all targets defined else invalid set.
             if (containerAnnotations == null) {
--- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug     4813736
+ * @bug     4813736 8013256
  * @summary Additional functionality test of task and JSR 269
  * @author  Peter von der Ah\u00e9
  * @library ./lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/VarargsMustBeLast.java	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.varargs.must.be.last
+
+class VarargMustBeFinal {
+    public void invalidVarArg(String... invalidVarArg, String extra) { }
+}
--- a/langtools/test/tools/javac/doctree/SeeTest.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/test/tools/javac/doctree/SeeTest.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7021614
+ * @bug 7021614 8031212
  * @summary extend com.sun.source API to support parsing javadoc comments
  * @build DocCommentTester
  * @run main DocCommentTester SeeTest.java
@@ -41,9 +41,9 @@
     Text[TEXT, pos:1, abc.]
   body: empty
   block tags: 1
-    Erroneous[ERRONEOUS, pos:7
-      code: compiler.err.dc.unexpected.content
-      body: @see_"String"
+    See[SEE, pos:7
+      reference: 1
+        Text[TEXT, pos:12, "String"]
     ]
 ]
 */
--- a/langtools/test/tools/javac/lambda/InnerConstructor.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/test/tools/javac/lambda/InnerConstructor.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8003280
+ * @bug 8003280 8003306
  * @summary Add lambda tests
  *  Regression test JDK-8003306 inner class constructor in lambda
  * @author  Robert Field
--- a/langtools/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8002099
+ * @bug 8002099 8010822
  * @summary Add support for intersection types in cast expression
  */
 
--- a/langtools/test/tools/javac/lambda/separate/Test.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/test/tools/javac/lambda/separate/Test.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8008708
  * @compile Foo.java
  * @compile Test.java
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/parser/ErroneousParameters.java	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8030091
+ * @summary Producing reasonable errors for unexpected tokens in method parameters
+ * @compile/fail/ref=ErroneousParameters.out -XDrawDiagnostics ErroneousParameters.java
+ */
+
+public class ErroneousParameters {
+
+    public static void test(int... extraVarArg, int additionalParam) { }
+    public static void test(byte param...) { }
+    public static void test(char param,) { }
+    public static void test(short param[) { }
+    public static void test(int param=) { }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/parser/ErroneousParameters.out	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,14 @@
+ErroneousParameters.java:10:36: compiler.err.varargs.must.be.last
+ErroneousParameters.java:11:39: compiler.err.expected3: ',', ')', '['
+ErroneousParameters.java:11:42: compiler.err.illegal.start.of.type
+ErroneousParameters.java:11:43: compiler.err.expected: token.identifier
+ErroneousParameters.java:11:45: compiler.err.expected: ';'
+ErroneousParameters.java:12:40: compiler.err.illegal.start.of.type
+ErroneousParameters.java:12:41: compiler.err.expected3: ',', ')', '['
+ErroneousParameters.java:12:43: compiler.err.expected: ';'
+ErroneousParameters.java:13:41: compiler.err.expected: ']'
+ErroneousParameters.java:14:38: compiler.err.expected3: ',', ')', '['
+ErroneousParameters.java:14:39: compiler.err.illegal.start.of.type
+ErroneousParameters.java:14:40: compiler.err.expected: token.identifier
+ErroneousParameters.java:14:42: compiler.err.expected: ';'
+13 errors
--- a/langtools/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.out	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.out	Tue Feb 11 11:25:59 2014 -0800
@@ -1,6 +1,6 @@
 ParseErrors.java:37:37: compiler.err.expected: token.identifier
 ParseErrors.java:38:1: compiler.err.illegal.start.of.type
-ParseErrors.java:38:2: compiler.err.expected: ')'
+ParseErrors.java:38:2: compiler.err.expected3: ',', ')', '['
 ParseErrors.java:40:6: compiler.err.expected: ';'
 ParseErrors.java:40:20: compiler.err.illegal.start.of.type
 ParseErrors.java:41:5: compiler.err.expected: '('
--- a/langtools/test/tools/javac/resolve/ResolveHarness.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/test/tools/javac/resolve/ResolveHarness.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7098660
+ * @bug 7098660 8014649
  * @summary Write better overload resolution/inference tests
  * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor ResolveHarness
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/util/BitsTest.java	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8028267
+ * @summary Unit tests for the com.sun.tools.javac.util.Bits class.
+ * @run main BitsTest
+ */
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import com.sun.tools.javac.util.Bits;
+
+public class BitsTest {
+
+    final static int[] samples = { 0, 1, 7, 16, 19, 31, 32, 33, 63, 64 };
+    final static int LENGTH = samples[samples.length - 1] + 50;
+
+    public static void main(String... args) throws Exception {
+
+        testIncl();
+        testInclRange();
+        testDup();
+        testClear();
+        testExcl();
+        testExcludeFrom();
+        testBinOps();
+        testNextBit();
+
+    }
+
+
+    // Test Bits.incl
+    static void testIncl() {
+        for (int a : samples) {
+            for (int b : samples) {
+                Bits bits = new Bits();
+                bits.incl(a);
+                if (a != b)
+                    bits.incl(b);
+                for (int i = 0; i < LENGTH; i++)
+                    assert bits.isMember(i) == (i == a || i == b);
+            }
+        }
+    }
+
+
+    // Test Bits.excl
+    static void testExcl() {
+        for (int a : samples) {
+            for (int b : samples) {
+                Bits bits = new Bits();
+                bits.inclRange(0, LENGTH);
+                bits.excl(a);
+                if (a != b)
+                    bits.excl(b);
+                for (int i = 0; i < LENGTH; i++)
+                    assert !bits.isMember(i) == (i == a || i == b);
+            }
+        }
+    }
+
+
+    // Test Bits.inclRange with various ranges.
+    static void testInclRange() {
+        for (int i = 0; i < samples.length; i++) {
+            for (int j = i; j < samples.length; j++)
+                testInclRangeHelper(samples[i], samples[j]);
+        }
+    }
+
+
+    // Tests Bits.inclRange for the given range.
+    static void testInclRangeHelper(int from, int to) {
+        Bits bits = new Bits();
+        bits.inclRange(from, to);
+        for (int i = 0; i < LENGTH; i++)
+            assert bits.isMember(i) == (from <= i && i < to);
+    }
+
+
+    // Test Bits.dup
+    static void testDup() {
+        Bits bits = sampleBits();
+        Bits dupBits = bits.dup();
+        assertEquals(LENGTH, bits, dupBits);
+    }
+
+
+    // Make sure Bits.clear clears all bits.
+    static void testClear() {
+        Bits bits = sampleBits();
+        bits.clear();
+        for (int i = 0; i < LENGTH; i++)
+            assert !bits.isMember(i);
+    }
+
+
+    // Test Bits.excludeFrom
+    static void testExcludeFrom() {
+        Bits bits = sampleBits();
+
+        int half = samples.length / 2;
+        Set<Integer> expected = new HashSet<Integer>();
+        for (int i : Arrays.copyOf(samples, half))
+            expected.add(i);
+
+        bits.excludeFrom(samples[half]);
+
+        for (int i = 0; i < LENGTH; i++)
+            assert bits.isMember(i) == expected.contains(i);
+    }
+
+
+    // Test andSet, orSet, diffSet, xorSet
+    static void testBinOps() {
+        int[] a = { 1630757163, -592623705 };
+        int[] b = { 1062404889, 1969380693 };
+
+        int[] or   = { a[0] | b[0],  a[1] | b[1] };
+        int[] and  = { a[0] & b[0],  a[1] & b[1] };
+        int[] xor  = { a[0] ^ b[0],  a[1] ^ b[1] };
+        int[] diff = { a[0] & ~b[0], a[1] & ~b[1] };
+
+        assertEquals(64, fromInts(a).orSet  (fromInts(b)), fromInts(or));
+        assertEquals(64, fromInts(a).andSet (fromInts(b)), fromInts(and));
+        assertEquals(64, fromInts(a).xorSet (fromInts(b)), fromInts(xor));
+        assertEquals(64, fromInts(a).diffSet(fromInts(b)), fromInts(diff));
+
+    }
+
+
+    // Create a Bits-instance based on bits in 'ints' argument.
+    static Bits fromInts(int[] ints) {
+        Bits bits = new Bits();
+        for (int bit = 0; bit < ints.length * 32; bit++)
+            if ((ints[bit / 32] & (1 << (bit % 32))) != 0)
+                bits.incl(bit);
+        return bits;
+    }
+
+
+    // Asserts that two Bits-instances are equal up to first 'len' bits.
+    static void assertEquals(int len, Bits a, Bits b) {
+        for (int i = 0; i < len; i++)
+            assert a.isMember(i) == b.isMember(i);
+    }
+
+
+    // Test Bits.nextBit
+    static void testNextBit() {
+        Bits bits = sampleBits();
+
+        int index = 0;
+        for (int bit = 0; bit < LENGTH; bit++) {
+
+            int expected;
+
+            // Passed last sample index?
+            if (index < samples.length) {
+                expected = samples[index];
+                if (bit == samples[index])
+                    index++;
+            } else {
+                expected = -1;
+            }
+
+            assert bits.nextBit(bit) == expected;
+        }
+    }
+
+
+    // Convenience method: Generate a Bits-instance based on samples.
+    static Bits sampleBits() {
+        Bits bits = new Bits();
+        for (int i : samples)
+            bits.incl(i);
+        return bits;
+    }
+
+}
--- a/langtools/test/tools/javap/InvalidOptions.java	Thu Feb 06 13:09:40 2014 -0800
+++ b/langtools/test/tools/javap/InvalidOptions.java	Tue Feb 11 11:25:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,8 @@
 
 /*
  * @test
- * @bug 8027411
- * @summary test invalid options -h and -b
+ * @bug 8027411 8032869
+ * @summary test an invalid option
  */
 
 import java.io.*;
@@ -39,7 +39,6 @@
     }
 
     void run() throws Exception {
-        test(2, "-h", "Error: -h is no longer available - use the javah program");
         test(2, "-b", "Error: unknown option: -b",
                       "Usage: javap <options> <classes>",
                       "use -help for a list of possible options");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/T8032814.java	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8032814
+ * @summary LineNumberTable/LocalVariableTable tables duplication for the
+ *          "-v -l" combination of options
+ * @compile -g T8032814.java
+ * @run main T8032814
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T8032814 {
+    public static void main(String... args) throws Exception {
+        new T8032814().run();
+    }
+
+    void run() throws Exception {
+        Class<?> clazz = T8032814.class;
+        int count = clazz.getDeclaredConstructors().length
+                + clazz.getDeclaredMethods().length;
+        test(clazz, 0);
+        test(clazz, count, "-v");
+        test(clazz, count, "-l");
+        test(clazz, count, "-v", "-l");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(Class<?> clazz, int expectedCount, String... opts) throws Exception {
+        System.err.println("test class " + clazz.getName() + " " + Arrays.asList(opts) + ": expect: " + expectedCount);
+        List<String> args = new ArrayList<String>();
+        args.addAll(Arrays.asList(opts));
+        args.addAll(Arrays.asList("-classpath", System.getProperty("test.classes")));
+        args.add(clazz.getName());
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
+        pw.close();
+        String out = sw.toString();
+        if (rc != 0)
+            throw new Exception("javap failed unexpectedly: rc=" + rc);
+
+        int lntCount = 0, lvtCount = 0;
+        for (String line: out.split("[\r\n]+")) {
+            if (line.matches("^ *LineNumberTable:$"))
+                lntCount++;
+            if (line.matches("^ *LocalVariableTable:$"))
+                lvtCount++;
+        }
+        checkEqual("LineNumberTable", lntCount, expectedCount);
+        checkEqual("LocalVariableTable", lvtCount, expectedCount);
+    }
+
+    void checkEqual(String attr, int found, int expect) {
+        if (found != expect) {
+            error("Unexpected number of occurrences of " + attr + "\n" +
+                "found: " + found + ", expected: " + expect);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors = 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/T8032819.java	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8032819
+ * @summary Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
+ * @compile -g T8032819.java
+ * @run main T8032819
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T8032819 {
+    static class Fields {
+        int f1;
+        int f2;
+    }
+
+    public static void main(String... args) throws Exception {
+        new T8032819().run();
+    }
+
+    void run() throws Exception {
+        Class<?> clazz = Fields.class;
+        test(clazz);
+        test(clazz, "-c");
+        test(clazz, "-l");
+        test(clazz, "-l", "-c");
+        test(clazz, "-v");
+        test(clazz, "-v", "-c");
+        test(clazz, "-v", "-l");
+        test(clazz, "-v", "-l", "-c");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    static final String sep = System.getProperty("line.separator");
+    static final String doubleBlankLine = sep + sep + sep;
+
+    void test(Class<?> clazz, String... opts) throws Exception {
+        System.err.println("test " + Arrays.asList(opts));
+        List<String> args = new ArrayList<String>();
+        args.addAll(Arrays.asList(opts));
+        args.addAll(Arrays.asList("-classpath", System.getProperty("test.classes")));
+        args.add(clazz.getName());
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
+        pw.close();
+        String out = sw.toString();
+        if (rc != 0)
+            throw new Exception("javap failed unexpectedly: rc=" + rc);
+
+        int count = 0;
+        int i = out.indexOf(doubleBlankLine, 0);
+        while (i != -1) {
+            count++;
+            i = out.indexOf(doubleBlankLine, i + doubleBlankLine.length());
+        }
+
+        if (count > 0)
+            error(count + " double blank lines found");
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors = 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/T8033180.java	Tue Feb 11 11:25:59 2014 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8033180
+ * @summary Bad newline characters
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T8033180 {
+
+    public static void main(String... args) throws Exception {
+        new T8033180().run();
+    }
+
+    void run() throws Exception {
+        // fast-track this case, because test cannot fail in this case
+        if (lineSep.equals(nl))
+            return;
+
+        test("-help");
+        test("-version");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    static final String lineSep = System.getProperty("line.separator");
+    static final String nl = "\n";
+
+    void test(String... opts) throws Exception {
+        System.err.println("test " + Arrays.asList(opts));
+        List<String> args = new ArrayList<String>();
+        args.addAll(Arrays.asList(opts));
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
+        pw.close();
+        String out = sw.toString();
+        if (rc != 0)
+            throw new Exception("javap failed unexpectedly: rc=" + rc);
+
+        // remove all valid platform newline sequences
+        String out2 = out.replace(lineSep, "");
+
+        // count the remaining simple newline characters
+        int count = 0;
+        int i = out2.indexOf(nl, 0);
+        while (i != -1) {
+            count++;
+            i = out2.indexOf(nl, i + nl.length());
+        }
+
+        if (count > 0)
+            error(count + " newline characters found");
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors = 0;
+}
+