8196403: remove the remaining use of string keys for errors and warnings in the compiler
authorvromero
Fri, 02 Feb 2018 07:43:54 -0500
changeset 48721 ef3557eb4306
parent 48720 290b480df13e
child 48722 02b7ea53c1a4
child 48735 7c63eefd620a
8196403: remove the remaining use of string keys for errors and warnings in the compiler Reviewed-by: mcimadamore, jlahoda
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java
src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ParserFactory.java
src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java
src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java
src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java
src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java
src/jdk.compiler/share/classes/module-info.java
src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java
src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java
test/langtools/tools/javac/6304921/TestLog.java
test/langtools/tools/javac/diags/examples/WithExpected/module-info.java
test/langtools/tools/javac/modules/ProvidesTest.java
test/langtools/tools/javac/parser/extend/JavacExtensionTest.java
test/langtools/tools/javac/parser/extend/TrialParser.java
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Feb 02 07:43:54 2018 -0500
@@ -59,7 +59,9 @@
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.JCDiagnostic.Error;
 import com.sun.tools.javac.util.JCDiagnostic.Fragment;
+import com.sun.tools.javac.util.JCDiagnostic.Warning;
 import com.sun.tools.javac.util.List;
 
 import static com.sun.tools.javac.code.Flags.*;
@@ -1417,7 +1419,7 @@
                         if (!pattype.hasTag(ERROR)) {
                             if (pattype.constValue() == null) {
                                 log.error(c.pat.pos(),
-                                          (stringSwitch ? "string.const.req" : "const.expr.req"));
+                                          (stringSwitch ? Errors.StringConstReq : Errors.ConstExprReq));
                             } else if (!labels.add(pattype.constValue())) {
                                 log.error(c.pos(), Errors.DuplicateCaseLabel);
                             }
@@ -3675,8 +3677,7 @@
                    sym.name != names._class) {
             // If the qualified item is not a type and the selected item is static, report
             // a warning. Make allowance for the class of an array type e.g. Object[].class)
-            chk.warnStatic(tree, "static.not.qualified.by.type",
-                           sym.kind.kindName(), sym.owner);
+            chk.warnStatic(tree, Warnings.StaticNotQualifiedByType(sym.kind.kindName(), sym.owner));
         }
 
         // If we are selecting an instance member via a `super', ...
@@ -3925,9 +3926,7 @@
                     if (s != null &&
                         s.isRaw() &&
                         !types.isSameType(v.type, v.erasure(types))) {
-                        chk.warnUnchecked(tree.pos(),
-                                          "unchecked.assign.to.var",
-                                          v, s);
+                        chk.warnUnchecked(tree.pos(), Warnings.UncheckedAssignToVar(v, s));
                     }
                 }
                 // The computed type of a variable is the type of the
@@ -4002,12 +4001,14 @@
                 ((v.flags() & STATIC) != 0) == Resolve.isStatic(env) &&
                 (!env.tree.hasTag(ASSIGN) ||
                  TreeInfo.skipParens(((JCAssign) env.tree).lhs) != tree)) {
-                String suffix = (initEnv.info.enclVar == v) ?
-                                "self.ref" : "forward.ref";
                 if (!onlyWarning || isStaticEnumField(v)) {
-                    log.error(tree.pos(), "illegal." + suffix);
+                    Error errkey = (initEnv.info.enclVar == v) ?
+                                Errors.IllegalSelfRef : Errors.IllegalForwardRef;
+                    log.error(tree.pos(), errkey);
                 } else if (useBeforeDeclarationWarning) {
-                    log.warning(tree.pos(), suffix, v);
+                    Warning warnkey = (initEnv.info.enclVar == v) ?
+                                Warnings.SelfRef(v) : Warnings.ForwardRef(v);
+                    log.warning(tree.pos(), warnkey);
                 }
             }
 
@@ -4117,9 +4118,7 @@
             if (s != null && s.isRaw() &&
                 !types.isSameTypes(sym.type.getParameterTypes(),
                                    sym.erasure(types).getParameterTypes())) {
-                chk.warnUnchecked(env.tree.pos(),
-                                  "unchecked.call.mbr.of.raw.type",
-                                  sym, s);
+                chk.warnUnchecked(env.tree.pos(), Warnings.UncheckedCallMbrOfRawType(sym, s));
             }
         }
 
@@ -4169,14 +4168,12 @@
             argtypes = argtypes.map(checkDeferredMap);
 
             if (noteWarner.hasNonSilentLint(LintCategory.UNCHECKED)) {
-                chk.warnUnchecked(env.tree.pos(),
-                        "unchecked.meth.invocation.applied",
-                        kindName(sym),
+                chk.warnUnchecked(env.tree.pos(), Warnings.UncheckedMethInvocationApplied(kindName(sym),
                         sym.name,
                         rs.methodArguments(sym.type.getParameterTypes()),
                         rs.methodArguments(argtypes.map(checkDeferredMap)),
                         kindName(sym.location()),
-                        sym.location());
+                        sym.location()));
                 if (resultInfo.pt != Infer.anyPoly ||
                         !owntype.hasTag(METHOD) ||
                         !owntype.isPartial()) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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
@@ -43,7 +43,9 @@
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.JCDiagnostic.Error;
 import com.sun.tools.javac.util.JCDiagnostic.Fragment;
+import com.sun.tools.javac.util.JCDiagnostic.Warning;
 import com.sun.tools.javac.util.List;
 
 import com.sun.tools.javac.code.Lint;
@@ -205,16 +207,16 @@
         if (sym.isDeprecatedForRemoval()) {
             if (!lint.isSuppressed(LintCategory.REMOVAL)) {
                 if (sym.kind == MDL) {
-                    removalHandler.report(pos, "has.been.deprecated.for.removal.module", sym);
+                    removalHandler.report(pos, Warnings.HasBeenDeprecatedForRemovalModule(sym));
                 } else {
-                    removalHandler.report(pos, "has.been.deprecated.for.removal", sym, sym.location());
+                    removalHandler.report(pos, Warnings.HasBeenDeprecatedForRemoval(sym, sym.location()));
                 }
             }
         } else if (!lint.isSuppressed(LintCategory.DEPRECATION)) {
             if (sym.kind == MDL) {
-                deprecationHandler.report(pos, "has.been.deprecated.module", sym);
+                deprecationHandler.report(pos, Warnings.HasBeenDeprecatedModule(sym));
             } else {
-                deprecationHandler.report(pos, "has.been.deprecated", sym, sym.location());
+                deprecationHandler.report(pos, Warnings.HasBeenDeprecated(sym, sym.location()));
             }
         }
     }
@@ -223,22 +225,22 @@
      *  @param pos        Position to be used for error reporting.
      *  @param msg        A string describing the problem.
      */
-    public void warnUnchecked(DiagnosticPosition pos, String msg, Object... args) {
+    public void warnUnchecked(DiagnosticPosition pos, Warning warnKey) {
         if (!lint.isSuppressed(LintCategory.UNCHECKED))
-            uncheckedHandler.report(pos, msg, args);
+            uncheckedHandler.report(pos, warnKey);
     }
 
     /** Warn about unsafe vararg method decl.
      *  @param pos        Position to be used for error reporting.
      */
-    void warnUnsafeVararg(DiagnosticPosition pos, String key, Object... args) {
+    void warnUnsafeVararg(DiagnosticPosition pos, Warning warnKey) {
         if (lint.isEnabled(LintCategory.VARARGS) && Feature.SIMPLIFIED_VARARGS.allowedInSource(source))
-            log.warning(LintCategory.VARARGS, pos, key, args);
+            log.warning(LintCategory.VARARGS, pos, warnKey);
     }
 
-    public void warnStatic(DiagnosticPosition pos, String msg, Object... args) {
+    public void warnStatic(DiagnosticPosition pos, Warning warnKey) {
         if (lint.isEnabled(LintCategory.STATIC))
-            log.warning(LintCategory.STATIC, pos, msg, args);
+            log.warning(LintCategory.STATIC, pos, warnKey);
     }
 
     /** Warn about division by integer constant zero.
@@ -903,14 +905,13 @@
             }
         } else if (hasTrustMeAnno && varargElemType != null &&
                             types.isReifiable(varargElemType)) {
-            warnUnsafeVararg(tree,
-                            "varargs.redundant.trustme.anno",
-                            syms.trustMeType.tsym,
-                            diags.fragment(Fragments.VarargsTrustmeOnReifiableVarargs(varargElemType)));
+            warnUnsafeVararg(tree, Warnings.VarargsRedundantTrustmeAnno(
+                                syms.trustMeType.tsym,
+                                diags.fragment(Fragments.VarargsTrustmeOnReifiableVarargs(varargElemType))));
         }
         else if (!hasTrustMeAnno && varargElemType != null &&
                 !types.isReifiable(varargElemType)) {
-            warnUnchecked(tree.params.head.pos(), "unchecked.varargs.non.reifiable.type", varargElemType);
+            warnUnchecked(tree.params.head.pos(), Warnings.UncheckedVarargsNonReifiableType(varargElemType));
         }
     }
     //where
@@ -998,9 +999,7 @@
                 (!Feature.SIMPLIFIED_VARARGS.allowedInSource(source) ||
                  sym.baseSymbol().attribute(syms.trustMeType.tsym) == null ||
                  !isTrustMeAllowedOnMethod(sym))) {
-                warnUnchecked(env.tree.pos(),
-                                  "unchecked.generic.array.creation",
-                                  argtype);
+                warnUnchecked(env.tree.pos(), Warnings.UncheckedGenericArrayCreation(argtype));
             }
             if ((sym.baseSymbol().flags() & SIGNATURE_POLYMORPHIC) == 0) {
                 TreeInfo.setVarargsElement(env.tree, types.elemtype(argtype));
@@ -1761,9 +1760,7 @@
             return;
         } else if (overrideWarner.hasNonSilentLint(LintCategory.UNCHECKED)) {
             warnUnchecked(TreeInfo.diagnosticPositionFor(m, tree),
-                    "override.unchecked.ret",
-                    uncheckedOverrides(m, other),
-                    mtres, otres);
+                    Warnings.OverrideUncheckedRet(uncheckedOverrides(m, other), mtres, otres));
         }
 
         // Error if overriding method throws an exception not reported
@@ -1779,9 +1776,7 @@
         }
         else if (unhandledUnerased.nonEmpty()) {
             warnUnchecked(TreeInfo.diagnosticPositionFor(m, tree),
-                          "override.unchecked.thrown",
-                         cannotOverride(m, other),
-                         unhandledUnerased.head);
+                          Warnings.OverrideUncheckedThrown(cannotOverride(m, other), unhandledUnerased.head));
             return;
         }
 
@@ -3237,10 +3232,10 @@
         missingDefaults = missingDefaults.reverse();
         if (missingDefaults.nonEmpty()) {
             isValid = false;
-            String key = (missingDefaults.size() > 1)
-                    ? "annotation.missing.default.value.1"
-                    : "annotation.missing.default.value";
-            log.error(a.pos(), key, a.type, missingDefaults);
+            Error errorKey = (missingDefaults.size() > 1)
+                    ? Errors.AnnotationMissingDefaultValue1(a.type, missingDefaults)
+                    : Errors.AnnotationMissingDefaultValue(a.type, missingDefaults);
+            log.error(a.pos(), errorKey);
         }
 
         return isValid && validateTargetAnnotationValue(a);
@@ -3605,14 +3600,14 @@
             if (warned) return; // suppress redundant diagnostics
             switch (lint) {
                 case UNCHECKED:
-                    Check.this.warnUnchecked(pos(), "prob.found.req", diags.fragment(uncheckedKey), found, expected);
+                    Check.this.warnUnchecked(pos(), Warnings.ProbFoundReq(diags.fragment(uncheckedKey), found, expected));
                     break;
                 case VARARGS:
                     if (method != null &&
                             method.attribute(syms.trustMeType.tsym) != null &&
                             isTrustMeAllowedOnMethod(method) &&
                             !types.isReifiable(method.type.getParameterTypes().last())) {
-                        Check.this.warnUnsafeVararg(pos(), "varargs.unsafe.use.varargs.param", method.params.last());
+                        Check.this.warnUnsafeVararg(pos(), Warnings.VarargsUnsafeUseVarargsParam(method.params.last()));
                     }
                     break;
                 default:
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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
@@ -38,6 +38,8 @@
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.JCDiagnostic.Error;
+import com.sun.tools.javac.util.JCDiagnostic.Warning;
 
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.JCTree.*;
@@ -1183,10 +1185,10 @@
                 // exception, that would have been covered in the branch above
                 if (chk.diff(catchableThrownTypes, caughtInTry).isEmpty() &&
                         !isExceptionOrThrowable(exc)) {
-                    String key = catchableThrownTypes.length() == 1 ?
-                            "unreachable.catch" :
-                            "unreachable.catch.1";
-                    log.warning(pos, key, catchableThrownTypes);
+                    Warning key = catchableThrownTypes.length() == 1 ?
+                            Warnings.UnreachableCatch(catchableThrownTypes) :
+                            Warnings.UnreachableCatch1(catchableThrownTypes);
+                    log.warning(pos, key);
                 }
             }
         }
@@ -1617,7 +1619,7 @@
                                       Errors.FinalParameterMayNotBeAssigned(sym));
                         }
                     } else if (!uninits.isMember(sym.adr)) {
-                        log.error(pos, flowKind.errKey, sym);
+                        log.error(pos, diags.errorKey(flowKind.errKey, sym));
                     } else {
                         uninit(sym);
                     }
@@ -1656,14 +1658,14 @@
         /** Check that trackable variable is initialized.
          */
         void checkInit(DiagnosticPosition pos, VarSymbol sym) {
-            checkInit(pos, sym, "var.might.not.have.been.initialized");
+            checkInit(pos, sym, Errors.VarMightNotHaveBeenInitialized(sym));
         }
 
-        void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) {
+        void checkInit(DiagnosticPosition pos, VarSymbol sym, Error errkey) {
             if ((sym.adr >= firstadr || sym.owner.kind != TYP) &&
                 trackable(sym) &&
                 !inits.isMember(sym.adr)) {
-                log.error(pos, errkey, sym);
+                log.error(pos, errkey);
                 inits.incl(sym.adr);
             }
         }
@@ -1894,7 +1896,7 @@
                                 // the ctor is default(synthesized) or not
                                 if (isSynthesized) {
                                     checkInit(TreeInfo.diagnosticPositionFor(var, vardecl),
-                                        var, "var.not.initialized.in.default.constructor");
+                                        var, Errors.VarNotInitializedInDefaultConstructor(var));
                                 } else {
                                     checkInit(TreeInfo.diagEndPos(tree.body), var);
                                 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -1410,7 +1410,7 @@
                 super.visitLambda(tree);
                 context.complete();
                 if (dumpLambdaToMethodStats) {
-                    log.note(tree, statKey, context.needsAltMetafactory(), context.translatedSym);
+                    log.note(tree, diags.noteKey(statKey, context.needsAltMetafactory(), context.translatedSym));
                 }
                 return context;
             }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -33,6 +33,7 @@
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.JCDiagnostic.Error;
 
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
@@ -305,9 +306,9 @@
         v.pos = tree.pos;
     }
     // where
-    void checkType(JCTree tree, Type type, String diag) {
+    void checkType(JCTree tree, Type type, Error errorKey) {
         if (!tree.type.isErroneous() && !types.isSameType(tree.type, type)) {
-            log.error(tree, diag, type, tree.type);
+            log.error(tree, errorKey);
         }
     }
     void checkReceiver(JCVariableDecl tree, Env<AttrContext> localEnv) {
@@ -320,14 +321,14 @@
                 outertype = m.owner.owner.owner.type;
             }
             if (outertype.hasTag(TypeTag.CLASS)) {
-                checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type");
-                checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name");
+                checkType(tree.vartype, outertype, Errors.IncorrectConstructorReceiverType(outertype, tree.vartype.type));
+                checkType(tree.nameexpr, outertype, Errors.IncorrectConstructorReceiverName(outertype, tree.nameexpr.type));
             } else {
                 log.error(tree, Errors.ReceiverParameterNotApplicableConstructorToplevelClass);
             }
         } else {
-            checkType(tree.vartype, m.owner.type, "incorrect.receiver.type");
-            checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name");
+            checkType(tree.vartype, m.owner.type, Errors.IncorrectReceiverType(m.owner.type, tree.vartype.type));
+            checkType(tree.nameexpr, m.owner.type, Errors.IncorrectReceiverName(m.owner.type, tree.nameexpr.type));
         }
     }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Fri Feb 02 07:43:54 2018 -0500
@@ -86,6 +86,7 @@
 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;
+import com.sun.tools.javac.util.JCDiagnostic.Warning;
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.jvm.ModuleNameReader;
@@ -1600,10 +1601,10 @@
         void add(Map<String, List<Path>> map, Path prefix, Path suffix) {
             if (!Files.isDirectory(prefix)) {
                 if (warn) {
-                    String key = Files.exists(prefix)
-                            ? "dir.path.element.not.directory"
-                            : "dir.path.element.not.found";
-                    log.warning(Lint.LintCategory.PATH, key, prefix);
+                    Warning key = Files.exists(prefix)
+                            ? Warnings.DirPathElementNotDirectory(prefix)
+                            : Warnings.DirPathElementNotFound(prefix);
+                    log.warning(Lint.LintCategory.PATH, key);
                 }
                 return;
             }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Feb 02 07:43:54 2018 -0500
@@ -26,8 +26,6 @@
 package com.sun.tools.javac.parser;
 
 import java.util.*;
-import java.util.function.Function;
-import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
@@ -39,12 +37,16 @@
 import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
 import com.sun.tools.javac.resources.CompilerProperties;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
+import com.sun.tools.javac.resources.CompilerProperties.Fragments;
+import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.JCDiagnostic.Error;
+import com.sun.tools.javac.util.JCDiagnostic.Warning;
+import com.sun.tools.javac.util.JCDiagnostic.Fragment;
 import com.sun.tools.javac.util.List;
 
 import static com.sun.tools.javac.parser.Tokens.TokenKind.*;
@@ -365,14 +367,14 @@
         }
     }
 
-    protected JCErroneous syntaxError(int pos, String key, TokenKind... args) {
-        return syntaxError(pos, List.nil(), key, args);
+    protected JCErroneous syntaxError(int pos, Error errorKey) {
+        return syntaxError(pos, List.nil(), errorKey);
     }
 
-    protected JCErroneous syntaxError(int pos, List<JCTree> errs, String key, TokenKind... args) {
+    protected JCErroneous syntaxError(int pos, List<JCTree> errs, Error errorKey) {
         setErrorEndPos(pos);
         JCErroneous err = F.at(pos).Erroneous(errs);
-        reportSyntaxError(err, key, (Object[])args);
+        reportSyntaxError(err, errorKey);
         if (errs != null) {
             JCTree last = errs.last();
             if (last != null)
@@ -389,22 +391,22 @@
      * Report a syntax using the given the position parameter and arguments,
      * unless one was already reported at the same position.
      */
-    protected void reportSyntaxError(int pos, String key, Object... args) {
+    protected void reportSyntaxError(int pos, Error errorKey) {
         JCDiagnostic.DiagnosticPosition diag = new JCDiagnostic.SimpleDiagnosticPosition(pos);
-        reportSyntaxError(diag, key, args);
+        reportSyntaxError(diag, errorKey);
     }
 
     /**
      * Report a syntax error using the given DiagnosticPosition object and
      * arguments, unless one was already reported at the same position.
      */
-    protected void reportSyntaxError(JCDiagnostic.DiagnosticPosition diagPos, String key, Object... args) {
+    protected void reportSyntaxError(JCDiagnostic.DiagnosticPosition diagPos, Error errorKey) {
         int pos = diagPos.getPreferredPosition();
         if (pos > S.errPos() || pos == Position.NOPOS) {
             if (token.kind == EOF) {
-                error(diagPos, "premature.eof");
+                log.error(DiagnosticFlag.SYNTAX, diagPos, Errors.PrematureEof);
             } else {
-                error(diagPos, key, args);
+                log.error(DiagnosticFlag.SYNTAX, diagPos, errorKey);
             }
         }
         S.errPos(pos);
@@ -417,21 +419,6 @@
         }
     }
 
-
-    /** Generate a syntax error at current position unless one was already
-     *  reported at the same position.
-     */
-    protected JCErroneous syntaxError(String key) {
-        return syntaxError(token.pos, key);
-    }
-
-    /** Generate a syntax error at current position unless one was
-     *  already reported at the same position.
-     */
-    protected JCErroneous syntaxError(String key, TokenKind arg) {
-        return syntaxError(token.pos, key, arg);
-    }
-
     /** If next input token matches given token, skip it, otherwise report
      *  an error.
      */
@@ -440,7 +427,7 @@
             nextToken();
         } else {
             setErrorEndPos(token.pos);
-            reportSyntaxError(S.prevToken().endPos, "expected", tk);
+            reportSyntaxError(S.prevToken().endPos, Errors.Expected(tk));
         }
     }
 
@@ -449,9 +436,9 @@
     JCExpression illegal(int pos) {
         setErrorEndPos(pos);
         if ((mode & EXPR) != 0)
-            return syntaxError(pos, "illegal.start.of.expr");
+            return syntaxError(pos, Errors.IllegalStartOfExpr);
         else
-            return syntaxError(pos, "illegal.start.of.type");
+            return syntaxError(pos, Errors.IllegalStartOfType);
 
     }
 
@@ -465,8 +452,7 @@
     protected void checkNoMods(long mods) {
         if (mods != 0) {
             long lowestMod = mods & -mods;
-            error(token.pos, "mod.not.allowed.here",
-                    Flags.asFlagSet(lowestMod));
+            log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.ModNotAllowedHere(Flags.asFlagSet(lowestMod)));
         }
     }
 
@@ -546,11 +532,11 @@
             nextToken();
             return name;
         } else if (token.kind == ASSERT) {
-            error(token.pos, "assert.as.identifier");
+            log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.AssertAsIdentifier);
             nextToken();
             return names.error;
         } else if (token.kind == ENUM) {
-            error(token.pos, "enum.as.identifier");
+            log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.EnumAsIdentifier);
             nextToken();
             return names.error;
         } else if (token.kind == THIS) {
@@ -561,15 +547,15 @@
                 nextToken();
                 return name;
             } else {
-                error(token.pos, "this.as.identifier");
+                log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.ThisAsIdentifier);
                 nextToken();
                 return names.error;
             }
         } else if (token.kind == UNDERSCORE) {
             if (Feature.UNDERSCORE_IDENTIFIER.allowedInSource(source)) {
-                warning(token.pos, "underscore.as.identifier");
+                log.warning(token.pos, Warnings.UnderscoreAsIdentifier);
             } else {
-                error(token.pos, "underscore.as.identifier");
+                log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.UnderscoreAsIdentifier);
             }
             Name name = token.name();
             nextToken();
@@ -628,7 +614,7 @@
                     TypeTag.INT,
                     Convert.string2int(strval(prefix), token.radix()));
             } catch (NumberFormatException ex) {
-                error(token.pos, "int.number.too.large", strval(prefix));
+                log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.IntNumberTooLarge(strval(prefix)));
             }
             break;
         case LONGLITERAL:
@@ -637,7 +623,7 @@
                     TypeTag.LONG,
                     Long.valueOf(Convert.string2long(strval(prefix), token.radix())));
             } catch (NumberFormatException ex) {
-                error(token.pos, "int.number.too.large", strval(prefix));
+                log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.IntNumberTooLarge(strval(prefix)));
             }
             break;
         case FLOATLITERAL: {
@@ -652,9 +638,9 @@
                 n = Float.NaN;
             }
             if (n.floatValue() == 0.0f && !isZero(proper))
-                error(token.pos, "fp.number.too.small");
+                log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.FpNumberTooSmall);
             else if (n.floatValue() == Float.POSITIVE_INFINITY)
-                error(token.pos, "fp.number.too.large");
+                log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.FpNumberTooLarge);
             else
                 t = F.at(pos).Literal(TypeTag.FLOAT, n);
             break;
@@ -671,9 +657,9 @@
                 n = Double.NaN;
             }
             if (n.doubleValue() == 0.0d && !isZero(proper))
-                error(token.pos, "fp.number.too.small");
+                log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.FpNumberTooSmall);
             else if (n.doubleValue() == Double.POSITIVE_INFINITY)
-                error(token.pos, "fp.number.too.large");
+                log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.FpNumberTooLarge);
             else
                 t = F.at(pos).Literal(TypeTag.DOUBLE, n);
             break;
@@ -762,7 +748,7 @@
         JCExpression result = term(TYPE);
 
         if (!allowVar && isRestrictedLocalVarTypeName(result)) {
-            syntaxError(result.pos, "var.not.allowed.here");
+            syntaxError(result.pos, Errors.VarNotAllowedHere);
         }
 
         return result;
@@ -1770,7 +1756,7 @@
             }
             accept(RPAREN);
         } else {
-            syntaxError(token.pos, "expected", LPAREN);
+            syntaxError(token.pos, Errors.Expected(LPAREN));
         }
         return args.toList();
     }
@@ -1839,13 +1825,13 @@
                     nextToken();
                     break;
                 default:
-                    args.append(syntaxError(token.pos, "expected", GT));
+                    args.append(syntaxError(token.pos, Errors.Expected(GT)));
                     break;
                 }
                 return args.toList();
             }
         } else {
-            return List.of(syntaxError(token.pos, "expected", LT));
+            return List.of(syntaxError(token.pos, Errors.Expected(LT)));
         }
     }
 
@@ -1879,7 +1865,7 @@
             JCExpression wc = toP(F.at(pos).Wildcard(t, null));
             JCIdent id = toP(F.at(token.pos).Ident(ident()));
             JCErroneous err = F.at(pos).Erroneous(List.<JCTree>of(wc, id));
-            reportSyntaxError(err, "expected3", GT, EXTENDS, SUPER);
+            reportSyntaxError(err, Errors.Expected3(GT, EXTENDS, SUPER));
             result = err;
         } else {
             TypeBoundKind t = toP(F.at(pos).TypeBoundKind(BoundKind.UNBOUND));
@@ -1969,7 +1955,7 @@
                 // are complained about directly in term3(), Here check for type annotations on dimensions
                 // taking care to handle some interior dimension(s) being annotated.
                 if ((tag == TYPEARRAY && TreeInfo.containsTypeAnnotation(t)) || tag == ANNOTATED_TYPE)
-                    syntaxError("no.annotations.on.dot.class");
+                    syntaxError(token.pos, Errors.NoAnnotationsOnDotClass);
                 t = toP(F.at(pos).Select(t, names._class));
             }
         } else if ((mode & TYPE) != 0) {
@@ -1977,7 +1963,7 @@
                 mode = TYPE;
             }
         } else if (token.kind != COLCOL) {
-            syntaxError(token.pos, "dot.class.expected");
+            syntaxError(token.pos, Errors.DotClassExpected);
         }
         return t;
     }
@@ -2070,7 +2056,7 @@
 
             JCExpression e = arrayCreatorRest(newpos, t);
             if (diamondFound) {
-                reportSyntaxError(lastTypeargsPos, "cannot.create.array.with.diamond");
+                reportSyntaxError(lastTypeargsPos, Errors.CannotCreateArrayWithDiamond);
                 return toP(F.at(newpos).Erroneous(List.of(e)));
             }
             else if (typeArgs != null) {
@@ -2083,7 +2069,7 @@
                 }
                 setErrorEndPos(S.prevToken().endPos);
                 JCErroneous err = F.at(pos).Erroneous(typeArgs.prepend(e));
-                reportSyntaxError(err, "cannot.create.array.with.type.arguments");
+                reportSyntaxError(err, Errors.CannotCreateArrayWithTypeArguments);
                 return toP(err);
             }
             return e;
@@ -2109,7 +2095,7 @@
             return newClass;
         } else {
             setErrorEndPos(token.pos);
-            reportSyntaxError(token.pos, "expected2", LPAREN, LBRACKET);
+            reportSyntaxError(token.pos, Errors.Expected2(LPAREN, LBRACKET));
             t = toP(F.at(newpos).NewClass(null, typeArgs, t, List.nil(), null));
             return toP(F.at(newpos).Erroneous(List.<JCTree>of(t)));
         }
@@ -2161,7 +2147,7 @@
                 return na;
             } else {
                 JCExpression t = toP(F.at(newpos).NewArray(elemtype, List.nil(), null));
-                return syntaxError(token.pos, List.of(t), "array.dimension.missing");
+                return syntaxError(token.pos, List.of(t), Errors.ArrayDimensionMissing);
             }
         } else {
             ListBuffer<JCExpression> dims = new ListBuffer<>();
@@ -2201,7 +2187,7 @@
             na.dimAnnotations = dimAnnotations.toList();
 
             if (elems != null) {
-                return syntaxError(errpos, List.of(na), "illegal.array.creation.both.dimension.and.initialization");
+                return syntaxError(errpos, List.of(na), Errors.IllegalArrayCreationBothDimensionAndInitialization);
             }
 
             return na;
@@ -2273,7 +2259,7 @@
         List<JCStatement> stats = blockStatements();
         JCBlock t = F.at(pos).Block(flags, stats);
         while (token.kind == CASE || token.kind == DEFAULT) {
-            syntaxError("orphaned", token.kind);
+            syntaxError(token.pos, Errors.Orphaned(token.kind));
             switchBlockStatementGroups();
         }
         // the Block node has a field "endpos" for first char of last token, which is
@@ -2327,21 +2313,21 @@
         int pos = token.pos;
         List<JCStatement> stats = blockStatement();
         if (stats.isEmpty()) {
-            JCErroneous e = syntaxError(pos, "illegal.start.of.stmt");
+            JCErroneous e = syntaxError(pos, Errors.IllegalStartOfStmt);
             return toP(F.at(pos).Exec(e));
         } else {
             JCStatement first = stats.head;
-            String error = null;
+            Error error = null;
             switch (first.getTag()) {
             case CLASSDEF:
-                error = "class.not.allowed";
+                error = Errors.ClassNotAllowed;
                 break;
             case VARDEF:
-                error = "variable.not.allowed";
+                error = Errors.VariableNotAllowed;
                 break;
             }
             if (error != null) {
-                error(first, error);
+                log.error(DiagnosticFlag.SYNTAX, first, error);
                 List<JCBlock> blist = List.of(F.at(first.pos).Block(0, stats));
                 return toP(F.at(pos).Exec(F.at(first.pos).Erroneous(blist)));
             }
@@ -2385,7 +2371,7 @@
             Comment dc = token.comment(CommentStyle.JAVADOC);
             return List.of(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
         case ENUM:
-            error(token.pos, "local.enum");
+            log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.LocalEnum);
             dc = token.comment(CommentStyle.JAVADOC);
             return List.of(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
         default:
@@ -2513,9 +2499,9 @@
             } else {
                 if (resources.isEmpty()) {
                     if (Feature.TRY_WITH_RESOURCES.allowedInSource(source)) {
-                        error(pos, "try.without.catch.finally.or.resource.decls");
+                        log.error(DiagnosticFlag.SYNTAX, pos, Errors.TryWithoutCatchFinallyOrResourceDecls);
                     } else {
-                        error(pos, "try.without.catch.or.finally");
+                        log.error(DiagnosticFlag.SYNTAX, pos, Errors.TryWithoutCatchOrFinally);
                     }
                 }
             }
@@ -2570,13 +2556,13 @@
         case ELSE:
             int elsePos = token.pos;
             nextToken();
-            return doRecover(elsePos, BasicErrorRecoveryAction.BLOCK_STMT, "else.without.if");
+            return doRecover(elsePos, BasicErrorRecoveryAction.BLOCK_STMT, Errors.ElseWithoutIf);
         case FINALLY:
             int finallyPos = token.pos;
             nextToken();
-            return doRecover(finallyPos, BasicErrorRecoveryAction.BLOCK_STMT, "finally.without.try");
+            return doRecover(finallyPos, BasicErrorRecoveryAction.BLOCK_STMT, Errors.FinallyWithoutTry);
         case CATCH:
-            return doRecover(token.pos, BasicErrorRecoveryAction.CATCH_CLAUSE, "catch.without.try");
+            return doRecover(token.pos, BasicErrorRecoveryAction.CATCH_CLAUSE, Errors.CatchWithoutTry);
         case ASSERT: {
             nextToken();
             JCExpression assertion = parseExpression();
@@ -2600,11 +2586,11 @@
         return parseStatementAsBlock();
     }
 
-    private JCStatement doRecover(int startPos, ErrorRecoveryAction action, String key) {
+    private JCStatement doRecover(int startPos, ErrorRecoveryAction action, Error errorKey) {
         int errPos = S.errPos();
         JCTree stm = action.doRecover(this);
         S.errPos(errPos);
-        return toP(F.Exec(syntaxError(startPos, List.of(stm), key)));
+        return toP(F.Exec(syntaxError(startPos, List.of(stm), errorKey)));
     }
 
     /** CatchClause     = CATCH "(" FormalParameter ")" Block
@@ -2655,8 +2641,7 @@
                 return cases.toList();
             default:
                 nextToken(); // to ensure progress
-                syntaxError(pos, "expected3",
-                    CASE, DEFAULT, RBRACE);
+                syntaxError(pos, Errors.Expected3(CASE, DEFAULT, RBRACE));
             }
         }
     }
@@ -2717,7 +2702,7 @@
             if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.accepts(token.kind)) {
                 return variableDeclarators(modifiersOpt(), t, stats, true).toList();
             } else if ((lastmode & TYPE) != 0 && token.kind == COLON) {
-                error(pos, "bad.initializer", "for-loop");
+                log.error(DiagnosticFlag.SYNTAX, pos, Errors.BadInitializer("for-loop"));
                 return List.of((JCStatement)F.at(pos).VarDef(null, null, t, null));
             } else {
                 return moreStatementExpressions(pos, t, stats).toList();
@@ -2802,7 +2787,7 @@
             case ERROR       : flag = 0; nextToken(); break;
             default: break loop;
             }
-            if ((flags & flag) != 0) error(token.pos, "repeated.modifier");
+            if ((flags & flag) != 0) log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.RepeatedModifier);
             lastPos = token.pos;
             nextToken();
             if (flag == Flags.ANNOTATION) {
@@ -2960,7 +2945,7 @@
         vdefs.append(head);
         while (token.kind == COMMA) {
             if (implicit) {
-                reportSyntaxError(pos, "var.not.allowed.compound");
+                reportSyntaxError(pos, Errors.VarNotAllowedCompound);
             }
             // All but last of multiple declarators subsume a comma
             storeEnd((JCTree)vdefs.last(), token.endPos);
@@ -2991,7 +2976,7 @@
             nextToken();
             init = variableInitializer();
         }
-        else if (reqInit) syntaxError(token.pos, "expected", EQ);
+        else if (reqInit) syntaxError(token.pos, Errors.Expected(EQ));
         JCTree elemType = TreeInfo.innermostType(type, true);
         int startPos = Position.NOPOS;
         if (Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source) && elemType.hasTag(IDENT)) {
@@ -2999,7 +2984,7 @@
             if (isRestrictedLocalVarTypeName(typeName)) {
                 if (type.hasTag(TYPEARRAY)) {
                     //error - 'var' and arrays
-                    reportSyntaxError(pos, "var.not.allowed.array");
+                    reportSyntaxError(pos, Errors.VarNotAllowedArray);
                 } else {
                     startPos = TreeInfo.getStartPos(mods);
                     if (startPos == Position.NOPOS)
@@ -3177,7 +3162,7 @@
                         consumedToplevelDoc = true;
                         break;
                     } else if (kind != ModuleKind.STRONG) {
-                        reportSyntaxError(token.pos, "expected.module");
+                        reportSyntaxError(token.pos, Errors.ExpectedModule);
                     }
                 }
                 JCTree def = typeDeclaration(mods, docComment);
@@ -3246,7 +3231,7 @@
                             }
                         case STATIC:
                             if (isStaticPhase) {
-                                error(token.pos, "repeated.modifier");
+                                log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.RepeatedModifier);
                             }
                             isStaticPhase = true;
                             break;
@@ -3284,7 +3269,7 @@
                     accept(SEMI);
                     defs.append(toP(F.at(pos).Provides(serviceName, implNames)));
                 } else {
-                    error(token.pos, "expected", "'" + names.with + "'");
+                    log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.ExpectedStr("'" + names.with + "'"));
                     skip(false, false, false, false);
                 }
             } else if (token.name() == names.uses) {
@@ -3294,7 +3279,7 @@
                 defs.append(toP(F.at(pos).Uses(service)));
             } else {
                 setErrorEndPos(pos);
-                reportSyntaxError(pos, "invalid.module.directive");
+                reportSyntaxError(pos, Errors.InvalidModuleDirective);
                 break;
             }
         }
@@ -3363,9 +3348,9 @@
             }
             final JCErroneous erroneousTree;
             if (parseModuleInfo) {
-                erroneousTree = syntaxError(pos, errs, "expected.module.or.open");
+                erroneousTree = syntaxError(pos, errs, Errors.ExpectedModuleOrOpen);
             } else {
-                erroneousTree = syntaxError(pos, errs, "expected3", CLASS, INTERFACE, ENUM);
+                erroneousTree = syntaxError(pos, errs, Errors.Expected3(CLASS, INTERFACE, ENUM));
             }
             return toP(F.Exec(erroneousTree));
         }
@@ -3405,9 +3390,9 @@
         Name name = ident();
         if (name == names.var) {
             if (Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source)) {
-                reportSyntaxError(pos, "var.not.allowed", name);
+                reportSyntaxError(pos, Errors.VarNotAllowed(name));
             } else {
-                warning(pos, "var.not.allowed");
+                log.warning(pos, Warnings.VarNotAllowed);
             }
         }
         return name;
@@ -3479,8 +3464,7 @@
                 defs.append(enumeratorDeclaration(enumName));
             }
             if (token.kind != SEMI && token.kind != RBRACE) {
-                defs.append(syntaxError(token.pos, "expected3",
-                                COMMA, RBRACE, SEMI));
+                defs.append(syntaxError(token.pos, Errors.Expected3(COMMA, RBRACE, SEMI)));
                 nextToken();
             }
         }
@@ -3614,7 +3598,7 @@
                        (mods.flags & Flags.StandardFlags & ~Flags.STATIC) == 0 &&
                        mods.annotations.isEmpty()) {
                 if (isInterface) {
-                    error(token.pos, "initializer.not.allowed");
+                    log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.InitializerNotAllowed);
                 }
                 return List.of(block(pos, mods.flags));
             } else {
@@ -3648,7 +3632,7 @@
                 }
                 if (token.kind == LPAREN && !isInterface && type.hasTag(IDENT)) {
                     if (isInterface || tk.name() != className)
-                        error(pos, "invalid.meth.decl.ret.type.req");
+                        log.error(DiagnosticFlag.SYNTAX, pos, Errors.InvalidMethDeclRetTypeReq);
                     else if (annosAfterParams.nonEmpty())
                         illegal(annosAfterParams.head.pos);
                     return List.of(methodDeclaratorRest(
@@ -3674,7 +3658,7 @@
                             ? List.of(toP(F.at(pos).MethodDef(mods, name, type, typarams,
                                 List.nil(), List.nil(), null, null)))
                             : null;
-                        return List.of(syntaxError(token.pos, err, "expected", LPAREN));
+                        return List.of(syntaxError(token.pos, err, Errors.Expected(LPAREN)));
                     }
                 }
             }
@@ -3841,7 +3825,7 @@
             this.allowThisIdent = false;
             while (token.kind == COMMA) {
                 if ((lastParam.mods.flags & Flags.VARARGS) != 0) {
-                    error(lastParam, "varargs.must.be.last");
+                    log.error(DiagnosticFlag.SYNTAX, lastParam, Errors.VarargsMustBeLast);
                 }
                 nextToken();
                 params.append(lastParam = formalParameter(lambdaParameters));
@@ -3851,7 +3835,7 @@
             nextToken();
         } else {
             setErrorEndPos(token.pos);
-            reportSyntaxError(S.prevToken().endPos, "expected3", COMMA, RPAREN, LBRACKET);
+            reportSyntaxError(S.prevToken().endPos, Errors.Expected3(COMMA, RPAREN, LBRACKET));
         }
         return params.toList();
     }
@@ -3976,8 +3960,7 @@
         } else {
             // if not a var arg, then typeAnnotationsPushedBack should be null
             if (typeAnnotationsPushedBack.nonEmpty()) {
-                reportSyntaxError(typeAnnotationsPushedBack.head.pos,
-                        "illegal.start.of.type");
+                reportSyntaxError(typeAnnotationsPushedBack.head.pos, Errors.IllegalStartOfType);
             }
             typeAnnotationsPushedBack = List.nil();
         }
@@ -3990,25 +3973,12 @@
     }
 
 /* ---------- auxiliary methods -------------- */
-
-    void error(int pos, String key, Object ... args) {
-        log.error(DiagnosticFlag.SYNTAX, pos, key, args);
-    }
-
-    void error(DiagnosticPosition pos, String key, Object ... args) {
-        log.error(DiagnosticFlag.SYNTAX, pos, key, args);
-    }
-
-    void warning(int pos, String key, Object ... args) {
-        log.warning(pos, key, args);
-    }
-
     /** Check that given tree is a legal expression statement.
      */
     protected JCExpression checkExprStat(JCExpression t) {
         if (!TreeInfo.isExpressionStatement(t)) {
             JCExpression ret = F.at(t.pos).Erroneous(List.<JCTree>of(t));
-            error(ret, "not.stmt");
+            log.error(DiagnosticFlag.SYNTAX, ret, Errors.NotStmt);
             return ret;
         } else {
             return t;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ParserFactory.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ParserFactory.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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,7 @@
 import com.sun.tools.javac.tree.DocTreeMaker;
 import com.sun.tools.javac.tree.TreeMaker;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Names;
 import com.sun.tools.javac.util.Options;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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
@@ -724,7 +724,7 @@
             throw new FilerException("Attempt to recreate a file for type " + typename);
         }
         if (lint && existing != null) {
-            log.warning("proc.type.already.exists", typename);
+            log.warning(Warnings.ProcTypeAlreadyExists(typename));
         }
         if (!mod.isUnnamed() && !typename.contains(".")) {
             throw new FilerException("Attempt to create a type in unnamed package of a named module: " + typename);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Feb 02 07:43:54 2018 -0500
@@ -624,9 +624,9 @@
 compiler.err.incomparable.types=\
     incomparable types: {0} and {1}
 
-# 0: number
+# 0: string
 compiler.err.int.number.too.large=\
-    integer number too large: {0}
+    integer number too large
 
 compiler.err.intf.annotation.members.cant.have.params=\
     elements in annotation type declarations cannot declare formal parameters
@@ -1207,7 +1207,7 @@
 compiler.err.illegal.ref.to.var.type=\
     illegal reference to restricted type ''{0}''
 
-# 0: token
+# 0: name
 compiler.err.var.not.allowed=\
     ''{0}'' not allowed here\n\
     as of release 10, ''{0}'' is a restricted local variable type and cannot be used for type declarations
@@ -1734,7 +1734,7 @@
     {0}: major version {1} is newer than {2}, the highest major version supported by this compiler.\n\
     It is recommended that the compiler be upgraded.
 
-# 0: symbol kind, 1: symbol
+# 0: kind name, 1: symbol
 compiler.warn.static.not.qualified.by.type=\
     static {0} should be qualified by type name, {1}, instead of by an expression
 
@@ -1780,7 +1780,7 @@
 compiler.warn.proc.file.reopening=\
     Attempt to create a file for ''{0}'' multiple times
 
-# 0: name
+# 0: string
 compiler.warn.proc.type.already.exists=\
     A file for type ''{0}'' already exists on the sourcepath or classpath
 
@@ -1861,7 +1861,7 @@
 compiler.warn.unchecked.cast.to.type=\
     unchecked cast to type {0}
 
-# 0: symbol kind, 1: name, 2: list of type, 3: list of type, 4: symbol kind, 5: symbol
+# 0: kind name, 1: name, 2: object, 3: object, 4: kind name, 5: symbol
 compiler.warn.unchecked.meth.invocation.applied=\
     unchecked method invocation: {0} {1} in {4} {5} is applied to given types\n\
     required: {2}\n\
@@ -1998,6 +1998,10 @@
 compiler.err.expected=\
     {0} expected
 
+# 0: string
+compiler.err.expected.str=\
+    {0} expected
+
 # 0: token, 1: token
 compiler.err.expected2=\
     {0} or {1} expected
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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
@@ -110,16 +110,6 @@
     /** 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 key    The key for the localized error message.
-     *  @param args   Fields of the error message.
-     */
-    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) {
@@ -130,17 +120,6 @@
      *  source position.
      *  @param flag   A flag to set on the diagnostic
      *  @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 void error(DiagnosticFlag flag, DiagnosticPosition pos, String key, Object ... args) {
-        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) {
@@ -170,17 +149,6 @@
      *  source position.
      *  @param flag   A flag to set on the diagnostic
      *  @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 void error(DiagnosticFlag flag, int pos, String key, Object ... args) {
-        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) {
@@ -189,15 +157,6 @@
 
     /** Report a warning, unless suppressed by the  -nowarn option or the
      *  maximum number of warnings has been reached.
-     *  @param key    The key for the localized warning message.
-     *  @param args   Fields of the warning message.
-     */
-    public void warning(String key, Object ... 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) {
@@ -207,16 +166,6 @@
     /** 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 key    The key for the localized warning message.
-     *  @param args   Fields of the warning message.
-     */
-    public void warning(LintCategory lc, String key, Object ... 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) {
@@ -226,16 +175,6 @@
     /** 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 key    The key for the localized warning message.
-     *  @param args   Fields of the warning message.
-     */
-    public void warning(DiagnosticPosition pos, String key, Object ... 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) {
@@ -246,17 +185,6 @@
      *  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 key    The key for the localized warning message.
-     *  @param args   Fields of the warning message.
-     */
-    public void warning(LintCategory lc, DiagnosticPosition pos, String key, Object ... 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) {
@@ -266,16 +194,6 @@
     /** 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 key    The key for the localized warning message.
-     *  @param args   Fields of the warning message.
-     */
-    public void warning(int pos, String key, Object ... 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) {
@@ -284,15 +202,6 @@
 
     /** Report a 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 void mandatoryWarning(DiagnosticPosition pos, String key, Object ... 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) {
@@ -302,16 +211,6 @@
     /** Report a warning.
      *  @param lc     The lint category for the diagnostic
      *  @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 void mandatoryWarning(LintCategory lc, DiagnosticPosition pos, String key, Object ... 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) {
@@ -319,14 +218,6 @@
     }
 
     /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
-     *  @param key    The key for the localized notification message.
-     *  @param args   Fields of the notint an error or warning message:
-     */
-    public void note(String key, Object ... 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) {
@@ -334,14 +225,6 @@
     }
 
     /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
-     *  @param key    The key for the localized notification message.
-     *  @param args   Fields of the notification message.
-     */
-    public void note(DiagnosticPosition pos, String key, Object ... 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) {
@@ -349,14 +232,6 @@
     }
 
     /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
-     *  @param key    The key for the localized notification message.
-     *  @param args   Fields of the notification message.
-     */
-    public void note(int pos, String key, Object ... 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) {
@@ -364,14 +239,6 @@
     }
 
     /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
-     *  @param key    The key for the localized notification message.
-     *  @param args   Fields of the notification message.
-     */
-    public void note(JavaFileObject file, String key, Object ... 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) {
@@ -379,14 +246,6 @@
     }
 
     /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
-     *  @param key    The key for the localized notification message.
-     *  @param args   Fields of the notification message.
-     */
-    public void mandatoryNote(final JavaFileObject file, String key, Object ... 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) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -295,7 +295,7 @@
         /**
          * Create a new error key.
          */
-        Error errorKey(String code, Object... args) {
+        public Error errorKey(String code, Object... args) {
             return (Error)DiagnosticInfo.of(ERROR, prefix, code, args);
         }
 
@@ -309,7 +309,7 @@
         /**
          * Create a new note key.
          */
-        Note noteKey(String code, Object... args) {
+        public Note noteKey(String code, Object... args) {
             return (Note)DiagnosticInfo.of(NOTE, prefix, code, args);
         }
 
@@ -527,6 +527,23 @@
             }
         }
 
+        /**
+         * Returns the code for this diagnostic info, provided mainly for backward compatibility
+         */
+        public String getCode() {
+            return code;
+        }
+
+        /**
+         * Returns the arguments for this diagnostic info, provided mainly for backward compatibility
+         */
+        public Object[] getArgs() {
+            return args;
+        }
+
+        public void setArgs(Object[] args) {
+            this.args = args;
+        }
     }
 
     /**
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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 com.sun.tools.javac.code.Lint.LintCategory;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.JCDiagnostic.Note;
+import com.sun.tools.javac.util.JCDiagnostic.Warning;
 
 
 /**
@@ -121,7 +123,7 @@
     /**
      * Report a mandatory warning.
      */
-    public void report(DiagnosticPosition pos, String msg, Object... args) {
+    public void report(DiagnosticPosition pos, Warning warnKey) {
         JavaFileObject currentSource = log.currentSourceFile();
 
         if (verbose) {
@@ -130,7 +132,7 @@
 
             if (log.nwarnings < log.MaxWarnings) {
                 // generate message and remember the source file
-                logMandatoryWarning(pos, msg, args);
+                logMandatoryWarning(pos, warnKey);
                 sourcesWithReportedWarnings.add(currentSource);
             } else if (deferredDiagnosticKind == null) {
                 // set up deferred message
@@ -248,13 +250,12 @@
      * Reports a mandatory warning to the log.  If mandatory warnings
      * are not being enforced, treat this as an ordinary warning.
      */
-    private void logMandatoryWarning(DiagnosticPosition pos, String msg,
-                                     Object... args) {
+    private void logMandatoryWarning(DiagnosticPosition pos, Warning warnKey) {
         // Note: the following log methods are safe if lintCategory is null.
         if (enforceMandatory)
-            log.mandatoryWarning(lintCategory, pos, msg, args);
+            log.mandatoryWarning(lintCategory, pos, warnKey);
         else
-            log.warning(lintCategory, pos, msg, args);
+            log.warning(lintCategory, pos, warnKey);
     }
 
     /**
@@ -263,8 +264,8 @@
      */
     private void logMandatoryNote(JavaFileObject file, String msg, Object... args) {
         if (enforceMandatory)
-            log.mandatoryNote(file, msg, args);
+            log.mandatoryNote(file, new Note("compiler", msg, args));
         else
-            log.note(file, msg, args);
+            log.note(file, new Note("compiler", msg, args));
     }
 }
--- a/src/jdk.compiler/share/classes/module-info.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.compiler/share/classes/module-info.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, 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
@@ -85,6 +85,8 @@
     exports com.sun.tools.javac.api to
         jdk.javadoc,
         jdk.jshell;
+    exports com.sun.tools.javac.resources to
+        jdk.jshell;
     exports com.sun.tools.javac.code to
         jdk.javadoc,
         jdk.jshell;
--- a/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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
@@ -129,16 +129,6 @@
         }
 
         @Override
-        public void error(DiagnosticPosition pos, String key, Object... args) {
-            die();
-        }
-
-        @Override
-        public void error(DiagnosticFlag flag, DiagnosticPosition pos, String key, Object... args) {
-            die();
-        }
-
-        @Override
         public void error(int pos, Error errorKey) {
             die();
         }
@@ -149,11 +139,6 @@
         }
 
         @Override
-        public void error(DiagnosticFlag flag, int pos, String key, Object... args) {
-            die();
-        }
-
-        @Override
         public void report(JCDiagnostic diagnostic) {
             // Ignore
         }
--- a/src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, 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
@@ -32,6 +32,8 @@
 import com.sun.tools.javac.parser.Tokens.Comment;
 import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
 import com.sun.tools.javac.parser.Tokens.Token;
+import com.sun.tools.javac.resources.CompilerProperties;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import static com.sun.tools.javac.parser.Tokens.TokenKind.CLASS;
 import static com.sun.tools.javac.parser.Tokens.TokenKind.COLON;
 import static com.sun.tools.javac.parser.Tokens.TokenKind.ENUM;
@@ -244,11 +246,11 @@
                                     ? List.of(toP(F.at(pos).MethodDef(mods, name, t, typarams,
                                                             List.nil(), List.nil(), null, null)))
                                     : null;
-                            return List.<JCTree>of(syntaxError(token.pos, err, "expected", LPAREN));
+                            return List.<JCTree>of(syntaxError(token.pos, err, Errors.Expected(LPAREN)));
                         }
                     } else if (!typarams.isEmpty()) {
                         // type parameters on non-variable non-method -- error
-                        return List.<JCTree>of(syntaxError(token.pos, "illegal.start.of.type"));
+                        return List.<JCTree>of(syntaxError(token.pos, Errors.IllegalStartOfType));
                     } else {
                         // expression-statement or expression to evaluate
                         JCExpressionStatement expr = toP(F.at(pos).Exec(t));
--- a/test/langtools/tools/javac/6304921/TestLog.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/test/langtools/tools/javac/6304921/TestLog.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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
@@ -29,6 +29,7 @@
  *          jdk.compiler/com.sun.tools.javac.parser
  *          jdk.compiler/com.sun.tools.javac.tree
  *          jdk.compiler/com.sun.tools.javac.util:+open
+ *          jdk.compiler/com.sun.tools.javac.resources
  */
 import java.lang.reflect.Field;
 import java.io.InputStream;
@@ -49,6 +50,8 @@
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
 import com.sun.tools.javac.util.JCDiagnostic.Factory;
 import com.sun.tools.javac.util.Options;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
+import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 
 public class TestLog
 {
@@ -122,15 +125,15 @@
         public void visitIf(JCTree.JCIf tree) {
             JCDiagnostic.DiagnosticPosition nil = null;
             // generate dummy messages to exercise the log API
-            log.error("not.stmt");
-            log.error(tree.pos, "not.stmt");
-            log.error(tree.pos(), "not.stmt");
-            log.error(nil, "not.stmt");
+            log.error(Errors.NotStmt);
+            log.error(tree.pos, Errors.NotStmt);
+            log.error(tree.pos(), Errors.NotStmt);
+            log.error(nil, Errors.NotStmt);
 
-            log.warning("div.zero");
-            log.warning(tree.pos, "div.zero");
-            log.warning(tree.pos(), "div.zero");
-            log.warning(nil, "div.zero");
+            log.warning(Warnings.DivZero);
+            log.warning(tree.pos, Warnings.DivZero);
+            log.warning(tree.pos(), Warnings.DivZero);
+            log.warning(nil, Warnings.DivZero);
         }
 
         private Log log;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/WithExpected/module-info.java	Fri Feb 02 07:43:54 2018 -0500
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.expected.str
+
+module WithExpected {
+    provides p.C;
+}
--- a/test/langtools/tools/javac/modules/ProvidesTest.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/test/langtools/tools/javac/modules/ProvidesTest.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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
@@ -103,7 +103,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("module-info.java:1:24: compiler.err.expected: 'with'"))
+        if (!log.contains("module-info.java:1:24: compiler.err.expected.str: 'with'"))
             throw new Exception("expected output not found");
 
     }
--- a/test/langtools/tools/javac/parser/extend/JavacExtensionTest.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/test/langtools/tools/javac/parser/extend/JavacExtensionTest.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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
@@ -56,6 +56,7 @@
  *          jdk.compiler/com.sun.tools.javac.parser
  *          jdk.compiler/com.sun.tools.javac.tree
  *          jdk.compiler/com.sun.tools.javac.util
+ *          jdk.compiler/com.sun.tools.javac.resources
  */
 public class JavacExtensionTest {
 
--- a/test/langtools/tools/javac/parser/extend/TrialParser.java	Fri Feb 02 23:21:12 2018 +0530
+++ b/test/langtools/tools/javac/parser/extend/TrialParser.java	Fri Feb 02 07:43:54 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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
@@ -55,6 +55,7 @@
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Position;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
 
 /**
  *
@@ -236,11 +237,11 @@
                                     ? List.<JCTree>of(toP(F.at(pos).MethodDef(mods, name, t, typarams,
                                                             List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, null)))
                                     : null;
-                            return List.<JCTree>of(syntaxError(token.pos, err, "expected", LPAREN));
+                            return List.<JCTree>of(syntaxError(token.pos, err, Errors.Expected(LPAREN)));
                         }
                     } else if (!typarams.isEmpty()) {
                         // type parameters on non-variable non-method -- error
-                        return List.<JCTree>of(syntaxError(token.pos, "illegal.start.of.type"));
+                        return List.<JCTree>of(syntaxError(token.pos, Errors.IllegalStartOfType));
                     } else {
                         // expression-statement or expression to evaluate
                         accept(SEMI);