Merge
authorlana
Mon, 12 Jan 2015 12:23:34 -0800
changeset 28342 867b8b80696e
parent 28329 d0222feb6ffd (current diff)
parent 28341 8f015bb3a75f (diff)
child 28343 a729ebd0ee58
Merge
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/LVTRanges.java
--- a/langtools/make/Tools.gmk	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/make/Tools.gmk	Mon Jan 12 12:23:34 2015 -0800
@@ -39,7 +39,7 @@
     DISABLE_SJAVAC := true, \
     ADD_JAVAC_FLAGS := -Xprefer:source, \
     SRC := $(LANGTOOLS_TOPDIR)/make/tools, \
-    INCLUDES := compileproperties, \
+    INCLUDES := compileproperties propertiesparser, \
     BIN := $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes))
 
 all: $(BUILD_TOOLS_LANGTOOLS)
--- a/langtools/make/build.properties	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/make/build.properties	Mon Jan 12 12:23:34 2015 -0800
@@ -54,6 +54,9 @@
 jdk.javadoc.dependencies=java.base:java.compiler:jdk.compiler
 jdk.dev.dependencies=java.base:java.compiler:jdk.compiler
 
+javac.resource.includes = \
+        com/sun/tools/javac/resources/compiler.properties
+
 #test configuration:
 jtreg.tests=
 boot.javac.tests = tools/javac
--- a/langtools/make/build.xml	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/make/build.xml	Mon Jan 12 12:23:34 2015 -0800
@@ -527,7 +527,8 @@
                 <build-module-classes module.name="java.compiler"
                                       compilation.kind="@{compilation.kind}" />
                 <build-module-classes module.name="jdk.compiler"
-                                      compilation.kind="@{compilation.kind}" />
+                                      compilation.kind="@{compilation.kind}"
+                                      resource.includes="${javac.resource.includes}" />
                 <build-module-classes module.name="jdk.javadoc"
                                       compilation.kind="@{compilation.kind}" />
                 <build-module-classes module.name="jdk.dev"
@@ -536,10 +537,11 @@
         </macrodef>
     </target>
 
-    <target name="-def-build-module-classes" depends="-def-pcompile">
+    <target name="-def-build-module-classes" depends="-def-pcompile,-def-pparse">
         <macrodef name="build-module-classes">
             <attribute name="module.name"/>
             <attribute name="compilation.kind" default=""/>
+            <attribute name="resource.includes" default="nonExistent" />
             <attribute name="dependencies" default="${@{module.name}.dependencies}"/>
             <attribute name="includes" default="${@{compilation.kind}javac.includes}"/>
             <attribute name="javac.lint.opts" default="${@{compilation.kind}javac.lint.opts}"/>
@@ -583,6 +585,12 @@
                         <path location="${src.dir}"/>
                     </src>
                 </pcompile>
+                <pparse destdir="@{gensrc.dir}"
+                        includes="@{resource.includes}">
+                    <src>
+                        <path location="${src.dir}"/>
+                    </src>
+                </pparse>
                 <copy todir="@{gensrc.dir}">
                     <fileset dir="${src.dir}" includes="@{includes}" />
                     <globmapper from="*.properties-template" to="*.properties"/>
@@ -644,6 +652,28 @@
         </macrodef>
     </target>
 
+    <target name="-def-pparse">
+        <mkdir dir="${build.toolclasses.dir}"/>
+        <copy todir="${build.toolclasses.dir}/propertiesparser" >
+            <fileset dir="make/tools/propertiesparser" includes="**/resources/**"/>
+        </copy>
+        <javac fork="true"
+               source="${boot.javac.source}"
+               target="${boot.javac.target}"
+               executable="${boot.java.home}/bin/javac"
+               srcdir="${make.tools.dir}"
+               includes="propertiesparser/* anttasks/PropertiesParser* anttasks/PathFileSet*"
+               destdir="${build.toolclasses.dir}/"
+               classpath="${ant.core.lib}"
+               bootclasspath="${boot.java.home}/jre/lib/rt.jar"
+               includeantruntime="false">
+            <compilerarg line="${javac.lint.opts}"/>
+        </javac>
+        <taskdef name="pparse"
+                 classname="anttasks.PropertiesParserTask"
+                 classpath="${build.toolclasses.dir}/"/>
+    </target>
+
     <target name="-do-depend" if="do.depend">
         <depend srcdir="${src.dir}:${gensrc.dir}" destdir="${classes.dir}" classpath="${classpath}"
                 cache="${depcache.dir}"/>
--- a/langtools/make/gensrc/Gensrc-jdk.compiler.gmk	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/make/gensrc/Gensrc-jdk.compiler.gmk	Mon Jan 12 12:23:34 2015 -0800
@@ -37,4 +37,7 @@
 $(eval $(call SetupCompileProperties,COMPILE_PROPERTIES,\
     $(JAVAC_VERSION) $(JAVAH_VERSION) $(JAVAP_VERSION)))
 
-all: $(COMPILE_PROPERTIES)
+$(eval $(call SetupParseProperties,PARSE_PROPERTIES,\
+	com/sun/tools/javac/resources/compiler.properties))
+
+all: $(COMPILE_PROPERTIES) $(PARSE_PROPERTIES)
--- a/langtools/make/gensrc/GensrcCommon.gmk	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/make/gensrc/GensrcCommon.gmk	Mon Jan 12 12:23:34 2015 -0800
@@ -35,6 +35,11 @@
 TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
     compileproperties.CompileProperties -quiet
 
+################################################################################
+# The compileprops tools compiles a properties file into an enum-like class.
+TOOL_PARSEPROPS_CMD := $(JAVA) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
+    propertiesparser.PropertiesParser
+
 
 ################################################################################
 # Sets up a rule that creates a version.properties file in the gensrc output
@@ -93,3 +98,32 @@
 endef
 
 ################################################################################
+# Parse property files in given location and generate a Java-like enum in the gensrc folder.
+# Param 1 - Variable to add targets to
+# Param 2 - Extra properties files to process
+define SetupParseProperties
+  #property file to generate
+  PARSEPROPSOURCES := $$(foreach var,$2,$$(addsuffix $$(var),$(LANGTOOLS_TOPDIR)/src/$(MODULE)/share/classes/))  
+
+  PARSEPROPALLDIRS := $$(patsubst $(LANGTOOLS_TOPDIR)/src/%, \
+      $(SUPPORT_OUTPUTDIR)/gensrc/%, \
+      $$(dir $$(PARSEPROPSOURCES)))
+
+  PARSEPROPDIRS := $$(sort $$(PARSEPROPALLDIRS))
+
+  PARSEPROPCMDLINE := $$(subst _SPACE_, $$(SPACE), \
+    $$(join $$(foreach var,$$(PARSEPROPSOURCES),$$(addprefix -compile_SPACE_,$$(var))), \
+    $$(addprefix _SPACE_, $$(PARSEPROPALLDIRS))))
+  
+  # Now setup the rule for the generation of the resource bundles.
+  $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the_parsed_props: $(PARSEPROPSOURCES)
+	$(CP) -r $(LANGTOOLS_TOPDIR)/make/tools/propertiesparser/resources $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes/propertiesparser/resources
+	$(MKDIR) -p $$(@D) $$(PARSEPROPDIRS)
+	$(ECHO) Parsing $$(words $$(PARSEPROPSOURCES)) properties into enum-like class for $(MODULE)
+	$(TOOL_PARSEPROPS_CMD) $$(PARSEPROPCMDLINE)
+	$(TOUCH) $$@
+
+  $$(strip $1) += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the_parsed_props
+endef
+
+################################################################################
--- a/langtools/make/intellij/build.xml	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/make/intellij/build.xml	Mon Jan 12 12:23:34 2015 -0800
@@ -28,7 +28,7 @@
         </sequential>
     </macrodef>
 
-    <target name="post-make" depends="build-all-tools"/>
+    <target name="post-make" depends="clean, build-all-tools"/>
 
     <target name="jtreg-debug" depends="build-all-tools,-def-jtreg">
         <exec-target target="jtreg-debug-internal"/>
--- a/langtools/make/intellij/compiler.xml	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/make/intellij/compiler.xml	Mon Jan 12 12:23:34 2015 -0800
@@ -5,6 +5,7 @@
     <excludeFromCompile>
       <directory url="file://$PROJECT_DIR$/src" includeSubdirectories="true" />
       <directory url="file://$PROJECT_DIR$/test" includeSubdirectories="true" />
+      <directory url="file://$PROJECT_DIR$/build" includeSubdirectories="true" />
     </excludeFromCompile>
     <resourceExtensions />
     <wildcardResourcePatterns />
--- a/langtools/make/intellij/langtools.iml	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/make/intellij/langtools.iml	Mon Jan 12 12:23:34 2015 -0800
@@ -1,20 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="false">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
     <output url="file://$MODULE_DIR$/build" />
     <output-test url="file://$MODULE_DIR$/build" />
     <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/build/bootstrap/gensrc" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/build/genstubs" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/java.base/share/classes" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/java.compiler/share/classes" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/jdk.compiler/share/classes" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/jdk.dev/share/classes" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/jdk.javadoc/share/classes" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/bootstrap/java.base/gensrc" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/bootstrap/java.compiler/gensrc" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/bootstrap/jdk.compiler/gensrc" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/bootstrap/jdk.dev/gensrc" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/bootstrap/jdk.javadoc/gensrc" isTestSource="false" />
     </content>
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="inheritedJdk" />
   </component>
 </module>
-
--- a/langtools/make/intellij/misc.xml	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/make/intellij/misc.xml	Mon Jan 12 12:23:34 2015 -0800
@@ -3,8 +3,8 @@
   <component name="EntryPointsManager">
     <entry_points version="2.0" />
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true">
-    <output url="file://$PROJECT_DIR$/build" />
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/.idea/out" />
   </component>
 </project>
 
--- a/langtools/make/netbeans/langtools/nbproject/project.xml	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/make/netbeans/langtools/nbproject/project.xml	Mon Jan 12 12:23:34 2015 -0800
@@ -478,29 +478,34 @@
         <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/4">
             <compilation-unit>
                 <package-root>${root}/src/java.base/share/classes</package-root>
+                <package-root>${root}/build/bootstrap/java.base/gensrc</package-root>
                 <built-to>${root}/build/java.base/classes</built-to>
                 <source-level>1.8</source-level>
             </compilation-unit>
             <compilation-unit>
                 <package-root>${root}/src/java.compiler/share/classes</package-root>
+                <package-root>${root}/build/bootstrap/java.compiler/gensrc</package-root>
                 <classpath mode="compile">${root}/build/java.base/classes</classpath>
                 <built-to>${root}/build/java.compiler/classes</built-to>
                 <source-level>1.8</source-level>
             </compilation-unit>
             <compilation-unit>
                 <package-root>${root}/src/jdk.compiler/share/classes</package-root>
+                <package-root>${root}/build/bootstrap/jdk.compiler/gensrc</package-root>
                 <classpath mode="compile">${root}/build/java.base/classes:${root}/build/java.compiler/classes</classpath>
                 <built-to>${root}/build/jdk.compiler/classes</built-to>
                 <source-level>1.8</source-level>
             </compilation-unit>
             <compilation-unit>
                 <package-root>${root}/src/jdk.dev/share/classes</package-root>
+                <package-root>${root}/build/bootstrap/jdk.dev/gensrc</package-root>
                 <classpath mode="compile">${root}/build/java.base/classes:${root}/build/java.compiler/classes:${root}/build/jdk.compiler/classes</classpath>
                 <built-to>${root}/build/jdk.dev/classes</built-to>
                 <source-level>1.8</source-level>
             </compilation-unit>
             <compilation-unit>
                 <package-root>${root}/src/jdk.javadoc/share/classes</package-root>
+                <package-root>${root}/build/bootstrap/jdk.javadoc/gensrc</package-root>
                 <classpath mode="compile">${root}/build/java.base/classes:${root}/build/java.compiler/classes:${root}/build/jdk.compiler/classes</classpath>
                 <built-to>${root}/build/jdk.javadoc/classes</built-to>
                 <source-level>1.8</source-level>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/tools/anttasks/PropertiesParserTask.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+package anttasks;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import propertiesparser.PropertiesParser;
+import propertiesparser.gen.ClassGenerator;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Resource;
+
+public class PropertiesParserTask extends MatchingTask {
+    public void addSrc(Path src) {
+        if (srcDirs == null)
+            srcDirs = new Path(getProject());
+        srcDirs.add(src);
+    }
+
+    public void setDestDir(File destDir) {
+        this.destDir = destDir;
+    }
+
+    @Override
+    public void execute() {
+        List<String> mainOpts = new ArrayList<String>();
+        int count = 0;
+        for (String dir : srcDirs.list()) {
+            File baseDir = getProject().resolveFile(dir);
+            DirectoryScanner s = getDirectoryScanner(baseDir);
+            for (String path : s.getIncludedFiles()) {
+                if (path.endsWith(".properties")) {
+                    File srcFile = new File(baseDir, path);
+                    String destPath =
+                            path.substring(0, path.lastIndexOf(File.separator) + 1) +
+                                    ClassGenerator.toplevelName(srcFile) + ".java";
+                    File destFile = new File(this.destDir, destPath);
+                    File destDir = destFile.getParentFile();
+                    // Arguably, the comparison in the next line should be ">", not ">="
+                    // but that assumes the resolution of the last modified time is fine
+                    // grained enough; in practice, it is better to use ">=".
+                    if (destFile.exists() && destFile.lastModified() >= srcFile.lastModified())
+                        continue;
+                    destDir.mkdirs();
+                    mainOpts.add("-compile");
+                    mainOpts.add(srcFile.getPath());
+                    mainOpts.add(destDir.getPath());
+                    count++;
+                }
+            }
+        }
+        if (mainOpts.size() > 0) {
+            log("Generating " + count + " resource files to " + destDir, Project.MSG_INFO);
+            PropertiesParser pp = new PropertiesParser(msg -> log(msg, Project.MSG_INFO));
+            boolean ok = pp.run(mainOpts.toArray(new String[mainOpts.size()]));
+            if (!ok)
+                throw new BuildException("PropertiesParser failed.");
+        }
+    }
+
+    private Path srcDirs;
+    private File destDir;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/tools/propertiesparser/PropertiesParser.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+
+package propertiesparser;
+
+import propertiesparser.parser.MessageFile;
+import propertiesparser.gen.ClassGenerator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.RuntimeException;
+import java.lang.Throwable;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/** Translates a .properties file into a .java file containing an enum-like Java class
+ *  which defines static factory methods for all resource keys in a given resource file. <P>
+ *
+ *  Usage: java PropertiesParser -compile [path to .properties file] [output folder where .java file will be written]
+ *
+ * @author mcimadamore
+ */
+
+public class PropertiesParser {
+
+    public Logger logger;
+
+    public PropertiesParser(Logger logger) {
+        this.logger = logger;
+    }
+
+    public static void main(String[] args) {
+        PropertiesParser pp = new PropertiesParser(msg -> System.out.println(msg));
+        boolean ok = pp.run(args);
+        if ( !ok ) {
+            System.exit(1);
+        }
+    }
+
+    public static interface Logger {
+        void info(String msg);
+    }
+
+    public void info(String msg) {
+        logger.info(msg);
+    }
+
+    public boolean run(String[] args) {
+        Map<String, String> optionsMap = parseOptions(args);
+        if (optionsMap.isEmpty()) {
+            usage();
+            return false;
+        }
+        try {
+            optionsMap.forEach((propfile, outfile) -> compilePropertyFile(propfile, outfile));
+            return true;
+        } catch (RuntimeException ex) {
+            ex.printStackTrace();
+            return false;
+        }
+    }
+
+    private void compilePropertyFile(String propertyPath, String outPath) {
+        try {
+            File propertyFile = new File(propertyPath);
+            String prefix = propertyFile.getName().split("\\.")[0];
+            MessageFile messageFile = new MessageFile(propertyFile, prefix);
+            new ClassGenerator().generateFactory(messageFile, new File(outPath));
+        } catch (Throwable ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    private Map<String, String> parseOptions(String args[]) {
+        Map<String, String> optionsMap = new HashMap<>(args.length);
+        for ( int i = 0; i < args.length ; i++ ) {
+            if ( "-compile".equals(args[i]) && i+2 < args.length ) {
+                optionsMap.put(args[++i], args[++i]);
+            } else {
+                return new HashMap<>();
+            }
+        }
+        return optionsMap;
+    }
+
+    private void usage() {
+        info("usage:");
+        info("    java PropertiesParser {-compile path_to_properties_file path_to_java_output_dir}");
+        info("");
+        info("Example:");
+        info("    java PropertiesParser -compile resources/test.properties resources");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/tools/propertiesparser/gen/ClassGenerator.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,419 @@
+package propertiesparser.gen;
+
+import propertiesparser.parser.Message;
+import propertiesparser.parser.MessageFile;
+import propertiesparser.parser.MessageInfo;
+import propertiesparser.parser.MessageLine;
+import propertiesparser.parser.MessageType;
+import propertiesparser.parser.MessageType.CompoundType;
+import propertiesparser.parser.MessageType.CustomType;
+import propertiesparser.parser.MessageType.SimpleType;
+import propertiesparser.parser.MessageType.UnionType;
+import propertiesparser.parser.MessageType.Visitor;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.TreeSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Properties;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class ClassGenerator {
+
+    /** Empty string - used to generate indentation padding. */
+    private final static String INDENT_STRING = "                                                                   ";
+
+    /** Default indentation step. */
+    private final static int INDENT_WIDTH = 4;
+
+    /** File-backed property file containing basic code stubs. */
+    static Properties stubs;
+
+    static {
+        //init properties from file
+        stubs = new Properties();
+        String resourcePath = "/propertiesparser/resources/templates.properties";
+        try (InputStream in = ClassGenerator.class.getResourceAsStream(resourcePath)) {
+            stubs.load(in);
+        } catch (IOException ex) {
+            throw new AssertionError(ex);
+        }
+    }
+
+    /**
+     * Supported stubs in the property file.
+     */
+    enum StubKind {
+        TOPLEVEL("toplevel.decl"),
+        FACTORY_CLASS("nested.decl"),
+        IMPORT("import.decl"),
+        FACTORY_METHOD_DECL("factory.decl.method"),
+        FACTORY_METHOD_ARG("factory.decl.method.arg"),
+        FACTORY_METHOD_BODY("factory.decl.method.body"),
+        FACTORY_FIELD("factory.decl.field"),
+        WILDCARDS_EXTENDS("wildcards.extends"),
+        SUPPRESS_WARNINGS("suppress.warnings");
+
+        /** stub key (as it appears in the property file) */
+        String key;
+
+        StubKind(String key) {
+            this.key = key;
+        }
+
+        /**
+         * Subst a list of arguments into a given stub.
+         */
+        String format(Object... args) {
+            return MessageFormat.format((String)stubs.get(key), args);
+        }
+    }
+
+    /**
+     * Nested factory class kind. There are multiple sub-factories, one for each kind of commonly used
+     * diagnostics (i.e. error, warnings, note, fragment). An additional category is defined for
+     * those resource keys whose prefix doesn't match any predefined category.
+     */
+    enum FactoryKind {
+        ERR("err", "Error", "Errors"),
+        WARN("warn", "Warning", "Warnings"),
+        NOTE("note", "Note", "Notes"),
+        MISC("misc", "Fragment", "Fragments"),
+        OTHER(null, null, null);
+
+        /** The prefix for this factory kind (i.e. 'err'). */
+        String prefix;
+
+        /** The type of the factory method/fields in this class. */
+        String keyClazz;
+
+        /** The class name to be used for this factory. */
+        String factoryClazz;
+
+        FactoryKind(String prefix, String keyClazz, String factoryClazz) {
+            this.prefix = prefix;
+            this.keyClazz = keyClazz;
+            this.factoryClazz = factoryClazz;
+        }
+
+        /**
+         * Utility method for parsing a factory kind from a resource key prefix.
+         */
+        static FactoryKind parseFrom(String prefix) {
+            for (FactoryKind k : FactoryKind.values()) {
+                if (k.prefix == null || k.prefix.equals(prefix)) {
+                    return k;
+                }
+            }
+            return null;
+        }
+    }
+
+    /**
+     * Main entry-point: generate a Java enum-like set of nested factory classes into given output
+     * folder. The factories are populated as mandated by the comments in the input resource file.
+     */
+    public void generateFactory(MessageFile messageFile, File outDir) {
+        Map<FactoryKind, List<Map.Entry<String, Message>>> groupedEntries =
+                messageFile.messages.entrySet().stream()
+                        .collect(Collectors.groupingBy(e -> FactoryKind.parseFrom(e.getKey().split("\\.")[1])));
+        //generate nested classes
+        List<String> nestedDecls = new ArrayList<>();
+        Set<String> importedTypes = new TreeSet<>();
+        for (Map.Entry<FactoryKind, List<Map.Entry<String, Message>>> entry : groupedEntries.entrySet()) {
+            if (entry.getKey() == FactoryKind.OTHER) continue;
+            //emit members
+            String members = entry.getValue().stream()
+                    .flatMap(e -> generateFactoryMethodsAndFields(e.getKey(), e.getValue()).stream())
+                    .collect(Collectors.joining("\n\n"));
+            //emit nested class
+            String factoryDecl =
+                    StubKind.FACTORY_CLASS.format(entry.getKey().factoryClazz, indent(members, 1));
+            nestedDecls.add(indent(factoryDecl, 1));
+            //add imports
+            entry.getValue().stream().forEach(e ->
+                    importedTypes.addAll(importedTypes(e.getValue().getMessageInfo().getTypes())));
+        }
+        String clazz = StubKind.TOPLEVEL.format(
+                packageName(messageFile.file),
+                String.join("\n", generateImports(importedTypes)),
+                toplevelName(messageFile.file),
+                String.join("\n", nestedDecls));
+        try (FileWriter fw = new FileWriter(new File(outDir, toplevelName(messageFile.file) + ".java"))) {
+            fw.append(clazz);
+        } catch (Throwable ex) {
+            throw new AssertionError(ex);
+        }
+    }
+
+    /**
+     * Indent a string to a given level.
+     */
+    String indent(String s, int level) {
+        return Stream.of(s.split("\n"))
+                .map(sub -> INDENT_STRING.substring(0, level * INDENT_WIDTH) + sub)
+                .collect(Collectors.joining("\n"));
+    }
+
+    /**
+     * Retrieve package part of given file object.
+     */
+    String packageName(File file) {
+        String path = file.getAbsolutePath();
+        int begin = path.indexOf("com" + File.separatorChar);
+        String packagePath = path.substring(begin, path.lastIndexOf(File.separatorChar));
+        String packageName =  packagePath.replace(File.separatorChar, '.');
+        return packageName;
+    }
+
+    /**
+     * Form the name of the toplevel factory class.
+     */
+    public static String toplevelName(File file) {
+        return Stream.of(file.getName().split("\\."))
+                .map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1))
+                .collect(Collectors.joining(""));
+    }
+
+    /**
+     * Generate a list of import declarations given a set of imported types.
+     */
+    List<String> generateImports(Set<String> importedTypes) {
+        List<String> importDecls = new ArrayList<>();
+        for (String it : importedTypes) {
+            importDecls.add(StubKind.IMPORT.format(it));
+        }
+        return importDecls;
+    }
+
+    /**
+     * Generate a list of factory methods/fields to be added to a given factory nested class.
+     */
+    List<String> generateFactoryMethodsAndFields(String key, Message msg) {
+        MessageInfo msgInfo = msg.getMessageInfo();
+        List<MessageLine> lines = msg.getLines(false);
+        String javadoc = lines.stream()
+                .filter(ml -> !ml.isInfo() && !ml.isEmptyOrComment())
+                .map(ml -> ml.text)
+                .collect(Collectors.joining("\n *"));
+        String[] keyParts = key.split("\\.");
+        FactoryKind k = FactoryKind.parseFrom(keyParts[1]);
+        String factoryName = factoryName(key);
+        if (msgInfo.getTypes().isEmpty()) {
+            //generate field
+            String factoryField = StubKind.FACTORY_FIELD.format(k.keyClazz, factoryName,
+                    "\"" + keyParts[0] + "\"",
+                    "\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"",
+                    javadoc);
+            return Collections.singletonList(factoryField);
+        } else {
+            //generate method
+            List<String> factoryMethods = new ArrayList<>();
+            for (List<MessageType> msgTypes : normalizeTypes(0, msgInfo.getTypes())) {
+                List<String> types = generateTypes(msgTypes);
+                List<String> argNames = argNames(types.size());
+                String suppressionString = needsSuppressWarnings(msgTypes) ?
+                        StubKind.SUPPRESS_WARNINGS.format() : "";
+                String factoryMethod = StubKind.FACTORY_METHOD_DECL.format(suppressionString, k.keyClazz,
+                        factoryName, argDecls(types, argNames).stream().collect(Collectors.joining(", ")),
+                        indent(StubKind.FACTORY_METHOD_BODY.format(k.keyClazz,
+                                "\"" + keyParts[0] + "\"",
+                                "\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"",
+                                argNames.stream().collect(Collectors.joining(", "))), 1),
+                        javadoc);
+                factoryMethods.add(factoryMethod);
+            }
+            return factoryMethods;
+        }
+    }
+
+    /**
+     * Form the name of a factory method/field given a resource key.
+     */
+    String factoryName(String key) {
+        return Stream.of(key.split("[\\.-]"))
+                .skip(2)
+                .map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1))
+                .collect(Collectors.joining(""));
+    }
+
+    /**
+     * Generate a formal parameter list given a list of types and names.
+     */
+    List<String> argDecls(List<String> types, List<String> args) {
+        List<String> argNames = new ArrayList<>();
+        for (int i = 0 ; i < types.size() ; i++) {
+            argNames.add(types.get(i) + " " + args.get(i));
+        }
+        return argNames;
+    }
+
+    /**
+     * Generate a list of formal parameter names given a size.
+     */
+    List<String> argNames(int size) {
+        List<String> argNames = new ArrayList<>();
+        for (int i = 0 ; i < size ; i++) {
+            argNames.add(StubKind.FACTORY_METHOD_ARG.format(i));
+        }
+        return argNames;
+    }
+
+    /**
+     * Convert a (normalized) parsed type into a string-based representation of some Java type.
+     */
+    List<String> generateTypes(List<MessageType> msgTypes) {
+        return msgTypes.stream().map(t -> t.accept(stringVisitor, null)).collect(Collectors.toList());
+    }
+    //where
+        Visitor<String, Void> stringVisitor = new Visitor<String, Void>() {
+            @Override
+            public String visitCustomType(CustomType t, Void aVoid) {
+                String customType = t.typeString;
+                return customType.substring(customType.lastIndexOf('.') + 1);
+            }
+
+            @Override
+            public String visitSimpleType(SimpleType t, Void aVoid) {
+                return t.clazz;
+            }
+
+            @Override
+            public String visitCompoundType(CompoundType t, Void aVoid) {
+                return StubKind.WILDCARDS_EXTENDS.format(t.kind.clazz.clazz,
+                        t.elemtype.accept(this, null));
+            }
+
+            @Override
+            public String visitUnionType(UnionType t, Void aVoid) {
+                throw new AssertionError("Union types should have been denormalized!");
+            }
+        };
+
+    /**
+     * See if any of the parsed types in the given list needs warning suppression.
+     */
+    boolean needsSuppressWarnings(List<MessageType> msgTypes) {
+        return msgTypes.stream().anyMatch(t -> t.accept(suppressWarningsVisitor, null));
+    }
+    //where
+    Visitor<Boolean, Void> suppressWarningsVisitor = new Visitor<Boolean, Void>() {
+        @Override
+        public Boolean visitCustomType(CustomType t, Void aVoid) {
+            //play safe
+            return true;
+        }
+        @Override
+        public Boolean visitSimpleType(SimpleType t, Void aVoid) {
+            switch (t) {
+                case LIST:
+                case SET:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
+        @Override
+        public Boolean visitCompoundType(CompoundType t, Void aVoid) {
+            return t.elemtype.accept(this, null);
+        }
+
+        @Override
+        public Boolean visitUnionType(UnionType t, Void aVoid) {
+            return needsSuppressWarnings(Arrays.asList(t.choices));
+        }
+    };
+
+    /**
+     * Retrieve a list of types that need to be imported, so that the factory body can refer
+     * to the types in the given list using simple names.
+     */
+    Set<String> importedTypes(List<MessageType> msgTypes) {
+        Set<String> imports = new TreeSet<>();
+        msgTypes.forEach(t -> t.accept(importVisitor, imports));
+        return imports;
+    }
+    //where
+    Visitor<Void, Set<String>> importVisitor = new Visitor<Void, Set<String>>() {
+        @Override
+        public Void visitCustomType(CustomType t, Set<String> imports) {
+            imports.add(t.typeString);
+            return null;
+        }
+
+        @Override
+        public Void visitSimpleType(SimpleType t, Set<String> imports) {
+            if (t.qualifier != null) {
+                imports.add(t.qualifier + "." + t.clazz);
+            }
+            return null;
+        }
+
+        @Override
+        public Void visitCompoundType(CompoundType t, Set<String> imports) {
+            visitSimpleType(t.kind.clazz, imports);
+            t.elemtype.accept(this, imports);
+            return null;
+        }
+
+        @Override
+        public Void visitUnionType(UnionType t, Set<String> imports) {
+            Stream.of(t.choices).forEach(c -> c.accept(this, imports));
+            return null;
+        }
+    };
+
+    /**
+     * Normalize parsed types in a comment line. If one or more types in the line contains alternatives,
+     * this routine generate a list of 'overloaded' normalized signatures.
+     */
+    List<List<MessageType>> normalizeTypes(int idx, List<MessageType> msgTypes) {
+        if (msgTypes.size() == idx) return Collections.singletonList(Collections.emptyList());
+        MessageType head = msgTypes.get(idx);
+        List<List<MessageType>> buf = new ArrayList<>();
+        for (MessageType alternative : head.accept(normalizeVisitor, null)) {
+            for (List<MessageType> rest : normalizeTypes(idx + 1, msgTypes)) {
+                List<MessageType> temp = new ArrayList<>(rest);
+                temp.add(0, alternative);
+                buf.add(temp);
+            }
+        }
+        return buf;
+    }
+    //where
+    Visitor<List<MessageType>, Void> normalizeVisitor = new Visitor<List<MessageType>, Void>() {
+        @Override
+        public List<MessageType> visitCustomType(CustomType t, Void aVoid) {
+            return Collections.singletonList(t);
+        }
+
+        @Override
+        public List<MessageType> visitSimpleType(SimpleType t, Void aVoid) {
+            return Collections.singletonList(t);
+        }
+
+        @Override
+        public List<MessageType> visitCompoundType(CompoundType t, Void aVoid) {
+            return t.elemtype.accept(this, null).stream()
+                    .map(nt -> new CompoundType(t.kind, nt))
+                    .collect(Collectors.toList());
+        }
+
+        @Override
+        public List<MessageType> visitUnionType(UnionType t, Void aVoid) {
+            return Stream.of(t.choices)
+                    .flatMap(t2 -> t2.accept(this, null).stream())
+                    .collect(Collectors.toList());
+        }
+    };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/tools/propertiesparser/parser/Message.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+package propertiesparser.parser;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A message within the message file.
+ * A message is a series of lines containing a "name=value" property,
+ * optionally preceded by a comment describing the use of placeholders
+ * such as {0}, {1}, etc within the property value.
+ */
+public final class Message {
+    final MessageLine firstLine;
+    private MessageInfo messageInfo;
+
+    Message(MessageLine l) {
+        firstLine = l;
+    }
+
+    /**
+     * Get the Info object for this message. It may be empty if there
+     * if no comment preceding the property specification.
+     */
+    public MessageInfo getMessageInfo() {
+        if (messageInfo == null) {
+            MessageLine l = firstLine.prev;
+            if (l != null && l.isInfo())
+                messageInfo = new MessageInfo(l.text);
+            else
+                messageInfo = MessageInfo.dummyInfo;
+        }
+        return messageInfo;
+    }
+
+    /**
+     * Get all the lines pertaining to this message.
+     */
+    public List<MessageLine> getLines(boolean includeAllPrecedingComments) {
+        List<MessageLine> lines = new ArrayList<>();
+        MessageLine l = firstLine;
+        if (includeAllPrecedingComments) {
+            // scan back to find end of prev message
+            while (l.prev != null && l.prev.isEmptyOrComment())
+                l = l.prev;
+            // skip leading blank lines
+            while (l.text.isEmpty())
+                l = l.next;
+        } else {
+            if (l.prev != null && l.prev.isInfo())
+                l = l.prev;
+        }
+
+        // include any preceding lines
+        for ( ; l != firstLine; l = l.next)
+            lines.add(l);
+
+        // include message lines
+        for (l = firstLine; l != null && l.hasContinuation(); l = l.next)
+            lines.add(l);
+        lines.add(l);
+
+        // include trailing blank line if present
+        l = l.next;
+        if (l != null && l.text.isEmpty())
+            lines.add(l);
+
+        return lines;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/tools/propertiesparser/parser/MessageFile.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,60 @@
+/*
+ * 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
+ * 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.
+ */
+package propertiesparser.parser;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.*;
+
+/**
+ * Class to facilitate manipulating compiler.properties.
+ */
+public class MessageFile {
+
+    MessageLine firstLine;
+    public Map<String, Message> messages = new TreeMap<>();
+    public File file;
+    public String keyPrefix;
+
+    public MessageFile(File file, String keyPrefix) throws IOException {
+        this.file = file;
+        this.keyPrefix = keyPrefix;
+        read(file);
+    }
+
+    final void read(File in) throws IOException {
+        MessageLine currLine = null;
+        for (String line : Files.readAllLines(in.toPath())) {
+            if (currLine == null)
+                firstLine = currLine = new MessageLine(line);
+            else
+                currLine = currLine.append(line);
+            if (line.startsWith(keyPrefix + ".")) {
+                int eq = line.indexOf("=");
+                if (eq > 0)
+                    messages.put(line.substring(0, eq), new Message(currLine));
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/tools/propertiesparser/parser/MessageInfo.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+package propertiesparser.parser;
+
+import propertiesparser.parser.MessageType.CompoundType;
+import propertiesparser.parser.MessageType.OrType;
+import propertiesparser.parser.MessageType.SimpleType;
+import propertiesparser.parser.MessageType.UnionType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An object to represent the comment that may precede the property
+ * specification in a Message.
+ * The comment is modelled as a list of fields, where the fields correspond
+ * to the placeholder values (e.g. {0}, {1}, etc) within the message value.
+ */
+public final class MessageInfo {
+
+    /** The fields of the Info object. */
+    List<MessageType> types = new ArrayList<>();
+
+    MessageInfo(String text) throws IllegalArgumentException {
+        if (text != null) {
+            if (!text.startsWith("# "))
+                throw new IllegalArgumentException();
+            String[] segs = text.substring(2).split(", ");
+            types = new ArrayList<>();
+            for (String seg : segs) {
+                types.add(parseType(seg));
+            }
+        }
+    }
+
+    public List<MessageType> getTypes() {
+        return types;
+    }
+
+    boolean isEmpty() {
+        return types.isEmpty();
+    }
+
+    @Override
+    public String toString() {
+        return types.toString();
+    }
+
+    /**
+     * Split the type comment into multiple alternatives (separated by 'or') - then parse each of them
+     * individually and form an 'or' type.
+     */
+    MessageType parseType(String text) {
+        int commentStart = text.indexOf("(");
+        if (commentStart != -1) {
+            //remove optional comment
+            text = text.substring(0, commentStart);
+        }
+        text = text.substring(text.indexOf(": ") + 2);
+        String[] alternatives = text.split(" " + OrType.OR_NAME + " ");
+        MessageType[] types = new MessageType[alternatives.length];
+        for (int i = 0 ; i < alternatives.length ; i++) {
+            types[i] = parseAlternative(alternatives[i].trim());
+        }
+        return types.length > 1 ?
+                new OrType(types) : types[0];
+    }
+
+    /**
+     * Parse a subset of the type comment; valid matches are simple types, compound types,
+     * union types and custom types.
+     */
+    MessageType parseAlternative(String text) {
+        //try with custom types
+        if (text.charAt(0) == '\'') {
+            int end = text.indexOf('\'', 1);
+            return new MessageType.CustomType(text.substring(1, end));
+        }
+        //try with simple types
+        for (SimpleType st : SimpleType.values()) {
+            if (text.equals(st.kindName())) {
+                return st;
+            }
+        }
+        //try with compound types
+        for (CompoundType.Kind ck : CompoundType.Kind.values()) {
+            if (text.startsWith(ck.kindName)) {
+                MessageType elemtype = parseAlternative(text.substring(ck.kindName.length() + 1).trim());
+                return new CompoundType(ck, elemtype);
+            }
+        }
+        //try with union types
+        for (UnionType.Kind uk : UnionType.Kind.values()) {
+            if (text.startsWith(uk.kindName)) {
+                return new UnionType(uk);
+            }
+        }
+        //no match - report a warning
+        System.err.println("WARNING - unrecognized type: " + text);
+        return SimpleType.UNKNOWN;
+    }
+
+    /** Dummy message info to be used when no resource key comment is available. */
+    static final MessageInfo dummyInfo = new MessageInfo(null);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/tools/propertiesparser/parser/MessageLine.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+package propertiesparser.parser;
+
+import java.util.regex.Pattern;
+
+/**
+ * A line of text within the message file.
+ * The lines form a doubly linked list for simple navigation.
+ */
+public class MessageLine {
+
+    static final Pattern emptyOrCommentPattern = Pattern.compile("( *#.*)?");
+    static final Pattern typePattern = Pattern.compile("[-\\\\'A-Z\\.a-z ]+( \\([A-Za-z 0-9]+\\))?");
+    static final Pattern infoPattern = Pattern.compile(String.format("# ([0-9]+: %s, )*[0-9]+: %s",
+            typePattern.pattern(), typePattern.pattern()));
+
+    public String text;
+    MessageLine prev;
+    MessageLine next;
+
+    MessageLine(String text) {
+        this.text = text;
+    }
+
+    public boolean isEmptyOrComment() {
+        return emptyOrCommentPattern.matcher(text).matches();
+    }
+
+    public boolean isInfo() {
+        return infoPattern.matcher(text).matches();
+    }
+
+    boolean hasContinuation() {
+        return (next != null) && text.endsWith("\\");
+    }
+
+    MessageLine append(String text) {
+        MessageLine l = new MessageLine(text);
+        append(l);
+        return l;
+    }
+
+    void append(MessageLine l) {
+        assert l.prev == null && l.next == null;
+        l.prev = this;
+        l.next = next;
+        if (next != null) {
+            next.prev = l;
+        }
+        next = l;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/tools/propertiesparser/parser/MessageType.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,250 @@
+/*
+ * 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.
+ */
+
+package propertiesparser.parser;
+
+/**
+ * Common interface to all kinds of diagnostic argument types.
+ */
+public interface MessageType {
+
+    /**
+     * Visitor method.
+     */
+    <R, A> R accept(Visitor<R, A> v, A a);
+
+    /**
+     * The type as mentioned in the resource file.
+     */
+    String kindName();
+
+    /**
+     * A custom type is a type for which a predefined alternative does not exist. As such, it is an
+     * handy option when prototyping - but usages of custom types should be avoided in product-quality
+     * resource file comments.
+     *
+     * Example: 'com.sun.tools.javac.code.Flags.Flag'
+     */
+    public static class CustomType implements MessageType {
+
+        /** The string-based representation of this type. */
+        public String typeString;
+
+        public CustomType(String typeString) {
+            this.typeString = typeString;
+        }
+
+        @Override
+        public String kindName() {
+            return typeString;
+        }
+
+        @Override
+        public <R, A> R accept(Visitor<R, A> v, A a) {
+            return v.visitCustomType(this, a);
+        }
+    }
+
+    /**
+     * A predefined type. All common types mentioned in the resource file comments are meant to
+     * be included here.
+     */
+    public enum SimpleType implements MessageType {
+
+        BOOLEAN("boolean", "boolean", null),
+        FRAGMENT("fragment", "Fragment", null),
+        DIAGNOSTIC("diagnostic", "JCDiagnostic", "com.sun.tools.javac.util"),
+        MODIFIER("modifier", "Modifier", "javax.lang.model.element"),
+        FILE("file", "File", "java.io"),
+        FILE_OBJECT("file object", "JavaFileObject", "javax.tools"),
+        NAME("name", "Name", "com.sun.tools.javac.util"),
+        NUMBER("number", "int", null),
+        OPTION_NAME("option name", "Option", "com.sun.tools.javac.main"),
+        SOURCE_VERSION("source version", "Source", "com.sun.tools.javac.code"),
+        STRING("string", "String", null),
+        SYMBOL("symbol", "Symbol", "com.sun.tools.javac.code"),
+        SYMBOL_KIND("symbol kind", "Kind", "com.sun.tools.javac.code.Kinds"),
+        KIND_NAME("kind name", "KindName", "com.sun.tools.javac.code.Kinds"),
+        TOKEN("token", "TokenKind", "com.sun.tools.javac.parser.Tokens"),
+        TYPE("type", "Type", "com.sun.tools.javac.code"),
+        SET("set", "Set", "java.util"),
+        LIST("list", "List", "java.util"),
+        OBJECT("object", "Object", null),
+        UNUSED("unused", "Void", null),
+        UNKNOWN("<unknown>", "UnknownType", null);
+
+        /** name of the predefined type as mentioned in the resource file. */
+        public final String kindName;
+
+        /** string-based representation of the type */
+        public final String clazz;
+
+        /** type qualifier (might be null) */
+        public final String qualifier;
+
+        SimpleType(String kindName, String clazz, String qualifier) {
+            this.kindName = kindName;
+            this.clazz = clazz;
+            this.qualifier = qualifier;
+        }
+
+        @Override
+        public String kindName() {
+            return kindName;
+        }
+
+        @Override
+        public <R, A> R accept(Visitor<R, A> v, A a) {
+            return v.visitSimpleType(this, a);
+        }
+    }
+
+    /**
+     * A compound type is a collection of some element type.
+     *
+     * Example: list of string
+     */
+    public static class CompoundType implements MessageType {
+
+        /**
+         * Compound type kind.
+         */
+        public enum Kind {
+            LIST("list of", SimpleType.LIST),
+            SET("set of", SimpleType.SET);
+
+            public final String kindName;
+            public final SimpleType clazz;
+
+            Kind(String kindName, SimpleType clazz) {
+                this.kindName = kindName;
+                this.clazz = clazz;
+            }
+        }
+
+        /** The compound type kind. */
+        public final Kind kind;
+
+        /** The element type. */
+        public final MessageType elemtype;
+
+        public CompoundType(Kind kind, MessageType elemtype) {
+            this.kind = kind;
+            this.elemtype = elemtype;
+        }
+
+        @Override
+        public String kindName() {
+            return kind.kindName;
+        }
+
+        @Override
+        public <R, A> R accept(Visitor<R, A> v, A a) {
+            return v.visitCompoundType(this, a);
+        }
+    }
+
+    /**
+     * A union type represents an alternative between two (or more) types. It can be useful to
+     * define the type of an argument which can assume multiple (unrelated) values; union types
+     * are only meant to be used in cases where the alternative comes up frequently enough in the
+     * resource file comments - in order to avoid cluttered comments.
+     *
+     * Example: message segment
+     */
+    public static class UnionType implements MessageType {
+
+        /**
+         * Union type kind.
+         */
+        public enum Kind {
+            MESSAGE_SEGMENT("message segment", SimpleType.DIAGNOSTIC, SimpleType.FRAGMENT),
+            FILE_NAME("file name", SimpleType.FILE, SimpleType.FILE_OBJECT);
+
+            final String kindName;
+            final SimpleType[] choices;
+
+            Kind(String kindName, SimpleType... choices) {
+                this.kindName = kindName;
+                this.choices = choices;
+            }
+        }
+
+        /** The union type kind. */
+        public final Kind kind;
+
+        /** The union type alternatives. */
+        public final MessageType[] choices;
+
+        UnionType(Kind kind) {
+            this(kind, kind.choices);
+        }
+
+        protected UnionType(Kind kind, MessageType[] choices) {
+            this.choices = choices;
+            this.kind = kind;
+        }
+
+        @Override
+        public String kindName() {
+            return kind.kindName;
+        }
+
+        @Override
+        public <R, A> R accept(Visitor<R, A> v, A a) {
+            return v.visitUnionType(this, a);
+        }
+    }
+
+    /**
+     * A subclass of union type representing 'explicit' alternatives in the resource file comments.
+     * Note: as the token 'or' is parsed with lowest priority, it is not possible, for instance,
+     * to form a compound type out of an 'or' type. In such cases a plain union type should be used
+     * instead.
+     *
+     * Examples: symbol or type
+     */
+    public static class OrType extends UnionType {
+
+        public static final String OR_NAME = "or";
+
+        @Override
+        public String kindName() {
+            return OR_NAME;
+        }
+
+        public OrType(MessageType... choices) {
+            super(null, choices);
+        }
+    }
+
+    /**
+     * Visitor class.
+     */
+    public static abstract class Visitor<R, A> {
+        public abstract R visitCustomType(CustomType t, A a);
+        public abstract R visitSimpleType(SimpleType t, A a);
+        public abstract R visitCompoundType(CompoundType t, A a);
+        public abstract R visitUnionType(UnionType t, A a);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/tools/propertiesparser/resources/templates.properties	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,48 @@
+toplevel.decl=\
+    package {0};\n\
+    \n\
+    {1}\n\
+    import com.sun.tools.javac.util.JCDiagnostic.Error;\n\
+    import com.sun.tools.javac.util.JCDiagnostic.Warning;\n\
+    import com.sun.tools.javac.util.JCDiagnostic.Note;\n\
+    import com.sun.tools.javac.util.JCDiagnostic.Fragment;\n\
+    \n\
+    public class {2} '{'\n\
+    {3}\n\
+    '}'\n
+
+import.decl=\
+    import {0};
+
+nested.decl =\
+    public static class {0} '{'\n\
+    {1}\n\
+    '}'
+
+factory.decl.method=\
+    /**\n\
+    ' '* {5}\n\
+    ' '*/\n\
+    {0}public static {1} {2}({3}) '{'\n\
+    {4}\n\
+    '}'
+
+factory.decl.method.arg=\
+    arg{0}
+
+factory.decl.method.body=\
+    return new {0}({1}, {2}, {3});
+
+factory.decl.field=\
+    /**\n\
+    ' '* {4}\n\
+    ' '*/\n\
+    public static final {0} {1} = new {0}({2}, {3});
+
+wildcards.extends=\
+    {0}<? extends {1}>
+
+suppress.warnings=\
+  @SuppressWarnings("rawtypes")\n
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/java.compiler/share/classes/javax/tools/FileManagerUtils.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2014, 2015, 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.
+ */
+
+package javax.tools;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.util.Iterator;
+
+/**
+ * Package-private utility methods to convert between files and paths.
+ *
+ * @since 1.9
+ */
+class FileManagerUtils {
+    private FileManagerUtils() { }
+
+    static Iterable<Path> asPaths(final Iterable<? extends File> files) {
+        return () -> new Iterator<Path>() {
+            Iterator<? extends File> iter = files.iterator();
+
+            @Override
+            public boolean hasNext() {
+                return iter.hasNext();
+            }
+
+            @Override
+            public Path next() {
+                return iter.next().toPath();
+            }
+        };
+    }
+
+    static Iterable<File> asFiles(final Iterable<? extends Path> paths) {
+        return () -> new Iterator<File>() {
+            Iterator<? extends Path> iter = paths.iterator();
+
+            @Override
+            public boolean hasNext() {
+                return iter.hasNext();
+            }
+
+            @Override
+            public File next() {
+                Path p = iter.next();
+                try {
+                    return p.toFile();
+                } catch (UnsupportedOperationException e) {
+                    throw new IllegalArgumentException(p.toString(), e);
+                }
+            }
+        };
+    }
+}
--- a/langtools/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2015, 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
@@ -27,13 +27,16 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.*;
+import java.nio.file.Path;
+import java.util.Arrays;
+
+import static javax.tools.FileManagerUtils.*;
 
 /**
- * File manager based on {@linkplain File java.io.File}.  A common way
- * to obtain an instance of this class is using {@linkplain
- * JavaCompiler#getStandardFileManager
- * getStandardFileManager}, for example:
+ * File manager based on {@linkplain File java.io.File} and {@linkplain Path java.nio.file.Path}.
+ *
+ * A common way to obtain an instance of this class is using
+ * {@linkplain JavaCompiler#getStandardFileManager getStandardFileManager}, for example:
  *
  * <pre>
  *   JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
@@ -110,7 +113,7 @@
  *     <code>file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java</code>
  *   </li>
  *   <li>
- *     <code>jar:///C:/Documents%20and%20Settings/UncleBob/lib/vendorA.jar!com/vendora/LibraryClass.class</code>
+ *     <code>jar:///C:/Documents%20and%20Settings/UncleBob/lib/vendorA.jar!/com/vendora/LibraryClass.class</code>
  *   </li>
  * </ul>
  * Whereas these are not (reason in parentheses):
@@ -120,7 +123,7 @@
  *     and depend on the current directory)
  *   </li>
  *   <li>
- *     <code>jar:lib/vendorA.jar!com/vendora/LibraryClass.class</code>
+ *     <code>jar:lib/vendorA.jar!/com/vendora/LibraryClass.class</code>
  *     (the first half of the path depends on the current directory,
  *     whereas the component after ! is legal)
  *   </li>
@@ -134,6 +137,10 @@
  *   </li>
  * </ul>
  *
+ * <p>All implementations of this interface must support Path objects representing
+ * files in the {@linkplain java.nio.file.FileSystems#getDefault() default file system.}
+ * It is recommended that implementations should support Path objects from any filesystem.</p>
+ *
  * @author Peter von der Ah&eacute;
  * @since 1.6
  */
@@ -147,11 +154,12 @@
      * @param a a file object
      * @param b a file object
      * @return true if the given file objects represent the same
-     * canonical file or zip file entry; false otherwise
+     * canonical file, zip file entry or path; false otherwise
      *
      * @throws IllegalArgumentException if either of the arguments
      * were created with another file manager implementation
      */
+    @Override
     boolean isSameFile(FileObject a, FileObject b);
 
     /**
@@ -166,6 +174,27 @@
         Iterable<? extends File> files);
 
     /**
+     * Returns file objects representing the given paths.
+     *
+     * <p>The default implementation converts each path to a file and calls
+     * {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}.
+     * IllegalArgumentException will be thrown if any of the paths
+     * cannot be converted to a file.
+     *
+     * @param paths a list of paths
+     * @return a list of file objects
+     * @throws IllegalArgumentException if the list of paths includes
+     * a directory or if this file manager does not support any of the
+     * given paths.
+     *
+     * @since 1.9
+     */
+    default Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(
+            Iterable<? extends Path> paths) {
+        return getJavaFileObjectsFromFiles(asFiles(paths));
+    }
+
+    /**
      * Returns file objects representing the given files.
      * Convenience method equivalent to:
      *
@@ -183,6 +212,27 @@
     Iterable<? extends JavaFileObject> getJavaFileObjects(File... files);
 
     /**
+     * Returns file objects representing the given paths.
+     * Convenience method equivalent to:
+     *
+     * <pre>
+     *     getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths))
+     * </pre>
+     *
+     * @param paths an array of paths
+     * @return a list of file objects
+     * @throws IllegalArgumentException if the array of files includes
+     * a directory
+     * @throws NullPointerException if the given array contains null
+     * elements
+     *
+     * @since 1.9
+     */
+    default Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths) {
+        return getJavaFileObjectsFromPaths(Arrays.asList(paths));
+    }
+
+    /**
      * Returns file objects representing the given file names.
      *
      * @param names a list of file names
@@ -211,29 +261,94 @@
     Iterable<? extends JavaFileObject> getJavaFileObjects(String... names);
 
     /**
-     * Associates the given path with the given location.  Any
+     * Associates the given search path with the given location.  Any
      * previous value will be discarded.
      *
      * @param location a location
-     * @param path a list of files, if {@code null} use the default
-     * path for this location
+     * @param files a list of files, if {@code null} use the default
+     * search path for this location
      * @see #getLocation
-     * @throws IllegalArgumentException if location is an output
-     * location and path does not contain exactly one element
-     * @throws IOException if location is an output location and path
+     * @throws IllegalArgumentException if {@code location} is an output
+     * location and {@code files} does not contain exactly one element
+     * @throws IOException if {@code location} is an output location and
      * does not represent an existing directory
      */
-    void setLocation(Location location, Iterable<? extends File> path)
+    void setLocation(Location location, Iterable<? extends File> files)
         throws IOException;
 
     /**
-     * Returns the path associated with the given location.
+     * Associates the given search path with the given location.  Any
+     * previous value will be discarded.
+     *
+     * <p>The default implementation converts each path to a file and calls
+     * {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}.
+     * IllegalArgumentException will be thrown if any of the paths
+     * cannot be converted to a file.</p>
+     *
+     * @param location a location
+     * @param paths a list of paths, if {@code null} use the default
+     * search path for this location
+     * @see #getLocation
+     * @throws IllegalArgumentException if {@code location} is an output
+     * location and {@code paths} does not contain exactly one element
+     * or if this file manager does not support any of the given paths
+     * @throws IOException if {@code location} is an output location and
+     * {@code paths} does not represent an existing directory
+     *
+     * @since 1.9
+     */
+    default void setLocationFromPaths(Location location, Iterable<? extends Path> paths)
+        throws IOException {
+        setLocation(location, asFiles(paths));
+    }
+
+    /**
+     * Returns the search path associated with the given location.
      *
      * @param location a location
      * @return a list of files or {@code null} if this location has no
-     * associated path
+     * associated search path
+     * @throws IllegalStateException if any element of the search path
+     * cannot be converted to a {@linkplain File}.
+     *
      * @see #setLocation
+     * @see Path#toFile
      */
     Iterable<? extends File> getLocation(Location location);
 
+    /**
+     * Returns the search path associated with the given location.
+     *
+     * @param location a location
+     * @return a list of paths or {@code null} if this location has no
+     * associated search path
+     *
+     * @see #setLocationFromPaths
+     * @since 1.9
+     */
+    default Iterable<? extends Path> getLocationAsPaths(Location location) {
+        return asPaths(getLocation(location));
+    }
+
+    /**
+     * Returns the path, if any, underlying this file object (optional operation).
+     * File objects derived from a {@link java.nio.file.FileSystem FileSystem},
+     * including the default file system, typically have a corresponding underlying
+     * {@link java.nio.file.Path Path} object. In such cases, this method may be
+     * used to access that object.
+     *
+     * <p>The default implementation throws {@link UnsupportedOperationException}
+     * for all files.</p>
+     *
+     * @param file a file object
+     * @return a path representing the same underlying file system artifact
+     * @throws IllegalArgumentException if the file object does not have an underlying path
+     * @throws UnsupportedOperationException if the operation is not supported by this file manager
+     *
+     * @since 1.9
+     */
+    default Path asPath(FileObject file) {
+        throw new UnsupportedOperationException();
+    }
+
 }
--- a/langtools/src/java.compiler/share/classes/javax/tools/ToolProvider.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/java.compiler/share/classes/javax/tools/ToolProvider.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, 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
@@ -92,6 +92,10 @@
     /**
      * Returns the Java&trade; programming language compiler provided
      * with this platform.
+     * <p>The file manager returned by calling
+     * {@link JavaCompiler#getStandardFileManager getStandardFileManager}
+     * on this compiler supports paths provided by any
+     * {@linkplain java.nio.file.FileSystem filesystem}.</p>
      * @return the compiler provided with this platform or
      * {@code null} if no compiler is provided
      */
@@ -105,6 +109,10 @@
     /**
      * Returns the Java&trade; programming language documentation tool provided
      * with this platform.
+     * <p>The file manager returned by calling
+     * {@link DocumentationTool#getStandardFileManager getStandardFileManager}
+     * on this tool supports paths provided by any
+     * {@linkplain java.nio.file.FileSystem filesystem}.</p>
      * @return the documentation tool provided with this platform or
      * {@code null} if no documentation tool is provided
      */
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/AnnoConstruct.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/AnnoConstruct.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, 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
@@ -26,6 +26,7 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.annotation.Inherited;
+import java.lang.annotation.Repeatable;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
@@ -183,65 +184,12 @@
         return c == null ? null : AnnotationProxyMaker.generateAnnotation(c, annoType);
     }
 
-    // Needed to unpack the runtime view of containing annotations
-    private static final Class<? extends Annotation> REPEATABLE_CLASS = initRepeatable();
-    private static final Method VALUE_ELEMENT_METHOD = initValueElementMethod();
-
-    private static Class<? extends Annotation> initRepeatable() {
-        try {
-            // Repeatable will not be available when bootstrapping on
-            // JDK 7 so use a reflective lookup instead of a class
-            // literal for Repeatable.class.
-            return Class.forName("java.lang.annotation.Repeatable").asSubclass(Annotation.class);
-        } catch (ClassNotFoundException | SecurityException e) {
-            return null;
-        }
-    }
-
-    private static Method initValueElementMethod() {
-        if (REPEATABLE_CLASS == null)
-            return null;
-
-        Method m = null;
-        try {
-            m = REPEATABLE_CLASS.getMethod("value");
-            if (m != null)
-                m.setAccessible(true);
-            return m;
-        } catch (NoSuchMethodException e) {
-            return null;
-        }
-    }
-
-
     // Helper to getAnnotationsByType
     private static Class<? extends Annotation> getContainer(Class<? extends Annotation> annoType) {
-        // Since we can not refer to java.lang.annotation.Repeatable until we are
-        // bootstrapping with java 8 we need to get the Repeatable annotation using
-        // reflective invocations instead of just using its type and element method.
-        if (REPEATABLE_CLASS != null &&
-            VALUE_ELEMENT_METHOD != null) {
-            // Get the Repeatable instance on the annotations declaration
-            Annotation repeatable = (Annotation)annoType.getAnnotation(REPEATABLE_CLASS);
-            if (repeatable != null) {
-                try {
-                    // Get the value element, it should be a class
-                    // indicating the containing annotation type
-                    @SuppressWarnings("unchecked")
-                    Class<? extends Annotation> containerType = (Class)VALUE_ELEMENT_METHOD.invoke(repeatable);
-                    if (containerType == null)
-                        return null;
-
-                    return containerType;
-                } catch (ClassCastException | IllegalAccessException | InvocationTargetException e) {
-                    return null;
-                }
-            }
-        }
-        return null;
+        Repeatable repeatable = annoType.getAnnotation(Repeatable.class);
+        return (repeatable == null) ? null : repeatable.value();
     }
 
-
     // Helper to getAnnotationsByType
     private static Attribute[] unpackAttributes(Attribute.Compound container) {
         // We now have an instance of the container,
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jan 12 12:23:34 2015 -0800
@@ -207,6 +207,7 @@
      *  are correct.
      *
      *  @param tree     The tree whose kind and type is checked
+     *  @param found    The computed type of the tree
      *  @param ownkind  The computed kind of the tree
      *  @param resultInfo  The expected result of the tree
      */
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Jan 12 12:23:34 2015 -0800
@@ -39,7 +39,6 @@
 import com.sun.tools.javac.comp.Infer.InferenceContext;
 import com.sun.tools.javac.comp.Infer.FreeTypeListener;
 import com.sun.tools.javac.comp.Resolve.MethodResolutionContext.Candidate;
-import com.sun.tools.javac.comp.Resolve.MethodResolutionDiagHelper.DiagnosticRewriter;
 import com.sun.tools.javac.comp.Resolve.MethodResolutionDiagHelper.Template;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.main.Option;
@@ -55,11 +54,12 @@
 
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.EnumMap;
 import java.util.EnumSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.function.BiPredicate;
+import java.util.stream.Stream;
 
 import javax.lang.model.element.ElementVisitor;
 
@@ -1008,7 +1008,7 @@
                 DeferredType dt = (DeferredType)found;
                 return dt.check(this);
             } else {
-                Type uResult = U(found.baseType());
+                Type uResult = U(found);
                 Type capturedType = pos == null || pos.getTree() == null ?
                         types.capture(uResult) :
                         checkContext.inferenceContext()
@@ -2546,17 +2546,7 @@
                                 final JCDiagnostic details = sym.kind == WRONG_MTH ?
                                                 ((InapplicableSymbolError)sym.baseSymbol()).errCandidate().snd :
                                                 null;
-                                sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) {
-                                    @Override
-                                    JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos,
-                                            Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
-                                        String key = details == null ?
-                                            "cant.apply.diamond" :
-                                            "cant.apply.diamond.1";
-                                        return diags.create(dkind, log.currentSource(), pos, key,
-                                                diags.fragment("diamond", site.tsym), details);
-                                    }
-                                };
+                                sym = new DiamondError(sym, currentResolutionContext);
                                 sym = accessMethod(sym, pos, site, names.init, true, argtypes, typeargtypes);
                                 env.info.pendingResolutionPhase = currentResolutionContext.step;
                             }
@@ -3724,15 +3714,10 @@
             else {
                 Pair<Symbol, JCDiagnostic> c = errCandidate();
                 if (compactMethodDiags) {
-                    for (Map.Entry<Template, DiagnosticRewriter> _entry :
-                            MethodResolutionDiagHelper.rewriters.entrySet()) {
-                        if (_entry.getKey().matches(c.snd)) {
-                            JCDiagnostic simpleDiag =
-                                    _entry.getValue().rewriteDiagnostic(diags, pos,
-                                        log.currentSource(), dkind, c.snd);
-                            simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
-                            return simpleDiag;
-                        }
+                    JCDiagnostic simpleDiag =
+                        MethodResolutionDiagHelper.rewrite(diags, pos, log.currentSource(), dkind, c.snd);
+                    if (simpleDiag != null) {
+                        return simpleDiag;
                     }
                 }
                 Symbol ws = c.fst.asMemberOf(site, types);
@@ -3765,9 +3750,8 @@
     }
 
     /**
-     * ResolveError error class indicating that a set of symbols
-     * (either methods, constructors or operands) is not applicable
-     * given an actual arguments/type argument list.
+     * ResolveError error class indicating that a symbol (either methods, constructors or operand)
+     * is not applicable given an actual arguments/type argument list.
      */
     class InapplicableSymbolsError extends InapplicableSymbolError {
 
@@ -3864,6 +3848,44 @@
     }
 
     /**
+     * DiamondError error class indicating that a constructor symbol is not applicable
+     * given an actual arguments/type argument list using diamond inference.
+     */
+    class DiamondError extends InapplicableSymbolError {
+
+        Symbol sym;
+
+        public DiamondError(Symbol sym, MethodResolutionContext context) {
+            super(sym.kind, "diamondError", context);
+            this.sym = sym;
+        }
+
+        JCDiagnostic getDetails() {
+            return (sym.kind == WRONG_MTH) ?
+                    ((InapplicableSymbolError)sym.baseSymbol()).errCandidate().snd :
+                    null;
+        }
+
+        @Override
+        JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos,
+                Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
+            JCDiagnostic details = getDetails();
+            if (details != null && compactMethodDiags) {
+                JCDiagnostic simpleDiag =
+                        MethodResolutionDiagHelper.rewrite(diags, pos, log.currentSource(), dkind, details);
+                if (simpleDiag != null) {
+                    return simpleDiag;
+                }
+            }
+            String key = details == null ?
+                "cant.apply.diamond" :
+                "cant.apply.diamond.1";
+            return diags.create(dkind, log.currentSource(), pos, key,
+                    diags.fragment("diamond", site.tsym), details);
+        }
+    }
+
+    /**
      * An InvalidSymbolError error class indicating that a symbol is not
      * accessible from a given site
      */
@@ -4146,6 +4168,28 @@
             }
         }
 
+        /**
+         * Common rewriter for all argument mismatch simplifications.
+         */
+        static class ArgMismatchRewriter implements DiagnosticRewriter {
+
+            /** the index of the subdiagnostic to be used as primary. */
+            int causeIndex;
+
+            public ArgMismatchRewriter(int causeIndex) {
+                this.causeIndex = causeIndex;
+            }
+
+            @Override
+            public JCDiagnostic rewriteDiagnostic(JCDiagnostic.Factory diags,
+                    DiagnosticPosition preferedPos, DiagnosticSource preferredSource,
+                    DiagnosticType preferredKind, JCDiagnostic d) {
+                JCDiagnostic cause = (JCDiagnostic)d.getArgs()[causeIndex];
+                return diags.create(preferredKind, preferredSource, d.getDiagnosticPosition(),
+                        "prob.found.req", cause);
+            }
+        }
+
         /** a dummy template that match any diagnostic argument */
         static final Template skip = new Template("") {
             @Override
@@ -4154,22 +4198,61 @@
             }
         };
 
+        /** template for matching inference-free arguments mismatch failures */
+        static final Template argMismatchTemplate = new Template(MethodCheckDiag.ARG_MISMATCH.regex(), skip);
+
+        /** template for matching inference related arguments mismatch failures */
+        static final Template inferArgMismatchTemplate = new Template(MethodCheckDiag.ARG_MISMATCH.regex(), skip, skip) {
+            @Override
+            boolean matches(Object o) {
+                if (!super.matches(o)) {
+                    return false;
+                }
+                JCDiagnostic d = (JCDiagnostic)o;
+                @SuppressWarnings("unchecked")
+                List<Type> tvars = (List<Type>)d.getArgs()[0];
+                return !containsAny(d, tvars);
+            }
+
+            BiPredicate<Object, List<Type>> containsPredicate = (o, ts) -> {
+                if (o instanceof Type) {
+                    return ((Type)o).containsAny(ts);
+                } else if (o instanceof JCDiagnostic) {
+                    return containsAny((JCDiagnostic)o, ts);
+                } else {
+                    return false;
+                }
+            };
+
+            boolean containsAny(JCDiagnostic d, List<Type> ts) {
+                return Stream.of(d.getArgs())
+                        .anyMatch(o -> containsPredicate.test(o, ts));
+            }
+        };
+
         /** rewriter map used for method resolution simplification */
         static final Map<Template, DiagnosticRewriter> rewriters = new LinkedHashMap<>();
 
         static {
-            String argMismatchRegex = MethodCheckDiag.ARG_MISMATCH.regex();
-            rewriters.put(new Template(argMismatchRegex, skip),
-                    new DiagnosticRewriter() {
-                @Override
-                public JCDiagnostic rewriteDiagnostic(JCDiagnostic.Factory diags,
-                        DiagnosticPosition preferedPos, DiagnosticSource preferredSource,
-                        DiagnosticType preferredKind, JCDiagnostic d) {
-                    JCDiagnostic cause = (JCDiagnostic)d.getArgs()[0];
-                    return diags.create(preferredKind, preferredSource, d.getDiagnosticPosition(),
-                            "prob.found.req", cause);
+            rewriters.put(argMismatchTemplate, new ArgMismatchRewriter(0));
+            rewriters.put(inferArgMismatchTemplate, new ArgMismatchRewriter(1));
+        }
+
+        /**
+         * Main entry point for diagnostic rewriting - given a diagnostic, see if any templates matches it,
+         * and rewrite it accordingly.
+         */
+        static JCDiagnostic rewrite(JCDiagnostic.Factory diags, DiagnosticPosition pos, DiagnosticSource source,
+                                    DiagnosticType dkind, JCDiagnostic d) {
+            for (Map.Entry<Template, DiagnosticRewriter> _entry : rewriters.entrySet()) {
+                if (_entry.getKey().matches(d)) {
+                    JCDiagnostic simpleDiag =
+                            _entry.getValue().rewriteDiagnostic(diags, pos, source, dkind, d);
+                    simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
+                    return simpleDiag;
                 }
-            });
+            }
+            return null;
         }
     }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Mon Jan 12 12:23:34 2015 -0800
@@ -739,7 +739,9 @@
     }
 
     public void visitUnary(JCUnary tree) {
-        tree.arg = translate(tree.arg, tree.operator.type.getParameterTypes().head);
+        tree.arg = translate(tree.arg, (tree.getTag() == Tag.NULLCHK)
+            ? tree.type
+            : tree.operator.type.getParameterTypes().head);
         result = tree;
     }
 
@@ -753,7 +755,15 @@
         tree.clazz = translate(tree.clazz, null);
         Type originalTarget = tree.type;
         tree.type = erasure(tree.type);
-        tree.expr = translate(tree.expr, erasure(tree.expr.type));
+        JCExpression newExpression = translate(tree.expr, erasure(tree.expr.type));
+        if (newExpression != tree.expr) {
+            JCTypeCast typeCast = newExpression.hasTag(Tag.TYPECAST)
+                ? (JCTypeCast) newExpression
+                : null;
+            tree.expr = typeCast != null && types.isSameType(typeCast.type, originalTarget, true)
+                ? typeCast.expr
+                : newExpression;
+        }
         if (originalTarget.isCompound()) {
             Type.IntersectionClassType ict = (Type.IntersectionClassType)originalTarget;
             for (Type c : ict.getExplicitComponents()) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, 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
@@ -101,7 +101,6 @@
     private final Set<JavaFileObject.Kind> sourceOrClass =
         EnumSet.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS);
 
-    protected boolean mmappedIO;
     protected boolean symbolFileEnabled;
 
     protected enum SortFiles implements Comparator<Path> {
@@ -157,7 +156,6 @@
         if (contextUseOptimizedZip)
             zipFileIndexCache = ZipFileIndexCache.getSharedInstance();
 
-        mmappedIO = options.isSet("mmappedIO");
         symbolFileEnabled = !options.isSet("ignore.symbol.file");
 
         String sf = options.get("sortFiles");
@@ -177,10 +175,12 @@
         return symbolFileEnabled;
     }
 
+    // used by tests
     public JavaFileObject getFileForInput(String name) {
         return getRegularFile(Paths.get(name));
     }
 
+    // used by tests
     public JavaFileObject getRegularFile(Path file) {
         return new RegularFileObject(this, file);
     }
@@ -195,10 +195,10 @@
 
     @Override @DefinedBy(Api.COMPILER)
     public Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings(Iterable<String> names) {
-        ListBuffer<File> files = new ListBuffer<>();
+        ListBuffer<Path> paths = new ListBuffer<>();
         for (String name : names)
-            files.append(new File(nullCheck(name)));
-        return getJavaFileObjectsFromFiles(files.toList());
+            paths.append(Paths.get(nullCheck(name)));
+        return getJavaFileObjectsFromPaths(paths.toList());
     }
 
     @Override @DefinedBy(Api.COMPILER)
@@ -873,11 +873,30 @@
     }
 
     @Override @DefinedBy(Api.COMPILER)
+    public Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(
+        Iterable<? extends Path> paths)
+    {
+        ArrayList<RegularFileObject> result;
+        if (paths instanceof Collection<?>)
+            result = new ArrayList<>(((Collection<?>)paths).size());
+        else
+            result = new ArrayList<>();
+        for (Path p: paths)
+            result.add(new RegularFileObject(this, nullCheck(p)));
+        return result;
+    }
+
+    @Override @DefinedBy(Api.COMPILER)
     public Iterable<? extends JavaFileObject> getJavaFileObjects(File... files) {
         return getJavaFileObjectsFromFiles(Arrays.asList(nullCheck(files)));
     }
 
     @Override @DefinedBy(Api.COMPILER)
+    public Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths) {
+        return getJavaFileObjectsFromPaths(Arrays.asList(nullCheck(paths)));
+    }
+
+    @Override @DefinedBy(Api.COMPILER)
     public void setLocation(Location location,
                             Iterable<? extends File> searchpath)
         throws IOException
@@ -887,12 +906,22 @@
     }
 
     @Override @DefinedBy(Api.COMPILER)
+    public void setLocationFromPaths(Location location,
+                            Iterable<? extends Path> searchpath)
+        throws IOException
+    {
+        nullCheck(location);
+        locations.setLocation(location, nullCheck(searchpath));
+    }
+
+    @Override @DefinedBy(Api.COMPILER)
     public Iterable<? extends File> getLocation(Location location) {
         nullCheck(location);
         return asFiles(locations.getLocation(location));
     }
 
-    private Iterable<? extends Path> getLocationAsPaths(Location location) {
+    @Override @DefinedBy(Api.COMPILER)
+    public Iterable<? extends Path> getLocationAsPaths(Location location) {
         nullCheck(location);
         return locations.getLocation(location);
     }
@@ -905,6 +934,14 @@
         return locations.getOutputLocation(SOURCE_OUTPUT);
     }
 
+    @Override @DefinedBy(Api.COMPILER)
+    public Path asPath(FileObject file) {
+        if (file instanceof RegularFileObject) {
+            return ((RegularFileObject) file).file;
+        } else
+            throw new IllegalArgumentException(file.getName());
+    }
+
     /**
      * Enforces the specification of a "relative" name as used in
      * {@linkplain #getFileForInput(Location,String,String)
@@ -1010,12 +1047,12 @@
 
             @Override
             public File next() {
-                return iter.next().toFile();
+                try {
+                    return iter.next().toFile();
+                } catch (UnsupportedOperationException e) {
+                    throw new IllegalStateException(e);
+                }
             }
         };
     }
-
-    private static File asFile(Path path) {
-        return path == null ? null : path.toFile();
-    }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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
@@ -428,7 +428,7 @@
 
     /**
      * General purpose implementation for search path locations, such as -sourcepath/SOURCE_PATH and
-     * -processorPath/ANNOTATION_PROCESS_PATH. All options are treated as equivalent (i.e. aliases.)
+     * -processorPath/ANNOTATION_PROCESSOR_PATH. All options are treated as equivalent (i.e. aliases.)
      * The value is an ordered set of files and/or directories.
      */
     private class SimpleLocationHandler extends LocationHandler {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -1740,15 +1740,17 @@
             // The method wasn't found: emit a warning and recover
             JavaFileObject prevSource = log.useSource(requestingOwner.classfile);
             try {
-                if (failure == null) {
-                    log.warning("annotation.method.not.found",
-                                container,
-                                name);
-                } else {
-                    log.warning("annotation.method.not.found.reason",
-                                container,
-                                name,
-                                failure.getDetailValue());//diagnostic, if present
+                if (lintClassfile) {
+                    if (failure == null) {
+                        log.warning("annotation.method.not.found",
+                                    container,
+                                    name);
+                    } else {
+                        log.warning("annotation.method.not.found.reason",
+                                    container,
+                                    name,
+                                    failure.getDetailValue());//diagnostic, if present
+                    }
                 }
             } finally {
                 log.useSource(prevSource);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -1159,7 +1159,7 @@
                     Assert.check(r.start_pc >= 0
                             && r.start_pc <= code.cp);
                     databuf.appendChar(r.start_pc);
-                    Assert.check(r.length >= 0
+                    Assert.check(r.length > 0
                             && (r.start_pc + r.length) <= code.cp);
                     databuf.appendChar(r.length);
                     VarSymbol sym = var.sym;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -182,8 +182,6 @@
 
     final MethodSymbol meth;
 
-    final LVTRanges lvtRanges;
-
     /** Construct a code object, given the settings of the fatcode,
      *  debugging info switches and the CharacterRangeTable.
      */
@@ -196,8 +194,7 @@
                 CRTable crt,
                 Symtab syms,
                 Types types,
-                Pool pool,
-                LVTRanges lvtRanges) {
+                Pool pool) {
         this.meth = meth;
         this.fatcode = fatcode;
         this.lineMap = lineMap;
@@ -219,7 +216,6 @@
         state = new State();
         lvar = new LocalVar[20];
         this.pool = pool;
-        this.lvtRanges = lvtRanges;
     }
 
 
@@ -1193,7 +1189,9 @@
     public int entryPoint(State state) {
         int pc = curCP();
         alive = true;
-        this.state = state.dup();
+        State newState = state.dup();
+        setDefined(newState.defined);
+        this.state = newState;
         Assert.check(state.stacksize <= max_stack);
         if (debugCode) System.err.println("entry point " + state);
         pendingStackMap = needStackMap;
@@ -1206,7 +1204,9 @@
     public int entryPoint(State state, Type pushed) {
         int pc = curCP();
         alive = true;
-        this.state = state.dup();
+        State newState = state.dup();
+        setDefined(newState.defined);
+        this.state = newState;
         Assert.check(state.stacksize <= max_stack);
         this.state.push(pushed);
         if (debugCode) System.err.println("entry point " + state);
@@ -2008,27 +2008,6 @@
         state.defined.excl(adr);
     }
 
-
-    public void closeAliveRanges(JCTree tree) {
-        closeAliveRanges(tree, cp);
-    }
-
-    public void closeAliveRanges(JCTree tree, int closingCP) {
-        List<VarSymbol> locals = lvtRanges.getVars(meth, tree);
-        for (LocalVar localVar: lvar) {
-            for (VarSymbol aliveLocal : locals) {
-                if (localVar != null) {
-                    if (localVar.sym == aliveLocal && localVar.lastRange() != null) {
-                        char length = (char)(closingCP - localVar.lastRange().start_pc);
-                        if (length < Character.MAX_VALUE) {
-                            localVar.closeRange(length);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
     void adjustAliveRanges(int oldCP, int delta) {
         for (LocalVar localVar: lvar) {
             if (localVar != null) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -94,10 +94,6 @@
      */
     private Pool pool;
 
-    /** LVTRanges info.
-     */
-    private LVTRanges lvtRanges;
-
     protected Gen(Context context) {
         context.put(genKey, this);
 
@@ -125,9 +121,6 @@
             options.isUnset(G_CUSTOM)
             ? options.isSet(G)
             : options.isSet(G_CUSTOM, "vars");
-        if (varDebugInfo) {
-            lvtRanges = LVTRanges.instance(context);
-        }
         genCrt = options.isSet(XJCOV);
         debugCode = options.isSet("debugcode");
         allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic");
@@ -982,8 +975,7 @@
                                                : null,
                                         syms,
                                         types,
-                                        pool,
-                                        varDebugInfo ? lvtRanges : null);
+                                        pool);
             items = new Items(pool, code, syms, types);
             if (code.debugCode) {
                 System.err.println(meth + " for body " + tree);
@@ -1086,30 +1078,14 @@
                 Chain loopDone = c.jumpFalse();
                 code.resolve(c.trueJumps);
                 genStat(body, loopEnv, CRT_STATEMENT | CRT_FLOW_TARGET);
-                if (varDebugInfo) {
-                    checkLoopLocalVarRangeEnding(loop, body,
-                            LoopLocalVarRangeEndingPoint.BEFORE_STEPS);
-                }
                 code.resolve(loopEnv.info.cont);
                 genStats(step, loopEnv);
-                if (varDebugInfo) {
-                    checkLoopLocalVarRangeEnding(loop, body,
-                            LoopLocalVarRangeEndingPoint.AFTER_STEPS);
-                }
                 code.resolve(code.branch(goto_), startpc);
                 code.resolve(loopDone);
             } else {
                 genStat(body, loopEnv, CRT_STATEMENT | CRT_FLOW_TARGET);
-                if (varDebugInfo) {
-                    checkLoopLocalVarRangeEnding(loop, body,
-                            LoopLocalVarRangeEndingPoint.BEFORE_STEPS);
-                }
                 code.resolve(loopEnv.info.cont);
                 genStats(step, loopEnv);
-                if (varDebugInfo) {
-                    checkLoopLocalVarRangeEnding(loop, body,
-                            LoopLocalVarRangeEndingPoint.AFTER_STEPS);
-                }
                 CondItem c;
                 if (cond != null) {
                     code.statBegin(cond.pos);
@@ -1120,47 +1096,10 @@
                 code.resolve(c.jumpTrue(), startpc);
                 code.resolve(c.falseJumps);
             }
-            code.resolve(loopEnv.info.exit);
-            if (loopEnv.info.exit != null) {
-                loopEnv.info.exit.state.defined.excludeFrom(code.nextreg);
-            }
-        }
-
-        private enum LoopLocalVarRangeEndingPoint {
-            BEFORE_STEPS,
-            AFTER_STEPS,
-        }
-
-        /**
-         *  Checks whether we have reached an alive range ending point for local
-         *  variables after a loop.
-         *
-         *  Local variables alive range ending point for loops varies depending
-         *  on the loop type. The range can be closed before or after the code
-         *  for the steps sentences has been generated.
-         *
-         *  - While loops has no steps so in that case the range is closed just
-         *  after the body of the loop.
-         *
-         *  - For-like loops may have steps so as long as the steps sentences
-         *  can possibly contain non-synthetic local variables, the alive range
-         *  for local variables must be closed after the steps in this case.
-        */
-        private void checkLoopLocalVarRangeEnding(JCTree loop, JCTree body,
-                LoopLocalVarRangeEndingPoint endingPoint) {
-            if (varDebugInfo && lvtRanges.containsKey(code.meth, body)) {
-                switch (endingPoint) {
-                    case BEFORE_STEPS:
-                        if (!loop.hasTag(FORLOOP)) {
-                            code.closeAliveRanges(body);
-                        }
-                        break;
-                    case AFTER_STEPS:
-                        if (loop.hasTag(FORLOOP)) {
-                            code.closeAliveRanges(body);
-                        }
-                        break;
-                }
+            Chain exit = loopEnv.info.exit;
+            if (exit != null) {
+                code.resolve(exit);
+                exit.state.defined.excludeFrom(code.nextreg);
             }
         }
 
@@ -1171,7 +1110,11 @@
     public void visitLabelled(JCLabeledStatement tree) {
         Env<GenContext> localEnv = env.dup(tree, new GenContext());
         genStat(tree.body, localEnv, CRT_STATEMENT);
-        code.resolve(localEnv.info.exit);
+        Chain exit = localEnv.info.exit;
+        if (exit != null) {
+            code.resolve(exit);
+            exit.state.defined.excludeFrom(code.nextreg);
+        }
     }
 
     public void visitSwitch(JCSwitch tree) {
@@ -1277,13 +1220,14 @@
 
                 // Generate code for the statements in this case.
                 genStats(c.stats, switchEnv, CRT_FLOW_TARGET);
-                if (varDebugInfo && lvtRanges.containsKey(code.meth, c.stats.last())) {
-                    code.closeAliveRanges(c.stats.last());
-                }
             }
 
             // Resolve all breaks.
-            code.resolve(switchEnv.info.exit);
+            Chain exit = switchEnv.info.exit;
+            if  (exit != null) {
+                code.resolve(exit);
+                exit.state.defined.excludeFrom(code.nextreg);
+            }
 
             // If we have not set the default offset, we do so now.
             if (code.get4(tableBase) == -1) {
@@ -1436,9 +1380,6 @@
             genFinalizer(env);
             code.statBegin(TreeInfo.endPos(env.tree));
             Chain exitChain = code.branch(goto_);
-            if (varDebugInfo && lvtRanges.containsKey(code.meth, body)) {
-                code.closeAliveRanges(body);
-            }
             endFinalizerGap(env);
             if (startpc != endpc) for (List<JCCatch> l = catchers; l.nonEmpty(); l = l.tail) {
                 // start off with exception on stack
@@ -1689,17 +1630,11 @@
             code.resolve(c.trueJumps);
             genStat(tree.thenpart, env, CRT_STATEMENT | CRT_FLOW_TARGET);
             thenExit = code.branch(goto_);
-            if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.thenpart)) {
-                code.closeAliveRanges(tree.thenpart, code.cp);
-            }
         }
         if (elseChain != null) {
             code.resolve(elseChain);
             if (tree.elsepart != null) {
                 genStat(tree.elsepart, env,CRT_STATEMENT | CRT_FLOW_TARGET);
-                if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.elsepart)) {
-                    code.closeAliveRanges(tree.elsepart);
-                }
             }
         }
         code.resolve(thenExit);
@@ -2381,16 +2316,6 @@
             localEnv.toplevel = env.toplevel;
             localEnv.enclClass = cdef;
 
-            /*  We must not analyze synthetic methods
-             */
-            if (varDebugInfo && (cdef.sym.flags() & SYNTHETIC) == 0) {
-                try {
-                    new LVTAssignAnalyzer().analyzeTree(localEnv);
-                } catch (Throwable e) {
-                    throw e;
-                }
-            }
-
             for (List<JCTree> l = cdef.defs; l.nonEmpty(); l = l.tail) {
                 genDef(l.head, localEnv);
             }
@@ -2476,282 +2401,4 @@
         }
     }
 
-    class LVTAssignAnalyzer
-        extends Flow.AbstractAssignAnalyzer<LVTAssignAnalyzer.LVTAssignPendingExit> {
-
-        final LVTBits lvtInits;
-
-        /*  This class is anchored to a context dependent tree. The tree can
-         *  vary inside the same instruction for example in the switch instruction
-         *  the same FlowBits instance can be anchored to the whole tree, or
-         *  to a given case. The aim is to always anchor the bits to the tree
-         *  capable of closing a DA range.
-         */
-        class LVTBits extends Bits {
-
-            JCTree currentTree;
-            private int[] oldBits = null;
-            BitsState stateBeforeOp;
-
-            @Override
-            public void clear() {
-                generalOp(null, -1, BitsOpKind.CLEAR);
-            }
-
-            @Override
-            protected void internalReset() {
-                super.internalReset();
-                oldBits = null;
-            }
-
-            @Override
-            public Bits assign(Bits someBits) {
-                // bits can be null
-                oldBits = bits;
-                stateBeforeOp = currentState;
-                super.assign(someBits);
-                changed();
-                return this;
-            }
-
-            @Override
-            public void excludeFrom(int start) {
-                generalOp(null, start, BitsOpKind.EXCL_RANGE);
-            }
-
-            @Override
-            public void excl(int x) {
-                Assert.check(x >= 0);
-                generalOp(null, x, BitsOpKind.EXCL_BIT);
-            }
-
-            @Override
-            public Bits andSet(Bits xs) {
-               return generalOp(xs, -1, BitsOpKind.AND_SET);
-            }
-
-            @Override
-            public Bits orSet(Bits xs) {
-                return generalOp(xs, -1, BitsOpKind.OR_SET);
-            }
-
-            @Override
-            public Bits diffSet(Bits xs) {
-                return generalOp(xs, -1, BitsOpKind.DIFF_SET);
-            }
-
-            @Override
-            public Bits xorSet(Bits xs) {
-                return generalOp(xs, -1, BitsOpKind.XOR_SET);
-            }
-
-            private Bits generalOp(Bits xs, int i, BitsOpKind opKind) {
-                Assert.check(currentState != BitsState.UNKNOWN);
-                oldBits = dupBits();
-                stateBeforeOp = currentState;
-                switch (opKind) {
-                    case AND_SET:
-                        super.andSet(xs);
-                        break;
-                    case OR_SET:
-                        super.orSet(xs);
-                        break;
-                    case XOR_SET:
-                        super.xorSet(xs);
-                        break;
-                    case DIFF_SET:
-                        super.diffSet(xs);
-                        break;
-                    case CLEAR:
-                        super.clear();
-                        break;
-                    case EXCL_BIT:
-                        super.excl(i);
-                        break;
-                    case EXCL_RANGE:
-                        super.excludeFrom(i);
-                        break;
-                }
-                changed();
-                return this;
-            }
-
-            /*  The tree we need to anchor the bits instance to.
-             */
-            LVTBits at(JCTree tree) {
-                this.currentTree = tree;
-                return this;
-            }
-
-            /*  If the instance should be changed but the tree is not a closing
-             *  tree then a reset is needed or the former tree can mistakingly be
-             *  used.
-             */
-            LVTBits resetTree() {
-                this.currentTree = null;
-                return this;
-            }
-
-            /** This method will be called after any operation that causes a change to
-             *  the bits. Subclasses can thus override it in order to extract information
-             *  from the changes produced to the bits by the given operation.
-             */
-            public void changed() {
-                if (currentTree != null &&
-                        stateBeforeOp != BitsState.UNKNOWN &&
-                        trackTree(currentTree)) {
-                    List<VarSymbol> locals = lvtRanges
-                            .getVars(currentMethod, currentTree);
-                    locals = locals != null ?
-                            locals : List.<VarSymbol>nil();
-                    for (JCVariableDecl vardecl : vardecls) {
-                        //once the first is null, the rest will be so.
-                        if (vardecl == null) {
-                            break;
-                        }
-                        if (trackVar(vardecl.sym) && bitChanged(vardecl.sym.adr)) {
-                            locals = locals.prepend(vardecl.sym);
-                        }
-                    }
-                    if (!locals.isEmpty()) {
-                        lvtRanges.setEntry(currentMethod,
-                                currentTree, locals);
-                    }
-                }
-            }
-
-            boolean bitChanged(int x) {
-                boolean isMemberOfBits = isMember(x);
-                int[] tmp = bits;
-                bits = oldBits;
-                boolean isMemberOfOldBits = isMember(x);
-                bits = tmp;
-                return (!isMemberOfBits && isMemberOfOldBits);
-            }
-
-            boolean trackVar(VarSymbol var) {
-                return (var.owner.kind == MTH &&
-                        (var.flags() & PARAMETER) == 0 &&
-                        trackable(var));
-            }
-
-            boolean trackTree(JCTree tree) {
-                switch (tree.getTag()) {
-                    // of course a method closes the alive range of a local variable.
-                    case METHODDEF:
-                    // for while loops we want only the body
-                    case WHILELOOP:
-                        return false;
-                }
-                return true;
-            }
-
-        }
-
-        public class LVTAssignPendingExit extends
-                                    Flow.AbstractAssignAnalyzer<LVTAssignPendingExit>.AbstractAssignPendingExit {
-
-            LVTAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) {
-                super(tree, inits, uninits);
-            }
-
-            @Override
-            public void resolveJump(JCTree tree) {
-                lvtInits.at(tree);
-                super.resolveJump(tree);
-            }
-        }
-
-        private LVTAssignAnalyzer() {
-            flow.super();
-            lvtInits = new LVTBits();
-            inits = lvtInits;
-        }
-
-        @Override
-        protected void markDead(JCTree tree) {
-            lvtInits.at(tree).inclRange(returnadr, nextadr);
-            super.markDead(tree);
-        }
-
-        @Override
-        protected void merge(JCTree tree) {
-            lvtInits.at(tree);
-            super.merge(tree);
-        }
-
-        boolean isSyntheticOrMandated(Symbol sym) {
-            return (sym.flags() & (SYNTHETIC | MANDATED)) != 0;
-        }
-
-        @Override
-        protected boolean trackable(VarSymbol sym) {
-            if (isSyntheticOrMandated(sym)) {
-                //fast check to avoid tracking synthetic or mandated variables
-                return false;
-            }
-            return super.trackable(sym);
-        }
-
-        @Override
-        protected void initParam(JCVariableDecl def) {
-            if (!isSyntheticOrMandated(def.sym)) {
-                super.initParam(def);
-            }
-        }
-
-        @Override
-        protected void assignToInits(JCTree tree, Bits bits) {
-            lvtInits.at(tree);
-            lvtInits.assign(bits);
-        }
-
-        @Override
-        protected void andSetInits(JCTree tree, Bits bits) {
-            lvtInits.at(tree);
-            lvtInits.andSet(bits);
-        }
-
-        @Override
-        protected void orSetInits(JCTree tree, Bits bits) {
-            lvtInits.at(tree);
-            lvtInits.orSet(bits);
-        }
-
-        @Override
-        protected void exclVarFromInits(JCTree tree, int adr) {
-            lvtInits.at(tree);
-            lvtInits.excl(adr);
-        }
-
-        @Override
-        protected LVTAssignPendingExit createNewPendingExit(JCTree tree, Bits inits, Bits uninits) {
-            return new LVTAssignPendingExit(tree, inits, uninits);
-        }
-
-        MethodSymbol currentMethod;
-
-        @Override
-        public void visitMethodDef(JCMethodDecl tree) {
-            if ((tree.sym.flags() & (SYNTHETIC | GENERATEDCONSTR)) != 0
-                    && (tree.sym.flags() & LAMBDA_METHOD) == 0) {
-                return;
-            }
-            if (tree.name.equals(names.clinit)) {
-                return;
-            }
-            boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0;
-            if (enumClass &&
-                    (tree.name.equals(names.valueOf) ||
-                    tree.name.equals(names.values) ||
-                    tree.name.equals(names.init))) {
-                return;
-            }
-            currentMethod = tree.sym;
-
-            super.visitMethodDef(tree);
-        }
-
-    }
-
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/LVTRanges.java	Thu Jan 08 12:08:32 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2013, 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.
- */
-
-package com.sun.tools.javac.jvm;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.WeakHashMap;
-
-import com.sun.tools.javac.code.Symbol.MethodSymbol;
-import com.sun.tools.javac.code.Symbol.VarSymbol;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.List;
-
-/** This class contains a one to many relation between a tree and a set of variables.
- *  The relation implies that the given tree closes the DA (definite assignment)
- *  range for the set of variables.
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- */
-public class LVTRanges {
-    /** The context key for the LVT ranges. */
-    protected static final Context.Key<LVTRanges> lvtRangesKey = new Context.Key<>();
-
-    /** Get the LVTRanges instance for this context. */
-    public static LVTRanges instance(Context context) {
-        LVTRanges instance = context.get(lvtRangesKey);
-        if (instance == null) {
-            instance = new LVTRanges(context);
-        }
-        return instance;
-    }
-
-    private static final long serialVersionUID = 1812267524140424433L;
-
-    protected Context context;
-
-    protected Map<MethodSymbol, Map<JCTree, List<VarSymbol>>>
-            aliveRangeClosingTrees = new WeakHashMap<>();
-
-    public LVTRanges(Context context) {
-        this.context = context;
-        context.put(lvtRangesKey, this);
-    }
-
-    public List<VarSymbol> getVars(MethodSymbol method, JCTree tree) {
-        Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method);
-        return (varMap != null) ? varMap.get(tree) : null;
-    }
-
-    public boolean containsKey(MethodSymbol method, JCTree tree) {
-        Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method);
-        if (varMap == null) {
-            return false;
-        }
-        return varMap.containsKey(tree);
-    }
-
-    public void setEntry(MethodSymbol method, JCTree tree, List<VarSymbol> vars) {
-        Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method);
-        if (varMap != null) {
-            varMap.put(tree, vars);
-        } else {
-            varMap = new WeakHashMap<>();
-            varMap.put(tree, vars);
-            aliveRangeClosingTrees.put(method, varMap);
-        }
-    }
-
-    public List<VarSymbol> removeEntry(MethodSymbol method, JCTree tree) {
-        Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method);
-        if (varMap != null) {
-            List<VarSymbol> result = varMap.remove(tree);
-            if (varMap.isEmpty()) {
-                aliveRangeClosingTrees.remove(method);
-            }
-            return result;
-        }
-        return null;
-    }
-
-    /* This method should be used for debugging LVT related issues.
-     */
-    @Override
-    public String toString() {
-        String result = "";
-        for (Entry<MethodSymbol, Map<JCTree, List<VarSymbol>>> mainEntry: aliveRangeClosingTrees.entrySet()) {
-            result += "Method: \n" + mainEntry.getKey().flatName() + "\n";
-            int i = 1;
-            for (Entry<JCTree, List<VarSymbol>> treeEntry: mainEntry.getValue().entrySet()) {
-                result += "    Tree " + i + ": \n" + treeEntry.getKey().toString() + "\n";
-                result += "        Variables closed:\n";
-                for (VarSymbol var: treeEntry.getValue()) {
-                    result += "            " + var.toString();
-                }
-                result += "\n";
-                i++;
-            }
-        }
-        return result;
-    }
-
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,6 @@
+
 #
-# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2015, 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
@@ -26,30 +27,50 @@
 # Messages in this file which use "placeholders" for values (e.g. {0}, {1})
 # are preceded by a stylized comment describing the type of the corresponding
 # values.
-# The types currently in use are
+# The simple types currently in use are:
 #
 # boolean           true or false
-# file name         the name of an input file; e.g.   MyFile.java
-# message segment   a sub-message; see compiler.misc.*
+# diagnostic        a sub-message; see compiler.misc.*
+# fragment          similar to 'message segment', but with more specific type
 # modifier          a Java modifier; e.g. public, private, protected
+# file              a file URL
+# file object       a file URL - similar to 'file' but typically used for source/class files, hence more specific
 # name              a name, typically a Java identifier
 # number            an integer
 # option name       the name of a command line option
 # source version    a source version number, such as 1.5, 1.6, 1.7
 # string            a general string
 # symbol            the name of a declared type
-# symbol kind       a description of the kind of a declaration; see compiler.misc.kindname.*
+# symbol kind       the kind of a symbol (i.e. method, variable)
+# kind name         an informative description of the kind of a declaration; see compiler.misc.kindname.*
 # token             the name of a non-terminal in source code; see compiler.misc.token.*
 # type              a Java type; e.g. int, X, X<T>
+# object            a Java object (unspecified)
 # unused            the value is not used in this message
 #
+# The following compound types are also used:
+#
 # list of X         a comma-separated list of items; e.g. list of type
-# X or Y            alternation; e.g. message segment or type
 # set of X          a comma-separated collection of items; e.g. set of modifier
 #
-# These may be composed: e.g.   list of type or message segment
+# These may be composed:
+#
+# list of type or message segment
+#
+# The following type aliases are supported:
+#
+# message segment --> diagnostic or fragment
+# file name --> file or file object
 #
-# These comments are verified by the jtreg test test/tools/javac/diags/MessageInfo,
+# Custom comments are supported in parenthesis i.e.
+#
+# number (classfile major version)
+#
+# These comments are used internally in order to generate an enum-like class declaration containing
+# a method/field for each of the diagnostic keys listed here. Those methods/fields can then be used
+# by javac code to build diagnostics in a type-safe fashion.
+#
+# In addition, these comments are verified by the jtreg test test/tools/javac/diags/MessageInfo,
 # using info derived from the collected set of examples in test/tools/javac/diags/examples.
 # MessageInfo can also be run as a standalone utility providing more facilities
 # for manipulating this file. For more details, see MessageInfo.java.
@@ -140,7 +161,7 @@
 compiler.err.attribute.value.must.be.constant=\
     element value must be a constant expression
 
-# 0: statement type
+# 0: string (statement type)
 compiler.err.bad.initializer=\
     bad initializer for {0}
 
@@ -360,7 +381,7 @@
 compiler.err.invalid.repeatable.annotation.invalid.value=\
     {0} is not a valid @Repeatable: invalid value element
 
-# 0: symbol type, 1: unused, 2: type
+# 0: symbol or type, 1: unused, 2: type
 compiler.err.invalid.repeatable.annotation.value.return=\
     containing annotation type ({0}) must declare an element named ''value'' of type {2}
 
@@ -832,7 +853,7 @@
 
 # Errors related to annotation processing
 
-# 0: symbol, 1: string, 2: stack-trace
+# 0: symbol, 1: string, 2: string (stack-trace)
 compiler.err.proc.cant.access=\
     cannot access {0}\n\
     {1}\n\
@@ -984,15 +1005,15 @@
 compiler.err.types.incompatible.diff.ret=\
     types {0} and {1} are incompatible; both define {2}, but with unrelated return types
 
-# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
+# 0: kind name, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
 compiler.err.types.incompatible.unrelated.defaults=\
     {0} {1} inherits unrelated defaults for {2}({3}) from types {4} and {5}
 
-# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
+# 0: kind name, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
 compiler.err.types.incompatible.abstract.default=\
     {0} {1} inherits abstract and default for {2}({3}) from types {4} and {5}
 
-# 0: name, 1: kind, 2: symbol
+# 0: name, 1: kind name, 2: symbol
 compiler.err.default.overrides.object.member=\
     default method {0} in {1} {2} overrides a member of java.lang.Object
 
@@ -1747,11 +1768,11 @@
     cannot access {0}\n\
     {1}
 
-# 0: class name
+# 0: name
 compiler.misc.bad.class.file=\
     class file is invalid for class {0}
 
-# 0: file name, 1: expected CP entry type, 2: constant pool index
+# 0: file name, 1: string (expected constant pool entry type), 2: number (constant pool index)
 compiler.misc.bad.const.pool.entry=\
     bad constant pool entry in {0}\n\
     expected {1} at index {2}
@@ -1802,11 +1823,11 @@
 compiler.misc.class.file.not.found=\
     class file for {0} not found
 
-# 0: classfile major version, 1: classfile minor version
+# 0: string (classfile major version), 1: string (classfile minor version)
 compiler.misc.invalid.default.interface=\
     default method found in version {0}.{1} classfile
 
-# 0: classfile major version, 1: classfile minor version
+# 0: string (classfile major version), 1: string (classfile minor version)
 compiler.misc.invalid.static.interface=\
     static method found in version {0}.{1} classfile
 
@@ -2422,7 +2443,7 @@
 compiler.misc.partial.inst.sig=\
     partially instantiated to: {0}
 
-# 0: name, 1: symbol, 2: number, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment
+# 0: name, 1: symbol, 2: number, 3: string (method resolution phase), 4: list of type or message segment, 5: list of type or message segment
 compiler.note.verbose.resolve.multi=\
     resolving method {0} in type {1} to candidate {2}\n\
     phase: {3}\n\
@@ -2430,7 +2451,7 @@
     with type-args: {5}\n\
     candidates:
 
-# 0: name, 1: symbol, 2: unused, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment
+# 0: name, 1: symbol, 2: unused, 3: string (method resolution phase), 4: list of type or message segment, 5: list of type or message segment
 compiler.note.verbose.resolve.multi.1=\
     erroneous resolution for method {0} in type {1}\n\
     phase: {3}\n\
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java	Mon Jan 12 12:23:34 2015 -0800
@@ -329,7 +329,7 @@
 
         DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) {
             this.body = body;
-            this.diag = diags.error(diagSource, this, code, args);
+            this.diag = diags.error(null, diagSource, this, code, args);
         }
 
         @Override @DefinedBy(Api.COMPILER_TREE)
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java	Mon Jan 12 12:23:34 2015 -0800
@@ -31,6 +31,9 @@
 
 import com.sun.tools.javac.code.Lint.LintCategory;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
+import com.sun.tools.javac.util.JCDiagnostic.Error;
+import com.sun.tools.javac.util.JCDiagnostic.Note;
+import com.sun.tools.javac.util.JCDiagnostic.Warning;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
 
@@ -93,7 +96,15 @@
      *  @param args   Fields of the error message.
      */
     public void error(String key, Object ... args) {
-        report(diags.error(source, null, key, args));
+        error(diags.errorKey(key, args));
+    }
+
+    /** Report an error, unless another error was already reported at same
+     *  source position.
+     *  @param errorKey    The key for the localized error message.
+     */
+    public void error(Error errorKey) {
+        report(diags.error(null, source, null, errorKey));
     }
 
     /** Report an error, unless another error was already reported at same
@@ -102,8 +113,17 @@
      *  @param key    The key for the localized error message.
      *  @param args   Fields of the error message.
      */
-    public void error(DiagnosticPosition pos, String key, Object ... args) {
-        report(diags.error(source, pos, key, args));
+    public void error(DiagnosticPosition pos, String key, Object... args) {
+        error(pos, diags.errorKey(key, args));
+    }
+
+    /** Report an error, unless another error was already reported at same
+     *  source position.
+     *  @param pos    The source position at which to report the error.
+     *  @param errorKey    The key for the localized error message.
+     */
+    public void error(DiagnosticPosition pos, Error errorKey) {
+        report(diags.error(null, source, pos, errorKey));
     }
 
     /** Report an error, unless another error was already reported at same
@@ -114,9 +134,17 @@
      *  @param args   Fields of the error message.
      */
     public void error(DiagnosticFlag flag, DiagnosticPosition pos, String key, Object ... args) {
-        JCDiagnostic d = diags.error(source, pos, key, args);
-        d.setFlag(flag);
-        report(d);
+        error(flag, pos, diags.errorKey(key, args));
+    }
+
+    /** Report an error, unless another error was already reported at same
+     *  source position.
+     *  @param flag   A flag to set on the diagnostic
+     *  @param pos    The source position at which to report the error.
+     *  @param errorKey    The key for the localized error message.
+     */
+    public void error(DiagnosticFlag flag, DiagnosticPosition pos, Error errorKey) {
+        report(diags.error(flag, source, pos, errorKey));
     }
 
     /** Report an error, unless another error was already reported at same
@@ -126,7 +154,16 @@
      *  @param args   Fields of the error message.
      */
     public void error(int pos, String key, Object ... args) {
-        report(diags.error(source, wrap(pos), key, args));
+        error(pos, diags.errorKey(key, args));
+    }
+
+    /** Report an error, unless another error was already reported at same
+     *  source position.
+     *  @param pos    The source position at which to report the error.
+     *  @param errorKey    The key for the localized error message.
+     */
+    public void error(int pos, Error errorKey) {
+        report(diags.error(null, source, wrap(pos), errorKey));
     }
 
     /** Report an error, unless another error was already reported at same
@@ -137,9 +174,17 @@
      *  @param args   Fields of the error message.
      */
     public void error(DiagnosticFlag flag, int pos, String key, Object ... args) {
-        JCDiagnostic d = diags.error(source, wrap(pos), key, args);
-        d.setFlag(flag);
-        report(d);
+        error(flag, pos, diags.errorKey(key, args));
+    }
+
+    /** Report an error, unless another error was already reported at same
+     *  source position.
+     *  @param flag   A flag to set on the diagnostic
+     *  @param pos    The source position at which to report the error.
+     *  @param errorKey    The key for the localized error message.
+     */
+    public void error(DiagnosticFlag flag, int pos, Error errorKey) {
+        report(diags.error(flag, source, wrap(pos), errorKey));
     }
 
     /** Report a warning, unless suppressed by the  -nowarn option or the
@@ -148,7 +193,15 @@
      *  @param args   Fields of the warning message.
      */
     public void warning(String key, Object ... args) {
-        report(diags.warning(source, null, key, args));
+        warning(diags.warningKey(key, args));
+    }
+
+    /** Report a warning, unless suppressed by the  -nowarn option or the
+     *  maximum number of warnings has been reached.
+     *  @param warningKey    The key for the localized warning message.
+     */
+    public void warning(Warning warningKey) {
+        report(diags.warning(null, source, null, warningKey));
     }
 
     /** Report a lint warning, unless suppressed by the  -nowarn option or the
@@ -158,7 +211,16 @@
      *  @param args   Fields of the warning message.
      */
     public void warning(LintCategory lc, String key, Object ... args) {
-        report(diags.warning(lc, key, args));
+        warning(lc, diags.warningKey(key, args));
+    }
+
+    /** Report a lint warning, unless suppressed by the  -nowarn option or the
+     *  maximum number of warnings has been reached.
+     *  @param lc     The lint category for the diagnostic
+     *  @param warningKey    The key for the localized warning message.
+     */
+    public void warning(LintCategory lc, Warning warningKey) {
+        report(diags.warning(lc, null, null, warningKey));
     }
 
     /** Report a warning, unless suppressed by the  -nowarn option or the
@@ -168,7 +230,16 @@
      *  @param args   Fields of the warning message.
      */
     public void warning(DiagnosticPosition pos, String key, Object ... args) {
-        report(diags.warning(source, pos, key, args));
+        warning(pos, diags.warningKey(key, args));
+    }
+
+    /** Report a warning, unless suppressed by the  -nowarn option or the
+     *  maximum number of warnings has been reached.
+     *  @param pos    The source position at which to report the warning.
+     *  @param warningKey    The key for the localized warning message.
+     */
+    public void warning(DiagnosticPosition pos, Warning warningKey) {
+        report(diags.warning(null, source, pos, warningKey));
     }
 
     /** Report a lint warning, unless suppressed by the  -nowarn option or the
@@ -179,7 +250,17 @@
      *  @param args   Fields of the warning message.
      */
     public void warning(LintCategory lc, DiagnosticPosition pos, String key, Object ... args) {
-        report(diags.warning(lc, source, pos, key, args));
+        warning(lc, pos, diags.warningKey(key, args));
+    }
+
+    /** Report a lint warning, unless suppressed by the  -nowarn option or the
+     *  maximum number of warnings has been reached.
+     *  @param lc     The lint category for the diagnostic
+     *  @param pos    The source position at which to report the warning.
+     *  @param warningKey    The key for the localized warning message.
+     */
+    public void warning(LintCategory lc, DiagnosticPosition pos, Warning warningKey) {
+        report(diags.warning(lc, source, pos, warningKey));
     }
 
     /** Report a warning, unless suppressed by the  -nowarn option or the
@@ -189,7 +270,16 @@
      *  @param args   Fields of the warning message.
      */
     public void warning(int pos, String key, Object ... args) {
-        report(diags.warning(source, wrap(pos), key, args));
+        warning(pos, diags.warningKey(key, args));
+    }
+
+    /** Report a warning, unless suppressed by the  -nowarn option or the
+     *  maximum number of warnings has been reached.
+     *  @param pos    The source position at which to report the warning.
+     *  @param warningKey    The key for the localized warning message.
+     */
+    public void warning(int pos, Warning warningKey) {
+        report(diags.warning(null, source, wrap(pos), warningKey));
     }
 
     /** Report a warning.
@@ -198,7 +288,15 @@
      *  @param args   Fields of the warning message.
      */
     public void mandatoryWarning(DiagnosticPosition pos, String key, Object ... args) {
-        report(diags.mandatoryWarning(source, pos, key, args));
+        mandatoryWarning(pos, diags.warningKey(key, args));
+    }
+
+    /** Report a warning.
+     *  @param pos    The source position at which to report the warning.
+     *  @param warningKey    The key for the localized warning message.
+     */
+    public void mandatoryWarning(DiagnosticPosition pos, Warning warningKey) {
+        report(diags.mandatoryWarning(null, source, pos, warningKey));
     }
 
     /** Report a warning.
@@ -208,7 +306,16 @@
      *  @param args   Fields of the warning message.
      */
     public void mandatoryWarning(LintCategory lc, DiagnosticPosition pos, String key, Object ... args) {
-        report(diags.mandatoryWarning(lc, source, pos, key, args));
+        mandatoryWarning(lc, pos, diags.warningKey(key, args));
+    }
+
+    /** Report a warning.
+     *  @param lc     The lint category for the diagnostic
+     *  @param pos    The source position at which to report the warning.
+     *  @param warningKey    The key for the localized warning message.
+     */
+    public void mandatoryWarning(LintCategory lc, DiagnosticPosition pos, Warning warningKey) {
+        report(diags.mandatoryWarning(lc, source, pos, warningKey));
     }
 
     /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
@@ -216,7 +323,14 @@
      *  @param args   Fields of the notint an error or warning message:
      */
     public void note(String key, Object ... args) {
-        report(diags.note(source, null, key, args));
+        note(diags.noteKey(key, args));
+    }
+
+    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
+     *  @param noteKey    The key for the localized notification message.
+     */
+    public void note(Note noteKey) {
+        report(diags.note(source, null, noteKey));
     }
 
     /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
@@ -224,7 +338,14 @@
      *  @param args   Fields of the notification message.
      */
     public void note(DiagnosticPosition pos, String key, Object ... args) {
-        report(diags.note(source, pos, key, args));
+        note(pos, diags.noteKey(key, args));
+    }
+
+    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
+     *  @param noteKey    The key for the localized notification message.
+     */
+    public void note(DiagnosticPosition pos, Note noteKey) {
+        report(diags.note(source, pos, noteKey));
     }
 
     /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
@@ -232,7 +353,14 @@
      *  @param args   Fields of the notification message.
      */
     public void note(int pos, String key, Object ... args) {
-        report(diags.note(source, wrap(pos), key, args));
+        note(pos, diags.noteKey(key, args));
+    }
+
+    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
+     *  @param noteKey    The key for the localized notification message.
+     */
+    public void note(int pos, Note noteKey) {
+        report(diags.note(source, wrap(pos), noteKey));
     }
 
     /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
@@ -240,7 +368,14 @@
      *  @param args   Fields of the notification message.
      */
     public void note(JavaFileObject file, String key, Object ... args) {
-        report(diags.note(getSource(file), null, key, args));
+        note(file, diags.noteKey(key, args));
+    }
+
+    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
+     *  @param noteKey    The key for the localized notification message.
+     */
+    public void note(JavaFileObject file, Note noteKey) {
+        report(diags.note(getSource(file), null, noteKey));
     }
 
     /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
@@ -248,7 +383,14 @@
      *  @param args   Fields of the notification message.
      */
     public void mandatoryNote(final JavaFileObject file, String key, Object ... args) {
-        report(diags.mandatoryNote(getSource(file), key, args));
+        mandatoryNote(file, diags.noteKey(key, args));
+    }
+
+    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
+     *  @param noteKey    The key for the localized notification message.
+     */
+    public void mandatoryNote(final JavaFileObject file, Note noteKey) {
+        report(diags.mandatoryNote(getSource(file), noteKey));
     }
 
     protected abstract void report(JCDiagnostic diagnostic);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Mon Jan 12 12:23:34 2015 -0800
@@ -28,6 +28,7 @@
 import java.util.EnumSet;
 import java.util.Locale;
 import java.util.Set;
+import java.util.stream.Stream;
 
 import javax.tools.Diagnostic;
 import javax.tools.JavaFileObject;
@@ -92,28 +93,30 @@
         }
 
         /**
-         * Create an error diagnostic.
+         * Create an error diagnostic
          *  @param source The source of the compilation unit, if any, in which to report the error.
          *  @param pos    The source position at which to report the error.
          *  @param key    The key for the localized error message.
          *  @param args   Fields of the error message.
          */
         public JCDiagnostic error(
-                DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(ERROR, null, defaultErrorFlags, source, pos, key, args);
+                DiagnosticFlag flag, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
+            return error(flag, source, pos, errorKey(key, args));
         }
 
         /**
-         * Create a warning diagnostic that will not be hidden by the -nowarn or -Xlint:none options.
-         *  @param source The source of the compilation unit, if any, in which to report the warning.
-         *  @param pos    The source position at which to report the warning.
-         *  @param key    The key for the localized warning message.
-         *  @param args   Fields of the warning message.
-         *  @see MandatoryWarningHandler
+         * Create an error diagnostic
+         *  @param source The source of the compilation unit, if any, in which to report the error.
+         *  @param pos    The source position at which to report the error.
+         *  @param errorKey    The key for the localized error message.
          */
-        public JCDiagnostic mandatoryWarning(
-                DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(WARNING, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args);
+        public JCDiagnostic error(
+                DiagnosticFlag flag, DiagnosticSource source, DiagnosticPosition pos, Error errorKey) {
+            JCDiagnostic diag = create(null, defaultErrorFlags, source, pos, errorKey);
+            if (flag != null) {
+                diag.setFlag(flag);
+            }
+            return diag;
         }
 
         /**
@@ -128,31 +131,35 @@
         public JCDiagnostic mandatoryWarning(
                 LintCategory lc,
                 DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(WARNING, lc, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args);
+            return mandatoryWarning(lc, source, pos, warningKey(key, args));
+        }
+
+        /**
+         * Create a warning diagnostic that will not be hidden by the -nowarn or -Xlint:none options.
+         *  @param lc     The lint category for the diagnostic
+         *  @param source The source of the compilation unit, if any, in which to report the warning.
+         *  @param pos    The source position at which to report the warning.
+         *  @param warningKey    The key for the localized warning message.
+         *  @see MandatoryWarningHandler
+         */
+        public JCDiagnostic mandatoryWarning(
+                LintCategory lc,
+                DiagnosticSource source, DiagnosticPosition pos, Warning warningKey) {
+            return create(lc, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, warningKey);
         }
 
         /**
          * Create a warning diagnostic.
          *  @param lc     The lint category for the diagnostic
+         *  @param source The source of the compilation unit, if any, in which to report the warning.
+         *  @param pos    The source position at which to report the warning.
          *  @param key    The key for the localized error message.
          *  @param args   Fields of the warning message.
          *  @see MandatoryWarningHandler
          */
         public JCDiagnostic warning(
-                 LintCategory lc, String key, Object... args) {
-            return create(WARNING, lc, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args);
-        }
-
-        /**
-         * Create a warning diagnostic.
-         *  @param source The source of the compilation unit, if any, in which to report the warning.
-         *  @param pos    The source position at which to report the warning.
-         *  @param key    The key for the localized warning message.
-         *  @param args   Fields of the warning message.
-         */
-        public JCDiagnostic warning(
-                DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(WARNING, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
+                LintCategory lc, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
+            return warning(lc, source, pos, warningKey(key, args));
         }
 
         /**
@@ -160,23 +167,32 @@
          *  @param lc     The lint category for the diagnostic
          *  @param source The source of the compilation unit, if any, in which to report the warning.
          *  @param pos    The source position at which to report the warning.
+         *  @param warningKey    The key for the localized warning message.
+         *  @see MandatoryWarningHandler
+         */
+        public JCDiagnostic warning(
+                LintCategory lc, DiagnosticSource source, DiagnosticPosition pos, Warning warningKey) {
+            return create(lc, EnumSet.noneOf(DiagnosticFlag.class), source, pos, warningKey);
+        }
+
+        /**
+         * Create a note diagnostic that will not be hidden by the -nowarn or -Xlint:none options.
+         *  @param source The source of the compilation unit, if any, in which to report the warning.
          *  @param key    The key for the localized warning message.
          *  @param args   Fields of the warning message.
          *  @see MandatoryWarningHandler
          */
-        public JCDiagnostic warning(
-                 LintCategory lc, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(WARNING, lc, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
+        public JCDiagnostic mandatoryNote(DiagnosticSource source, String key, Object... args) {
+            return mandatoryNote(source, noteKey(key, args));
         }
 
         /**
          * Create a note diagnostic that will not be hidden by the -nowarn or -Xlint:none options.
-         *  @param key    The key for the localized message.
-         *  @param args   Fields of the message.
+         *  @param noteKey    The key for the localized note message.
          *  @see MandatoryWarningHandler
          */
-        public JCDiagnostic mandatoryNote(DiagnosticSource source, String key, Object... args) {
-            return create(NOTE, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, null, key, args);
+        public JCDiagnostic mandatoryNote(DiagnosticSource source, Note noteKey) {
+            return create(null, EnumSet.of(DiagnosticFlag.MANDATORY), source, null, noteKey);
         }
 
         /**
@@ -184,20 +200,20 @@
          *  @param key    The key for the localized error message.
          *  @param args   Fields of the message.
          */
-        public JCDiagnostic note(String key, Object... args) {
-            return create(NOTE, null, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args);
+        public JCDiagnostic note(
+                DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
+            return note(source, pos, noteKey(key, args));
         }
 
         /**
          * Create a note diagnostic.
          *  @param source The source of the compilation unit, if any, in which to report the note.
          *  @param pos    The source position at which to report the note.
-         *  @param key    The key for the localized message.
-         *  @param args   Fields of the message.
+         *  @param noteKey    The key for the localized note message.
          */
         public JCDiagnostic note(
-                DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(NOTE, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
+                DiagnosticSource source, DiagnosticPosition pos, Note noteKey) {
+            return create(null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, noteKey);
         }
 
         /**
@@ -206,7 +222,15 @@
          *  @param args   Fields of the message.
          */
         public JCDiagnostic fragment(String key, Object... args) {
-            return create(FRAGMENT, null, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args);
+            return fragment(fragmentKey(key, args));
+        }
+
+        /**
+         * Create a fragment diagnostic, for use as an argument in other diagnostics
+         *  @param fragmentKey    The key for the localized subdiagnostic message.
+         */
+        public JCDiagnostic fragment(Fragment fragmentKey) {
+            return create(null, EnumSet.noneOf(DiagnosticFlag.class), null, null, fragmentKey);
         }
 
         /**
@@ -220,7 +244,19 @@
          */
         public JCDiagnostic create(
                 DiagnosticType kind, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(kind, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
+            return create(null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, DiagnosticInfo.of(kind, prefix, key, args));
+        }
+
+        /**
+         * Create a new diagnostic of the given kind, which is not mandatory and which has
+         * no lint category.
+         *  @param source      The source of the compilation unit, if any, in which to report the message.
+         *  @param pos         The source position at which to report the message.
+         *  @param diagnosticInfo         The key for the localized message.
+         */
+        public JCDiagnostic create(
+                DiagnosticSource source, DiagnosticPosition pos, DiagnosticInfo diagnosticInfo) {
+            return create(null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, diagnosticInfo);
         }
 
         /**
@@ -233,13 +269,59 @@
          *  @param key         The key for the localized message.
          *  @param args        Fields of the message.
          */
-        public JCDiagnostic create(
-                DiagnosticType kind, LintCategory lc, Set<DiagnosticFlag> flags, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return new JCDiagnostic(formatter, kind, lc, flags, source, pos, qualify(kind, key), args);
+        public JCDiagnostic create(DiagnosticType kind,
+                LintCategory lc, Set<DiagnosticFlag> flags, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
+            return create(lc, flags, source, pos, DiagnosticInfo.of(kind, prefix, key, args));
         }
 
-        protected String qualify(DiagnosticType t, String key) {
-            return prefix + "." + t.key + "." + key;
+        /**
+         * Create a new diagnostic with given key.
+         *  @param lc          The lint category, if applicable, or null
+         *  @param flags       The set of flags for the diagnostic
+         *  @param source      The source of the compilation unit, if any, in which to report the message.
+         *  @param pos         The source position at which to report the message.
+         *  @param diagnosticInfo    The key for the localized message.
+         */
+        public JCDiagnostic create(
+                LintCategory lc, Set<DiagnosticFlag> flags, DiagnosticSource source, DiagnosticPosition pos, DiagnosticInfo diagnosticInfo) {
+            return new JCDiagnostic(formatter, normalize(diagnosticInfo), lc, flags, source, pos);
+        }
+        //where
+            DiagnosticInfo normalize(DiagnosticInfo diagnosticInfo) {
+                //replace all nested FragmentKey with full-blown JCDiagnostic objects
+                return DiagnosticInfo.of(diagnosticInfo.type, diagnosticInfo.prefix, diagnosticInfo.code,
+                        Stream.of(diagnosticInfo.args).map(o -> {
+                            return (o instanceof Fragment) ?
+                                    fragment((Fragment)o) : o;
+                        }).toArray());
+            }
+
+        /**
+         * Create a new error key.
+         */
+        Error errorKey(String code, Object... args) {
+            return (Error)DiagnosticInfo.of(ERROR, prefix, code, args);
+        }
+
+        /**
+         * Create a new warning key.
+         */
+        Warning warningKey(String code, Object... args) {
+            return (Warning)DiagnosticInfo.of(WARNING, prefix, code, args);
+        }
+
+        /**
+         * Create a new note key.
+         */
+        Note noteKey(String code, Object... args) {
+            return (Note)DiagnosticInfo.of(NOTE, prefix, code, args);
+        }
+
+        /**
+         * Create a new fragment key.
+         */
+        Fragment fragmentKey(String code, Object... args) {
+            return (Fragment)DiagnosticInfo.of(FRAGMENT, prefix, code, args);
         }
     }
 
@@ -254,13 +336,14 @@
     @Deprecated
     public static JCDiagnostic fragment(String key, Object... args) {
         return new JCDiagnostic(getFragmentFormatter(),
-                              FRAGMENT,
+                              DiagnosticInfo.of(FRAGMENT,
+                                      "compiler",
+                                      key,
+                                      args),
                               null,
                               EnumSet.noneOf(DiagnosticFlag.class),
                               null,
-                              null,
-                              "compiler." + FRAGMENT.key + "." + key,
-                              args);
+                              null);
     }
     //where
     @Deprecated
@@ -352,11 +435,9 @@
         COMPRESSED
     }
 
-    private final DiagnosticType type;
     private final DiagnosticSource source;
     private final DiagnosticPosition position;
-    private final String key;
-    protected final Object[] args;
+    private final DiagnosticInfo diagnosticInfo;
     private final Set<DiagnosticFlag> flags;
     private final LintCategory lintCategory;
 
@@ -391,34 +472,120 @@
     }
 
     /**
+     * A diagnostic key object encapsulates basic properties of a diagnostic, such as the resource key,
+     * the arguments and the kind associated with the diagnostic object. Diagnostic keys can be either
+     * created programmatically (by using the supplied factory method) or obtained through build-time
+     * generated factory methods.
+     */
+    public static abstract class DiagnosticInfo {
+
+        /** The diagnostic kind (i.e. error). */
+        DiagnosticType type;
+
+        /** The diagnostic prefix (i.e. 'javac'); used to compute full resource key. */
+        String prefix;
+
+        /** The diagnostic code (i.e. 'cannot.resolve.sym'); together with {@code prefix} it forms
+         * the full resource key. */
+        String code;
+
+        /** The diagnostic arguments. */
+        Object[] args;
+
+        private DiagnosticInfo(DiagnosticType type, String prefix, String code, Object... args) {
+            this.type = type;
+            this.prefix = prefix;
+            this.code = code;
+            this.args = args;
+        }
+
+        /**
+         * Compute the resource key.
+         */
+        public String key() {
+            return prefix + "." + type.key + "." + code;
+        }
+
+        /**
+         * Static factory method; build a custom diagnostic key using given kind, prefix, code and args.
+         */
+        public static DiagnosticInfo of(DiagnosticType type, String prefix, String code, Object... args) {
+            switch (type) {
+                case ERROR:
+                    return new Error(prefix, code, args);
+                case WARNING:
+                    return new Warning(prefix, code, args);
+                case NOTE:
+                    return new Note(prefix, code, args);
+                case FRAGMENT:
+                    return new Fragment(prefix, code, args);
+                default:
+                    Assert.error("Wrong diagnostic type: " + type);
+                    return null;
+            }
+        }
+
+    }
+
+    /**
+     * Class representing error diagnostic keys.
+     */
+    public static final class Error extends DiagnosticInfo {
+        public Error(String prefix, String key, Object... args) {
+            super(DiagnosticType.ERROR, prefix, key, args);
+        }
+    }
+
+    /**
+     * Class representing warning diagnostic keys.
+     */
+    public static final class Warning extends DiagnosticInfo {
+        public Warning(String prefix, String key, Object... args) {
+            super(DiagnosticType.WARNING, prefix, key, args);
+        }
+    }
+
+    /**
+     * Class representing note diagnostic keys.
+     */
+    public static final class Note extends DiagnosticInfo {
+        public Note(String prefix, String key, Object... args) {
+            super(DiagnosticType.NOTE, prefix, key, args);
+        }
+    }
+
+    /**
+     * Class representing fragment diagnostic keys.
+     */
+    public static final class Fragment extends DiagnosticInfo {
+        public Fragment(String prefix, String key, Object... args) {
+            super(DiagnosticType.FRAGMENT, prefix, key, args);
+        }
+    }
+
+    /**
      * Create a diagnostic object.
      * @param formatter the formatter to use for the diagnostic
-     * @param dt the type of diagnostic
+     * @param diagnosticInfo the diagnostic key
      * @param lc     the lint category for the diagnostic
      * @param source the name of the source file, or null if none.
      * @param pos the character offset within the source file, if given.
-     * @param key a resource key to identify the text of the diagnostic
-     * @param args arguments to be included in the text of the diagnostic
      */
     protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter,
-                       DiagnosticType dt,
+                       DiagnosticInfo diagnosticInfo,
                        LintCategory lc,
                        Set<DiagnosticFlag> flags,
                        DiagnosticSource source,
-                       DiagnosticPosition pos,
-                       String key,
-                       Object... args) {
+                       DiagnosticPosition pos) {
         if (source == null && pos != null && pos.getPreferredPosition() != Position.NOPOS)
             throw new IllegalArgumentException();
 
         this.defaultFormatter = formatter;
-        this.type = dt;
+        this.diagnosticInfo = diagnosticInfo;
         this.lintCategory = lc;
         this.flags = flags;
         this.source = source;
         this.position = pos;
-        this.key = key;
-        this.args = args;
     }
 
     /**
@@ -426,7 +593,7 @@
      * @return the type of this diagnostic
      */
     public DiagnosticType getType() {
-        return type;
+        return diagnosticInfo.type;
     }
 
     /**
@@ -543,7 +710,7 @@
      * @return  the arguments to be included in the text of the diagnostic
      */
     public Object[] getArgs() {
-        return args;
+        return diagnosticInfo.args;
     }
 
     /**
@@ -551,7 +718,7 @@
      * @return the prefix string associated with this type of diagnostic
      */
     public String getPrefix() {
-        return getPrefix(type);
+        return getPrefix(diagnosticInfo.type);
     }
 
     /**
@@ -567,7 +734,7 @@
      */
     @Override
     public String toString() {
-        return defaultFormatter.format(this,Locale.getDefault());
+        return defaultFormatter.format(this, Locale.getDefault());
     }
 
     private DiagnosticFormatter<JCDiagnostic> defaultFormatter;
@@ -578,7 +745,7 @@
 
     @DefinedBy(Api.COMPILER)
     public Diagnostic.Kind getKind() {
-        switch (type) {
+        switch (diagnosticInfo.type) {
         case NOTE:
             return Diagnostic.Kind.NOTE;
         case WARNING:
@@ -594,7 +761,7 @@
 
     @DefinedBy(Api.COMPILER)
     public String getCode() {
-        return key;
+        return diagnosticInfo.key();
     }
 
     @DefinedBy(Api.COMPILER)
@@ -605,7 +772,7 @@
     public void setFlag(DiagnosticFlag flag) {
         flags.add(flag);
 
-        if (type == DiagnosticType.ERROR) {
+        if (diagnosticInfo.type == DiagnosticType.ERROR) {
             switch (flag) {
                 case SYNTAX:
                     flags.remove(DiagnosticFlag.RECOVERABLE);
@@ -627,13 +794,11 @@
 
         public MultilineDiagnostic(JCDiagnostic other, List<JCDiagnostic> subdiagnostics) {
             super(other.defaultFormatter,
-                  other.getType(),
+                  other.diagnosticInfo,
                   other.getLintCategory(),
                   other.flags,
                   other.getDiagnosticSource(),
-                  other.position,
-                  other.getCode(),
-                  other.getArgs());
+                  other.position);
             this.subdiagnostics = subdiagnostics;
         }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java	Mon Jan 12 12:23:34 2015 -0800
@@ -535,7 +535,7 @@
      *  @param args   Fields of the warning message.
      */
     public void strictWarning(DiagnosticPosition pos, String key, Object ... args) {
-        writeDiagnostic(diags.warning(source, pos, key, args));
+        writeDiagnostic(diags.warning(null, source, pos, key, args));
         nwarnings++;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/BranchToFewerDefines.java	Mon Jan 12 12:23:34 2015 -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.
+ *
+ * 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 8067429
+ * @summary java.lang.VerifyError: Inconsistent stackmap frames at branch target
+ * @author srikanth
+ *
+ * @compile  BranchToFewerDefines.java
+ * @run main BranchToFewerDefines
+ */
+
+public class BranchToFewerDefines {
+        public static void main(String[] args) {
+        }
+        private void problematicMethod(int p) {
+                switch (p) {
+                        case 3:
+                                long n;
+                                while (true) {
+                                        if (false) {
+                                                break;
+                                        }
+                                }
+                                break;
+                        case 2:
+                                loop: while (true) {
+                                        while (true) {
+                                                int i = 4;
+                                                if (p != 16) {
+                                                        return;
+                                                }
+                                                break loop;
+                                        }
+                                }
+                                break;
+                        default:
+                                while (true) {
+                                        if (false) {
+                                                break;
+                                        }
+                                }
+                                break;
+                }
+                long b;
+                if (p != 7) {
+                        switch (p) {
+                                case 1:
+                                        long a = 17;
+                                        break;
+                                case 2:
+                                        break;
+                                default:
+                                        break;
+                        }
+                }
+        }
+        private void problematicMethod2(int p) {
+                switch (p) {
+                        case 3:
+                                long n;
+                                {
+                                        int i = 4;
+                                        break;
+                                }
+                        case 2:
+                                {
+                                        int i = 4;
+                                        break;
+                                }
+                        default:
+                                {
+                                        int i = 4;
+                                        break;
+                                }
+                }
+                long b;
+                if (p != 7) {
+                        switch (p) {
+                                case 1:
+                                        long a = 17;
+                                        break;
+                                case 2:
+                                        break;
+                                default:
+                                        break;
+                        }
+                }
+        }
+}
--- a/langtools/test/tools/javac/ConstFoldTest.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/ConstFoldTest.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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
@@ -31,6 +31,8 @@
  */
 
 import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.List;
 
 public class ConstFoldTest {
@@ -75,9 +77,10 @@
         ToolBox tb = new ToolBox();
 
         URL url = ConstFoldTest.class.getResource("ConstFoldTest$CFTest.class");
+        Path file = Paths.get(url.toURI());
         List<String> result = tb.new JavapTask()
                 .options("-c")
-                .classes(url.getFile())
+                .classes(file.toString())
                 .run()
                 .write(ToolBox.OutputKind.DIRECT)
                 .getOutputLines(ToolBox.OutputKind.DIRECT);
--- a/langtools/test/tools/javac/Diagnostics/6769027/T6769027.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/Diagnostics/6769027/T6769027.java	Mon Jan 12 12:23:34 2015 -0800
@@ -387,7 +387,7 @@
         messages.add("tester");
         JCDiagnostic.Factory diags = JCDiagnostic.Factory.instance(ctx);
         log.useSource(new MyFileObject("This is a source line"));
-        JCDiagnostic d = diags.error(log.currentSource(),
+        JCDiagnostic d = diags.error(null, log.currentSource(),
             posKind.pos(),
             errorKind.key(), "Hello!");
         if (multiKind != MultilineKind.NONE) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/Diagnostics/compressed/8067883/T8067883.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8067883
+ * @summary Javac misses some opportunities for diagnostic simplification
+ *
+ * @compile/fail/ref=T8067883a.out -Xdiags:compact -XDrawDiagnostics T8067883.java
+ * @compile/fail/ref=T8067883b.out -Xdiags:verbose -XDrawDiagnostics T8067883.java
+ *
+ */
+
+import java.util.List;
+
+class T8067883 {
+    void testMethod(List<Integer> li) {
+        m(null, li);
+        m(1, li);
+    }
+
+    void testDiamond(List<Integer> li) {
+        new Box<>(null, li);
+        new Box<>(1, li);
+    }
+
+    <Z> void m(List<Z> z, List<String> ls) { }
+
+    static class Box<X> {
+        Box(List<X> z, List<String> ls) { }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/Diagnostics/compressed/8067883/T8067883a.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,6 @@
+T8067883.java:15:17: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.util.List<java.lang.Integer>, java.util.List<java.lang.String>)
+T8067883.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<Z>,java.util.List<java.lang.String>, int,java.util.List<java.lang.Integer>, kindname.class, T8067883, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: int, java.util.List<Z>))
+T8067883.java:20:25: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.util.List<java.lang.Integer>, java.util.List<java.lang.String>)
+T8067883.java:21:9: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: T8067883.Box), (compiler.misc.infer.no.conforming.assignment.exists: X, (compiler.misc.inconvertible.types: int, java.util.List<X>))
+- compiler.note.compressed.diags
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/Diagnostics/compressed/8067883/T8067883b.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,5 @@
+T8067883.java:15:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<Z>,java.util.List<java.lang.String>, compiler.misc.type.null,java.util.List<java.lang.Integer>, kindname.class, T8067883, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.util.List<java.lang.Integer>, java.util.List<java.lang.String>))
+T8067883.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<Z>,java.util.List<java.lang.String>, int,java.util.List<java.lang.Integer>, kindname.class, T8067883, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: int, java.util.List<Z>))
+T8067883.java:20:9: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: T8067883.Box), (compiler.misc.infer.no.conforming.assignment.exists: X, (compiler.misc.inconvertible.types: java.util.List<java.lang.Integer>, java.util.List<java.lang.String>))
+T8067883.java:21:9: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: T8067883.Box), (compiler.misc.infer.no.conforming.assignment.exists: X, (compiler.misc.inconvertible.types: int, java.util.List<X>))
+4 errors
--- a/langtools/test/tools/javac/SerialWarn.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/SerialWarn.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,34 +1,11 @@
 /*
- * Copyright (c) 2003, 2004, 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
+ * @test /nodynamiccopyright/
  * @bug 4854628
  * @summary include Throwable subclasses in missing serialVersionUID warning
  * @author gafter
  *
  * @compile                    -Werror SerialWarn.java
- * @compile/fail -Xlint:serial -Werror SerialWarn.java
+ * @compile/fail/ref=SerialWarn.out -XDrawDiagnostics -Xlint:serial -Werror SerialWarn.java
  */
 
 class SerialWarn extends Throwable {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/SerialWarn.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,4 @@
+SerialWarn.java:11:1: compiler.warn.missing.SVUID: SerialWarn
+- compiler.err.warnings.and.werror
+1 error
+1 warning
--- a/langtools/test/tools/javac/T4994049/DeprecatedYES.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/T4994049/DeprecatedYES.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,33 +1,10 @@
 /*
- * Copyright (c) 2005, 2006, 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
+ * @test    /nodynamiccopyright/
  * @bug     6229758
  * @summary deprecatedNOT! is
  * @author  Peter von der Ah\u00e9
  * @compile -Xlint:deprecation DeprecatedYES.java
- * @compile/fail -Werror -Xlint:deprecation DeprecatedYES.java
+ * @compile/fail/ref=DeprecatedYES.out -XDrawDiagnostics -Werror -Xlint:deprecation DeprecatedYES.java
  */
 
 class A {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T4994049/DeprecatedYES.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,4 @@
+DeprecatedYES.java:18:10: compiler.warn.has.been.deprecated: foo(), A
+- compiler.err.warnings.and.werror
+1 error
+1 warning
--- a/langtools/test/tools/javac/T6231847.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/T6231847.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,9 +1,8 @@
 /*
- * @test  /nodynamiccopyright/
+ * @test    /nodynamiccopyright/
  * @bug     6231847
  * @summary Crash in com.sun.tools.javac.comp.Attr.visitNewClass:1352
  * @author  Peter von der Ah\u00e9
- * @compile/fail -XDdev T6231847.java
  * @compile/fail/ref=T6231847.out -XDdev -XDrawDiagnostics T6231847.java
  */
 
--- a/langtools/test/tools/javac/T6231847.out	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/T6231847.out	Mon Jan 12 12:23:34 2015 -0800
@@ -1,9 +1,9 @@
-T6231847.java:15:21: compiler.err.anon.class.impl.intf.no.typeargs
-T6231847.java:16:30: compiler.err.anon.class.impl.intf.no.args
+T6231847.java:14:21: compiler.err.anon.class.impl.intf.no.typeargs
+T6231847.java:15:30: compiler.err.anon.class.impl.intf.no.args
+T6231847.java:16:16: compiler.err.anon.class.impl.intf.no.qual.for.new
 T6231847.java:17:16: compiler.err.anon.class.impl.intf.no.qual.for.new
-T6231847.java:18:16: compiler.err.anon.class.impl.intf.no.qual.for.new
-T6231847.java:18:41: compiler.err.anon.class.impl.intf.no.args
-T6231847.java:18:23: compiler.err.anon.class.impl.intf.no.typeargs
-T6231847.java:19:16: compiler.err.qualified.new.of.static.class: T6231847.T6231847C
-T6231847.java:19:34: compiler.err.illegal.qual.not.icls: T6231847.T6231847C
+T6231847.java:17:41: compiler.err.anon.class.impl.intf.no.args
+T6231847.java:17:23: compiler.err.anon.class.impl.intf.no.typeargs
+T6231847.java:18:16: compiler.err.qualified.new.of.static.class: T6231847.T6231847C
+T6231847.java:18:34: compiler.err.illegal.qual.not.icls: T6231847.T6231847C
 8 errors
--- a/langtools/test/tools/javac/annotations/6214965/T6214965.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/annotations/6214965/T6214965.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, 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,9 +23,10 @@
 
 /**
  * @test
- * @bug     6214965 6365854
+ * @bug     6214965 6365854 8068639
  * @summary Compiler crash on redefing nested annotation types
  * @compile CompilerAnnotationTest.java CompilerAnnotationTest2.java
  * @compile CompilerAnnotationTest2bad.java
- * @compile/ref=T6214965.out -XDrawDiagnostics CompilerAnnotationTest2bad.java
+ * @compile/ref=T6214965.out -XDrawDiagnostics -Xlint:classfile CompilerAnnotationTest2bad.java
+ * @compile -Werror CompilerAnnotationTest2bad.java
  */
--- a/langtools/test/tools/javac/annotations/6365854/T6365854.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/annotations/6365854/T6365854.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, 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     6365854
+ * @bug     6365854 8068639
  * @summary javac crashes when compiling against an annotated class
  * @compile TestAnnotation.java TestCore.java
  * @clean test.annotation.TestAnnotation
@@ -33,11 +33,11 @@
  *
  * @compile TestAnnotation.java TestCore.java
  * @clean test.annotation.TestAnnotation
- * @compile/ref=test1.out -XDrawDiagnostics T6365854.java
+ * @compile/ref=test1.out -XDrawDiagnostics -Xlint:classfile T6365854.java
  * @run main T6365854
- * @compile/ref=test2.out -XDrawDiagnostics evolve/TestAnnotation.java T6365854.java
+ * @compile/ref=test2.out -XDrawDiagnostics -Xlint:classfile evolve/TestAnnotation.java T6365854.java
  * @run main T6365854
- * @compile/ref=test2.out -XDrawDiagnostics T6365854.java
+ * @compile/ref=test2.out -XDrawDiagnostics -Xlint:classfile T6365854.java
  * @run main T6365854
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/file/MyStandardJavaFileManager.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2014, 2015, 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import javax.tools.ForwardingJavaFileManager;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+
+class MyStandardJavaFileManager
+        extends ForwardingJavaFileManager<StandardJavaFileManager>
+        implements StandardJavaFileManager {
+    MyStandardJavaFileManager(StandardJavaFileManager delegate) {
+        super(delegate);
+    }
+
+    @Override
+    public Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles(Iterable<? extends File> files) {
+        return fileManager.getJavaFileObjectsFromFiles(files);
+    }
+
+    @Override
+    public Iterable<? extends JavaFileObject> getJavaFileObjects(File... files) {
+        return fileManager.getJavaFileObjects(files);
+    }
+
+    @Override
+    public Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings(Iterable<String> names) {
+        return fileManager.getJavaFileObjectsFromStrings(names);
+    }
+
+    @Override
+    public Iterable<? extends JavaFileObject> getJavaFileObjects(String... names) {
+        return fileManager.getJavaFileObjects(names);
+    }
+
+    @Override
+    public void setLocation(JavaFileManager.Location location, Iterable<? extends File> files) throws IOException {
+        fileManager.setLocation(location, files);
+    }
+
+    @Override
+    public Iterable<? extends File> getLocation(JavaFileManager.Location location) {
+        return fileManager.getLocation(location);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/file/SJFM_AsPath.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2014, 2015, 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 8059977
+ * @summary StandardJavaFileManager should support java.nio.file.Path.
+ *          Test asPath method.
+ * @build SJFM_TestBase
+ * @run main SJFM_AsPath
+ */
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+/**
+ * For those paths which are supported by a file manager, such that
+ * a file object can encapsulate the path, verify that the underlying
+ * path can be recovered from the file object.
+ */
+public class SJFM_AsPath extends SJFM_TestBase {
+    public static void main(String... args) throws Exception {
+        new SJFM_AsPath().run();
+    }
+
+    @Test
+    void test_asPath(StandardJavaFileManager fm) throws IOException {
+        test_asPath(fm, getTestFilePaths());
+        test_asPath(fm, getTestZipPaths());
+    }
+
+    /**
+     * Tests the asPath method for a specific file manager and a series
+     * of paths.
+     *
+     * Note: instances of MyStandardJavaFileManager only support
+     * encapsulating paths for files in the default file system,
+     * and throw UnsupportedOperationException for asPath.
+     *
+     * @param fm  the file manager to be tested
+     * @param paths  the paths to be tested
+     * @throws IOException
+     */
+    void test_asPath(StandardJavaFileManager fm, List<Path> paths) throws IOException {
+        if (!isGetFileObjectsSupported(fm, paths))
+            return;
+        boolean expectException = (fm instanceof MyStandardJavaFileManager);
+
+        Set<Path> ref = new HashSet<>(paths);
+        for (JavaFileObject fo : fm.getJavaFileObjectsFromPaths(paths)) {
+            try {
+                Path path = fm.asPath(fo);
+                if (expectException)
+                    error("expected exception not thrown: " + UnsupportedOperationException.class.getName());
+                boolean found = ref.remove(path);
+                if (!found) {
+                    error("Unexpected path found: " + path + "; expected one of " + ref);
+                }
+            } catch (Exception e) {
+                if (expectException && e instanceof UnsupportedOperationException)
+                    continue;
+                error("unexpected exception thrown: " + e);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/file/SJFM_GetFileObjects.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2014, 2015, 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 8059977
+ * @summary StandardJavaFileManager should support java.nio.file.Path.
+ *          Test getFileObject methods.
+ * @build SJFM_TestBase
+ * @run main SJFM_GetFileObjects
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Collections;
+import java.util.List;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
+/**
+ * For those paths supported by a file manager, verify that the paths
+ * can be encapsulated by file objects, such that the file objects can
+ * be used by a tool such as javac.
+ */
+public class SJFM_GetFileObjects extends SJFM_TestBase {
+    public static void main(String... args) throws Exception {
+        new SJFM_GetFileObjects().run();
+    }
+
+    @Test
+    void test_getJavaFileObjects(StandardJavaFileManager fm) throws IOException {
+        test_getJavaFileObjects(fm, getTestFilePaths());
+        test_getJavaFileObjects(fm, getTestZipPaths());
+    }
+
+    /**
+     * Tests the getJavaFileObjects method for a specific file manager
+     * and a series of paths.
+     *
+     * Note: instances of MyStandardJavaFileManager only support
+     * encapsulating paths for files in the default file system.
+     *
+     * @param fm  the file manager to be tested
+     * @param paths  the paths to be tested
+     * @throws IOException
+     */
+    void test_getJavaFileObjects(StandardJavaFileManager fm, List<Path> paths) throws IOException {
+        boolean expectException = !isGetFileObjectsSupported(fm, paths);
+        try {
+            compile(fm.getJavaFileObjects(paths.toArray(new Path[paths.size()])));
+            if (expectException)
+                error("expected exception not thrown");
+        } catch (RuntimeException e) {
+            if (expectException && e instanceof IllegalArgumentException)
+                return;
+            error("unexpected exception thrown: " + e);
+        }
+    }
+
+    //----------------------------------------------------------------------------------------------
+
+    @Test
+    void test_getJavaFileObjectsFromPaths(StandardJavaFileManager fm) throws IOException {
+        test_getJavaFileObjectsFromPaths(fm, getTestFilePaths());
+        test_getJavaFileObjectsFromPaths(fm, getTestZipPaths());
+    }
+
+    /**
+     * Tests the getJavaFileObjectsFromPaths method for a specific file manager
+     * and a series of paths.
+     *
+     * Note: instances of MyStandardJavaFileManager only support
+     * encapsulating paths for files in the default file system.
+     *
+     * @param fm  the file manager to be tested
+     * @param paths  the paths to be tested
+     * @throws IOException
+     */
+    void test_getJavaFileObjectsFromPaths(StandardJavaFileManager fm, List<Path> paths)
+            throws IOException {
+        boolean expectException = !isGetFileObjectsSupported(fm, paths);
+        try {
+            compile(fm.getJavaFileObjectsFromPaths(paths));
+            if (expectException)
+                error("expected exception not thrown: " + IllegalArgumentException.class.getName());
+        } catch (RuntimeException e) {
+            if (expectException && e instanceof IllegalArgumentException)
+                return;
+            error("unexpected exception thrown: " + e);
+        }
+    }
+
+
+    //----------------------------------------------------------------------------------------------
+
+    /**
+     * Compiles a set of files.
+     *
+     * @param files the files to be compiled.
+     * @throws IOException
+     */
+    void compile(Iterable<? extends JavaFileObject> files) throws IOException {
+        String name = "compile" + (compileCount++);
+        try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
+            File f = new File(name);
+            f.mkdirs();
+            // use setLocation(Iterable<File>) to avoid relying on setLocationFromPaths
+            fm.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(f));
+            boolean ok = comp.getTask(null, fm, null, null, null, files).call();
+            if (!ok)
+                error(name + ": compilation failed");
+        }
+    }
+
+    int compileCount;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/file/SJFM_IsSameFile.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014, 2015, 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 8059977
+ * @summary StandardJavaFileManager should support java.nio.file.Path.
+ *          Test isSameFile method.
+ * @build SJFM_TestBase
+ * @run main SJFM_IsSameFile
+ */
+
+import java.nio.file.Path;
+import java.util.List;
+import java.util.concurrent.Callable;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+/**
+ * For those paths which are supported by a file manager, such that
+ * a file object can encapsulate the path, verify that the underlying
+ * paths can be compared.
+ */
+public class SJFM_IsSameFile extends SJFM_TestBase {
+    public static void main(String... args) throws Exception {
+        new SJFM_IsSameFile().run();
+    }
+
+    @Test
+    void test_isSameFile(StandardJavaFileManager fm) throws Exception {
+        test_isSameFile(fm, () -> getTestFilePaths());
+        test_isSameFile(fm, () -> getTestZipPaths());
+    }
+
+    /**
+     * Tests the isSameFile method for a specific file manager
+     * and a series of paths.
+     *
+     * Note: instances of MyStandardJavaFileManager only support
+     * encapsulating paths for files in the default file system.
+     *
+     * @param fm  the file manager to be tested
+     * @param paths  a generator for the paths to be tested
+     * @throws IOException
+     */
+    void test_isSameFile(StandardJavaFileManager fm, Callable<List<Path>> paths) throws Exception {
+        if (!isGetFileObjectsSupported(fm, paths.call()))
+            return;
+
+        // use distinct paths and file objects in the following two sets
+        Iterable<? extends JavaFileObject> setA = fm.getJavaFileObjectsFromPaths(paths.call());
+        Iterable<? extends JavaFileObject> setB = fm.getJavaFileObjectsFromPaths(paths.call());
+        for (JavaFileObject a : setA) {
+            for (JavaFileObject b : setB) {
+                System.err.println("compare: a: " + a);
+                System.err.println("         b: " + b);
+                // Use the fileObject getName method to determine the expected result.
+                // For the files being tested, getName is the absolute path.
+                boolean expect = a.getName().equals(b.getName());
+                boolean actual = fm.isSameFile(a, b);
+                if (actual != expect) {
+                    error("mismatch: actual:" + (actual ? "same" : "not same")
+                            + ", expect:" + (expect ? "same" : "not same"));
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/file/SJFM_Locations.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2014, 2015, 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 8059977
+ * @summary StandardJavaFileManager should support java.nio.file.Path.
+ *          Test get/setLocation methods.
+ * @build SJFM_TestBase
+ * @run main SJFM_Locations
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.tools.JavaFileManager;
+import javax.tools.StandardJavaFileManager;
+
+/**
+ * For those paths which are supported by a file manager, verify
+ * that setLocation can accept such paths, and that getLocation
+ * can subsequently return the same paths.
+ *
+ * In addition, for files in the default file system, verify
+ * the combinations of setting a location using files or paths
+ * and then subsequently getting the location as files or paths.
+ */
+public class SJFM_Locations extends SJFM_TestBase {
+    public static void main(String... args) throws Exception {
+        new SJFM_Locations().run();
+    }
+
+    @Test
+    void test_locations(StandardJavaFileManager fm) throws IOException {
+        test_setFiles_getFiles(fm, getTestFileDirs());
+        test_setFiles_getPaths(fm, getTestFileDirs());
+        test_setPaths_getFiles(fm, getTestFilePathDirs());
+        test_setPaths_getPaths(fm, getTestFilePathDirs());
+//        test_setPaths_getPaths(fm, getTestZipPathDirs());
+    }
+
+    void test_setFiles_getFiles(StandardJavaFileManager fm, List<File> inFiles) throws IOException {
+        System.err.println("test_setFiles_getFiles");
+        JavaFileManager.Location l = newLocation();
+        fm.setLocation(l, inFiles);
+        Iterable<? extends File> outFiles = fm.getLocation(l);
+        compare(inFiles, outFiles);
+    }
+
+    void test_setFiles_getPaths(StandardJavaFileManager fm, List<File> inFiles) throws IOException {
+        System.err.println("test_setFiles_getPaths");
+        JavaFileManager.Location l = newLocation();
+        fm.setLocation(l, inFiles);
+        Iterable<? extends Path> outPaths = fm.getLocationAsPaths(l);
+        compare(inFiles, outPaths);
+    }
+
+    void test_setPaths_getFiles(StandardJavaFileManager fm, List<Path> inPaths) throws IOException {
+        System.err.println("test_setPaths_getFiles");
+        JavaFileManager.Location l = newLocation();
+        fm.setLocationFromPaths(l, inPaths);
+        Iterable<? extends File> outFiles = fm.getLocation(l);
+        compare(inPaths, outFiles);
+    }
+
+    void test_setPaths_getPaths(StandardJavaFileManager fm, List<Path> inPaths) throws IOException {
+        System.err.println("test_setPaths_getPaths");
+        JavaFileManager.Location l = newLocation();
+        fm.setLocationFromPaths(l, inPaths);
+        Iterable<? extends Path> outPaths = fm.getLocationAsPaths(l);
+        compare(inPaths, outPaths);
+    }
+
+    //----------------------------------------------------------------------------------------------
+
+    /**
+     * Gets a representative series of directories in the default file system,
+     * derived from the test.src directory and test.classes path.
+     *
+     * @return a list of directories, represented with {@code File}
+     * @throws IOException
+     */
+    List<File> getTestFileDirs() throws IOException {
+        return Stream.of("test.src", "test.classes")
+                .map(s -> System.getProperty(s))
+                .flatMap(s -> Stream.of(s.split(File.pathSeparator, 0)))
+                .filter(s -> !s.isEmpty())
+                .map(s -> new File(s))
+                .collect(Collectors.toList());
+    }
+
+    /**
+     * Gets a representative series of directories in the default file system,
+     * derived from the test.src directory and test.classes path.
+     *
+     * @return a list of directories, represented with {@code Path}
+     * @throws IOException
+     */
+    List<Path> getTestFilePathDirs() throws IOException {
+        return Stream.of("test.src", "test.classes")
+                .map(s -> System.getProperty(s))
+                .flatMap(s -> Stream.of(s.split(File.pathSeparator, 0)))
+                .filter(s -> !s.isEmpty())
+                .map(s -> Paths.get(s))
+                .collect(Collectors.toList());
+    }
+
+
+    /**
+     * Compares two lists of items by comparing their individual string representations.
+     *
+     * @param in   the first set of items to be compared
+     * @param out  the second set of items to be compared
+     */
+    void compare(Iterable<?> in, Iterable<?> out) {
+        List<String> ins = toString(in);
+        List<String> outs = toString(out);
+        if (!ins.equals(outs)) {
+            error("mismatch in comparison");
+            System.err.println("in:");
+            for (String s: ins) System.err.println(s);
+            System.err.println("out:");
+            for (String s: outs) System.err.println(s);
+        }
+    }
+
+    List<String> toString(Iterable<?> iter) {
+        List<String> strings = new ArrayList<>();
+        for (Object item: iter)
+            strings.add(item.toString());
+        return strings;
+    }
+
+    /**
+     * Create an instance of a location.
+     * @return a location
+     */
+    JavaFileManager.Location newLocation() {
+        final String name = "locn" + (count++);
+        return new JavaFileManager.Location() {
+            @Override
+            public String getName() {
+                return name;
+            }
+
+            @Override
+            public boolean isOutputLocation() {
+                return false;
+            }
+        };
+    }
+
+    int count = 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/file/SJFM_TestBase.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2014, 2015, 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.
+ */
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UncheckedIOException;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import javax.tools.JavaCompiler;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Base class for unit tests for StandardJavaFileManager.
+ */
+class SJFM_TestBase {
+
+    /** Shared compiler instance. */
+    JavaCompiler comp;
+
+    /** A list of items to be closed when the test is complete. */
+    List<AutoCloseable> closeables;
+
+    /**
+     * Runs a test. This is the primary entry point and should generally be
+     * called from each test's main method.
+     * It calls all methods annotated with {@code @Test} with the instances
+     * of StandardJavaFileManager to be tested.
+     *
+     * @throws Exception if the test fails.
+     */
+    void run() throws Exception {
+        comp = ToolProvider.getSystemJavaCompiler();
+        closeables = new ArrayList<>();
+
+        try (StandardJavaFileManager systemFileManager = comp.getStandardFileManager(null, null, null);
+                StandardJavaFileManager customFileManager = new MyStandardJavaFileManager(systemFileManager)) {
+            test(systemFileManager);
+            test(customFileManager);
+        } finally {
+            for (AutoCloseable c: closeables) {
+                try {
+                    c.close();
+                } catch (IOException e) {
+                    error("Exception closing " + c + ": " + e);
+                }
+            }
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    /**
+     * Get the file managers to be tested.
+     *
+     * Currently, two are provided:
+     * <ol>
+     * <li>the system-provided file manager
+     * <li>a custom file manager, which relies on the default methods provided in the
+     *     StandardJavaFileManager interface
+     * </li>
+     *
+     * @return the file managers to be tested
+     */
+    List<StandardJavaFileManager> getTestFileManagers() {
+        StandardJavaFileManager systemFileManager = comp.getStandardFileManager(null, null, null);
+        StandardJavaFileManager customFileManager = new MyStandardJavaFileManager(systemFileManager);
+        return Arrays.asList(systemFileManager, customFileManager);
+    }
+
+    /**
+     * Tests a specific file manager, by calling all methods annotated
+     * with {@code @Test} passing this file manager as an argument.
+     *
+     * @param fm the file manager to be tested
+     * @throws Exception if the test fails
+     */
+    void test(StandardJavaFileManager fm) throws Exception {
+        System.err.println("Testing " + fm);
+        for (Method m: getClass().getDeclaredMethods()) {
+            Annotation a = m.getAnnotation(Test.class);
+            if (a != null) {
+                try {
+                    System.err.println("Test " + m.getName());
+                    m.invoke(this, new Object[] { fm });
+                } catch (InvocationTargetException e) {
+                    Throwable cause = e.getCause();
+                    throw (cause instanceof Exception) ? ((Exception) cause) : e;
+                }
+                System.err.println();
+            }
+        }
+    }
+
+    /** Marker annotation for test cases. */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Test { }
+
+    /**
+     * Returns a series of paths for artifacts in the default file system.
+     * The paths are for the .java files in the test.src directory.
+     *
+     * @return a list of paths
+     * @throws IOException
+     */
+    List<Path> getTestFilePaths() throws IOException {
+        String testSrc = System.getProperty("test.src");
+        return Files.list(Paths.get(testSrc))
+                .filter(p -> p.getFileName().toString().endsWith(".java"))
+                .collect(Collectors.toList());
+    }
+
+    private FileSystem zipfs;
+    private List<Path> zipPaths;
+
+    /**
+     * Returns a series of paths for artifacts in a non-default file system.
+     * A zip file is created containing copies of the .java files in the
+     * test.src directory. The paths that are returned refer to these files.
+     *
+     * @return a list of paths
+     * @throws IOException
+     */
+    List<Path> getTestZipPaths() throws IOException {
+        if (zipfs == null) {
+            Path testZip = createSourceZip();
+            zipfs = FileSystems.newFileSystem(testZip, null);
+            closeables.add(zipfs);
+            zipPaths = Files.list(zipfs.getRootDirectories().iterator().next())
+                .filter(p -> p.getFileName().toString().endsWith(".java"))
+                .collect(Collectors.toList());
+        }
+        return zipPaths;
+    }
+
+    /**
+     * Create a zip file containing the contents of the test.src directory.
+     *
+     * @return a path for the zip file.
+     * @throws IOException if there is a problem creating the file
+     */
+    private Path createSourceZip() throws IOException {
+        Path testSrc = Paths.get(System.getProperty("test.src"));
+        Path testZip = Paths.get("test.zip");
+        try (OutputStream os = Files.newOutputStream(testZip)) {
+            try (ZipOutputStream zos = new ZipOutputStream(os)) {
+                Files.list(testSrc)
+                    .filter(p -> p.getFileName().toString().endsWith(".java"))
+                    .forEach(p -> {
+                        try {
+                            zos.putNextEntry(new ZipEntry(p.getFileName().toString()));
+                            zos.write(Files.readAllBytes(p));
+                            zos.closeEntry();
+                        } catch (IOException ex) {
+                            throw new UncheckedIOException(ex);
+                        }
+                    });
+            }
+        }
+        return testZip;
+    }
+
+    /**
+     * Tests whether it is expected that a file manager will be able
+     * to create a series of file objects from a series of paths.
+     *
+     * MyStandardJavaFileManager does not support paths referring to
+     * non-default file systems.
+     *
+     * @param fm  the file manager to be tested
+     * @param paths  the paths to be tested
+     * @return
+     */
+    boolean isGetFileObjectsSupported(StandardJavaFileManager fm, List<Path> paths) {
+        return !(fm instanceof MyStandardJavaFileManager
+                && (paths.get(0).getFileSystem() != FileSystems.getDefault()));
+    }
+
+    /**
+     * Report an error.
+     */
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    /** Count of errors reported. */
+    int errors;
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/conditional/ConditionalWithFinalStrings.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015, 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 8066871
+ * @summary java.lang.VerifyError: Bad local variable type - local final String
+ * @author Srikanth Sankaran
+ *
+ * @compile -g:none ConditionalWithFinalStrings.java
+ * @run main ConditionalWithFinalStrings
+ */
+
+public class ConditionalWithFinalStrings {
+
+        interface I {
+            String foo();
+        }
+
+        static class Tmp {
+                private String value;
+                public void setValue(String tmpStr) {
+                        this.value = tmpStr;
+                        if (!this.value.equals("YES"))
+                            throw new AssertionError();
+                }
+        }
+
+        void goo(I i) {
+            if (!i.foo().equals("YES"))
+                throw new AssertionError();
+        }
+
+        public void test() {
+                final String y = "YES";
+                final String n = "NO";
+                Tmp tmp = new Tmp();
+                tmp.setValue(true ? y : n);
+                goo (() -> y);
+
+        }
+        public static void main(String[] args) {
+                new ConditionalWithFinalStrings().test();
+                if (!id("Hello!").equals("Hello!"))
+                    throw new AssertionError();
+
+        }
+        static <Z> Z id(Z z) { return z; }
+}
--- a/langtools/test/tools/javac/diags/MessageFile.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/diags/MessageFile.java	Mon Jan 12 12:23:34 2015 -0800
@@ -31,7 +31,9 @@
  */
 class MessageFile {
     static final Pattern emptyOrCommentPattern = Pattern.compile("( *#.*)?");
-    static final Pattern infoPattern = Pattern.compile("# ([0-9]+: [-A-Za-z ]+, )*[0-9]+: [-A-Za-z ]+");
+    static final Pattern typePattern = Pattern.compile("[-\\\\'A-Z\\.a-z ]+( \\([A-Za-z 0-9]+\\))?");
+    static final Pattern infoPattern = Pattern.compile(String.format("# ([0-9]+: %s, )*[0-9]+: %s",
+            typePattern.pattern(), typePattern.pattern()));
 
     /**
      * A line of text within the message file.
--- a/langtools/test/tools/javac/flow/LVTHarness.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/flow/LVTHarness.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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 7047734 8027660 8037937 8047719 8058708
+ * @bug 7047734 8027660 8037937 8047719 8058708 8064857
  * @summary The LVT is not generated correctly during some try/catch scenarios
  *          javac crash while creating LVT entry for a local variable defined in
  *          an inner block
@@ -147,7 +147,7 @@
     }
 
     void checkMethod(ConstantPool constantPool, Method method, AliveRanges ranges)
-            throws InvalidIndex, UnexpectedEntry {
+            throws InvalidIndex, UnexpectedEntry, ConstantPoolException {
         Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code);
         LocalVariableTable_attribute lvt =
             (LocalVariableTable_attribute) (code.attributes.get(Attribute.LocalVariableTable));
@@ -169,7 +169,7 @@
         }
 
         if (i < infoFromRanges.size()) {
-            error(infoFromLVT, infoFromRanges);
+            error(infoFromLVT, infoFromRanges, method.getName(constantPool).toString());
         }
     }
 
@@ -205,9 +205,10 @@
         return sb.toString();
     }
 
-    protected void error(List<String> infoFromLVT, List<String> infoFromRanges) {
+    protected void error(List<String> infoFromLVT, List<String> infoFromRanges, String methodName) {
         nerrors++;
         System.err.printf("Error occurred while checking file: %s\n", jfo.getName());
+        System.err.printf("at method: %s\n", methodName);
         System.err.println("The range info from the annotations is");
         printStringListToErrOutput(infoFromRanges);
         System.err.println();
--- a/langtools/test/tools/javac/flow/tests/TestCaseFor.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/flow/tests/TestCaseFor.java	Mon Jan 12 12:23:34 2015 -0800
@@ -2,7 +2,7 @@
 
 public class TestCaseFor {
 
-    @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8)
+    @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=11)
     @AliveRange(varName="o", bytecodeStart=24, bytecodeLength=1)
     void m1(String[] args) {
         Object o;
@@ -13,7 +13,7 @@
         o = "";
     }
 
-    @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8)
+    @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=11)
     @AliveRange(varName="o", bytecodeStart=24, bytecodeLength=1)
     void m2(String[] args) {
         Object o;
--- a/langtools/test/tools/javac/flow/tests/TestCaseForEach.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/flow/tests/TestCaseForEach.java	Mon Jan 12 12:23:34 2015 -0800
@@ -2,7 +2,7 @@
 
 public class TestCaseForEach {
 
-    @AliveRange(varName="o", bytecodeStart=25, bytecodeLength=8)
+    @AliveRange(varName="o", bytecodeStart=25, bytecodeLength=11)
     @AliveRange(varName="o", bytecodeStart=39, bytecodeLength=1)
     void m(String[] args) {
         Object o;
--- a/langtools/test/tools/javac/flow/tests/TestCaseIfElse.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/flow/tests/TestCaseIfElse.java	Mon Jan 12 12:23:34 2015 -0800
@@ -60,4 +60,19 @@
         }
         return null;
     }
+
+    @AliveRange(varName="i", bytecodeStart=6, bytecodeLength=2)
+    int m4(boolean flag) {
+        int i;
+        label:
+        {
+            if (flag) {
+                i = 1;
+            } else {
+                break label;
+            }
+            return i;
+        }
+        return -1;
+    }
 }
--- a/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java	Mon Jan 12 12:23:34 2015 -0800
@@ -81,4 +81,26 @@
         o = "finish";
     }
 
+    @AliveRange(varName="oCache", bytecodeStart=30, bytecodeLength=6)
+    @AliveRange(varName="cache", bytecodeStart=41, bytecodeLength=3)
+    @AliveRange(varName="cache", bytecodeStart=54, bytecodeLength=2)
+    @AliveRange(varName="service", bytecodeStart=39, bytecodeLength=5)
+    Object m4(int i) {
+        Object cache;
+        switch (i) {
+            case 0:
+                Object oCache = null;
+                if (oCache != null) {
+                    return oCache;
+                }
+            case 1:
+                Object service = null;
+                cache = null;
+                break;
+            default:
+                throw new AssertionError("");
+            }
+        return cache;
+    }
+
 }
--- a/langtools/test/tools/javac/flow/tests/TestCaseTry.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/flow/tests/TestCaseTry.java	Mon Jan 12 12:23:34 2015 -0800
@@ -17,7 +17,8 @@
     }
 
     @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16)
-    @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=23)
+    @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=8)
+    @AliveRange(varName="o", bytecodeStart=35, bytecodeLength=11)
     void m1() {
         Object o;
         try {
@@ -33,7 +34,8 @@
     }
 
     @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16)
-    @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=31)
+    @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=16)
+    @AliveRange(varName="o", bytecodeStart=43, bytecodeLength=11)
     void m2() {
         Object o;
         try {
@@ -51,7 +53,8 @@
     }
 
     @AliveRange(varName="o", bytecodeStart=22, bytecodeLength=38)
-    @AliveRange(varName="o", bytecodeStart=103, bytecodeLength=8)
+    @AliveRange(varName="o", bytecodeStart=103, bytecodeLength=3)
+    @AliveRange(varName="o", bytecodeStart=110, bytecodeLength=1)
     void m3() {
         Object o;
         try (BufferedReader br =
--- a/langtools/test/tools/javac/flow/tests/TestCaseWhile.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/flow/tests/TestCaseWhile.java	Mon Jan 12 12:23:34 2015 -0800
@@ -2,7 +2,7 @@
 
 public class TestCaseWhile {
 
-    @AliveRange(varName="o", bytecodeStart=9, bytecodeLength=5)
+    @AliveRange(varName="o", bytecodeStart=9, bytecodeLength=8)
     @AliveRange(varName="o", bytecodeStart=20, bytecodeLength=1)
     void m(String[] args) {
         Object o;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/MissingCast2.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,55 @@
+/*
+ * 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 8043741
+ * @summary VerifyError due to missing checkcast
+ * @author srikanth
+ *
+ * @compile  MissingCast2.java
+ * @run main MissingCast2
+ */
+
+import java.util.*;
+
+public class MissingCast2 {
+  public static void main(String[] args) {
+          new E();
+  }
+}
+
+class S<T> {
+    T t;
+}
+
+class C {
+    class I { };
+}
+
+class E extends S<C> {
+    {
+        t = new C();
+        t.new I() { };
+    }
+};
--- a/langtools/test/tools/javac/overrridecrash/B.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/overrridecrash/B.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,33 +1,10 @@
 /*
- * Copyright (c) 2003, 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
+ * @test /nodynamiccopyright/
  * @bug 4909690
  * @summary AssertionError(com.sun.tools.javac.v8.code.Symbol$MethodSymbol.isOverridableIn)
  * @author gafter
  *
- * @compile/fail B.java
+ * @compile/fail/ref=B.out -XDrawDiagnostics B.java
  */
 
 public class B extends A
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/overrridecrash/B.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,3 @@
+B.java:12:27: compiler.err.illegal.combination.of.modifiers: private, protected
+A.java:25:27: compiler.err.illegal.combination.of.modifiers: private, protected
+2 errors
--- a/langtools/test/tools/javac/processing/6365040/T6365040.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/processing/6365040/T6365040.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,28 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, 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
+ * @test /nodynamiccopyright/
  * @bug 6365040 6358129
  * @summary Test -processor foo,bar,baz
  * @author  Joseph D. Darcy
@@ -34,8 +11,8 @@
  * @compile      -processor ProcFoo,ProcBar,T6365040  -proc:only T6365040.java
  * @compile      -processor T6365040                  -proc:only T6365040.java
  * @compile      -processor T6365040,NotThere,        -proc:only T6365040.java
- * @compile/fail -processor NotThere                  -proc:only T6365040.java
- * @compile/fail -processor NotThere,T6365040         -proc:only T6365040.java
+ * @compile/fail/ref=T6365040.out -XDrawDiagnostics -processor NotThere -proc:only T6365040.java
+ * @compile/fail/ref=T6365040.out -XDrawDiagnostics -processor NotThere,T6365040 -proc:only T6365040.java
  */
 
 import java.util.Set;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/6365040/T6365040.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,4 @@
+- compiler.err.proc.processor.not.found: NotThere
+- compiler.warn.proc.proc-only.requested.no.procs
+1 error
+1 warning
--- a/langtools/test/tools/javac/processing/6511613/clss41701.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/processing/6511613/clss41701.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,35 +1,11 @@
 /*
- * Copyright (c) 2010, 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
+ * @test /nodynamiccopyright/
  * @bug 6511613
  * @summary javac unexpectedly doesn't fail in some cases if an annotation processor specified
- *
  * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor DummyProcessor
- * @compile/fail clss41701.java
- * @compile/fail -processor DummyProcessor clss41701.java
+ * @compile/fail/ref=clss41701.out -XDrawDiagnostics clss41701.java
+ * @compile/fail/ref=clss41701.out -XDrawDiagnostics -processor DummyProcessor clss41701.java
  */
 
 import java.io.PrintStream;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/6511613/clss41701.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,2 @@
+clss41701.java:19:30: compiler.err.type.var.may.not.be.followed.by.other.bounds
+1 error
--- a/langtools/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,28 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, 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
+ * @test /nodynamiccopyright/
  * @bug 6403459
  * @summary Test that generating programs with syntax errors is a fatal condition
  * @author  Joseph D. Darcy
@@ -30,7 +7,7 @@
  * @build JavacTestingAbstractProcessor
  * @compile TestReturnCode.java
  * @compile TestFatalityOfParseErrors.java
- * @compile/fail -XprintRounds -processor TestFatalityOfParseErrors -proc:only TestFatalityOfParseErrors.java
+ * @compile/fail/ref=TestFatalityOfParseErrors.out -XDrawDiagnostics -XprintRounds -processor TestFatalityOfParseErrors -proc:only TestFatalityOfParseErrors.java
  */
 
 import java.util.Set;
@@ -49,41 +26,12 @@
  * is marked as an error.
  */
 public class TestFatalityOfParseErrors extends JavacTestingAbstractProcessor {
-    int round = 0;
 
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
-        try {
-            PrintWriter pw = null;
-            round++;
-
-            switch (round) {
-            case 1:
-                pw = new PrintWriter(filer.createSourceFile("SyntaxError").openWriter());
-                pw.println("class SyntaxError {");
-                pw.close();
-                break;
-
-            case 2:
-                pw = new PrintWriter(filer.createSourceFile("SimpleClass").openWriter());
-                pw.println("class SimpleClass {}");
-                pw.close();
-
-                if (!roundEnvironment.errorRaised() || !roundEnvironment.processingOver() ) {
-                    System.err.println(roundEnvironment);
-                    throw new RuntimeException("Second round not erroneous as expected.");
-                }
-                if (!roundEnvironment.getRootElements().isEmpty()) {
-                    System.err.println(roundEnvironment);
-                    throw new RuntimeException("Root elements not empty as expected.");
-                }
-                break;
-
-            default:
-                throw new RuntimeException("Unexpected round number " + round);
-            }
+        try (PrintWriter pw = new PrintWriter(filer.createSourceFile("SyntaxError").openWriter())) {
+            pw.println("class SyntaxError {");
         } catch (IOException ioException) {
-            throw new RuntimeException(ioException);
         }
         return true;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/errors/TestFatalityOfParseErrors.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,10 @@
+Round 1:
+	input files: {TestFatalityOfParseErrors}
+	annotations: []
+	last round: false
+Round 2:
+	input files: {}
+	annotations: []
+	last round: true
+SyntaxError.java:1:20: compiler.err.premature.eof
+1 error
--- a/langtools/test/tools/javac/processing/messager/MessagerBasics.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/processing/messager/MessagerBasics.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,28 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
+ * @test    /nodynamiccopyright/
  * @bug     6341173 6341072
  * @summary Test presence of Messager methods
  * @author  Joseph D. Darcy
@@ -30,9 +7,9 @@
  * @build   JavacTestingAbstractProcessor
  * @compile MessagerBasics.java
  * @compile -processor MessagerBasics -proc:only MessagerBasics.java
- * @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java
+ * @compile/fail/ref=MessagerBasics.out -XDrawDiagnostics -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java
  * @compile -processor MessagerBasics MessagerBasics.java
- * @compile/fail -processor MessagerBasics -AfinalError MessagerBasics.java
+ * @compile/fail/ref=MessagerBasics.out -XDrawDiagnostics -processor MessagerBasics -AfinalError MessagerBasics.java
  */
 
 import java.util.Set;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/messager/MessagerBasics.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,2 @@
+- compiler.err.proc.messager: Does not compute
+1 error
--- a/langtools/test/tools/javac/staticQualifiedNew/StaticQualifiedNew.java	Thu Jan 08 12:08:32 2015 -0800
+++ b/langtools/test/tools/javac/staticQualifiedNew/StaticQualifiedNew.java	Mon Jan 12 12:23:34 2015 -0800
@@ -1,33 +1,9 @@
 /*
- * Copyright (c) 2000, 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
+ * @test /nodynamiccopyright/
  * @bug 4295650
  * @summary Verify that qualified 'new' of static class is forbidden.
  * @author maddox (after gbracha)
- *
- * @compile/fail StaticQualifiedNew.java
+ * @compile/fail/ref=StaticQualifiedNew.out -XDrawDiagnostics StaticQualifiedNew.java
  */
 
 import p2.X;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/staticQualifiedNew/StaticQualifiedNew.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,2 @@
+StaticQualifiedNew.java:13:11: compiler.err.qualified.new.of.static.class: p2.X.M
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/tree/8067914/E.out	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,16 @@
+
+class E extends S {
+    
+    E() {
+        super();
+    }
+    {
+        t = new C();
+        new I(<*nullchk*>((C)t)){
+            
+            (.C x0) {
+                x0.super();
+            }
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/tree/8067914/NukeExtraCast.java	Mon Jan 12 12:23:34 2015 -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.
+ *
+ * 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 8067914
+ * @summary Redunant type cast nodes in AST (follow up from JDK-8043741)
+ * @library /tools/lib
+ * @build ToolBox
+ * @run compile -XD-printsource T8067914.java
+ * @run main NukeExtraCast
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+public class NukeExtraCast {
+
+    public static void main(String[] args) throws Exception {
+        ToolBox tb = new ToolBox();
+        Path path1 = Paths.get(ToolBox.testClasses, "E.java");
+        List<String> file1 = tb.readAllLines(path1);
+
+        Path path2 = Paths.get(ToolBox.testSrc, "E.out");
+        List<String> file2 = tb.readAllLines(path2);
+        tb.checkEqual(file1, file2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/tree/8067914/T8067914.java	Mon Jan 12 12:23:34 2015 -0800
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+class S<T> { T t; }
+class C { class I { }; }
+class E extends S<C> {{
+  t = new C();
+  ((C) t).new I() { };
+}};
+class X {
+  public static void main(String[] args) { new E(); }
+}
+