mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8374718: Generation of CompilerProperties can fail in subtle ways
Reviewed-by: jlahoda
This commit is contained in:
parent
067fd3cb2f
commit
904ba5f5ed
@ -286,7 +286,7 @@ public class ClassGenerator {
|
||||
diagnosticFlags.isEmpty() ?
|
||||
StubKind.DIAGNOSTIC_FLAGS_EMPTY.format() :
|
||||
StubKind.DIAGNOSTIC_FLAGS_NON_EMPTY.format(diagnosticFlags),
|
||||
StubKind.LINT_CATEGORY.format("\"" + lintCategory + "\""),
|
||||
StubKind.LINT_CATEGORY.format(toLintFieldName(lintCategory)),
|
||||
"\"" + keyParts[0] + "\"",
|
||||
"\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"",
|
||||
javadoc);
|
||||
@ -314,7 +314,7 @@ public class ClassGenerator {
|
||||
diagnosticFlags.isEmpty() ?
|
||||
StubKind.DIAGNOSTIC_FLAGS_EMPTY.format() :
|
||||
StubKind.DIAGNOSTIC_FLAGS_NON_EMPTY.format(diagnosticFlags),
|
||||
StubKind.LINT_CATEGORY.format("\"" + lintCategory + "\""),
|
||||
StubKind.LINT_CATEGORY.format(toLintFieldName(lintCategory)),
|
||||
"\"" + keyParts[0] + "\"",
|
||||
"\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"",
|
||||
argNames.stream().collect(Collectors.joining(", ")));
|
||||
@ -329,6 +329,11 @@ public class ClassGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
String toLintFieldName(String lintCategory) {
|
||||
return lintCategory.toUpperCase()
|
||||
.replaceAll("-", "_");
|
||||
}
|
||||
|
||||
/**
|
||||
* Form the name of a factory method/field given a resource key.
|
||||
*/
|
||||
|
||||
@ -87,7 +87,7 @@ suppress.warnings=\
|
||||
@SuppressWarnings("rawtypes")\n
|
||||
|
||||
lint.category=\
|
||||
LintCategory.get({0}).get()
|
||||
LintCategory.{0}
|
||||
|
||||
diagnostic.flags.empty=\
|
||||
EnumSet.noneOf(DiagnosticFlag.class)
|
||||
|
||||
@ -37,11 +37,7 @@ import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.sun.tools.javac.main.Option;
|
||||
import com.sun.tools.javac.tree.JCTree.*;
|
||||
import com.sun.tools.javac.util.Assert;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
|
||||
import com.sun.tools.javac.util.JCDiagnostic.LintWarning;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
import com.sun.tools.javac.util.Names;
|
||||
import com.sun.tools.javac.util.Options;
|
||||
@ -178,6 +174,14 @@ public class Lint {
|
||||
|
||||
/**
|
||||
* Categories of warnings that can be generated by the compiler.
|
||||
* Each lint category has a logical name (a string), which is the string used e.g. in a {@code SuppressWarning} annotation.
|
||||
* To ensure automation, the enum field name for a lint category string {@code C} should be obtained by:
|
||||
* <ol>
|
||||
* <li>capitalize all the letters in {@code C}, and</li>
|
||||
* <li>replacing any occurrence of {@code -} with {@code _}</li>
|
||||
* </ol>
|
||||
* For instance, the lint category string {@code dangling-doc-comments} corresponds to the enum field
|
||||
* {@code DANGLING_DOC_COMMENTS}.
|
||||
*/
|
||||
public enum LintCategory {
|
||||
/**
|
||||
@ -320,7 +324,7 @@ public class Lint {
|
||||
/**
|
||||
* Warn about unchecked operations on raw types.
|
||||
*/
|
||||
RAW("rawtypes"),
|
||||
RAWTYPES("rawtypes"),
|
||||
|
||||
/**
|
||||
* Warn about use of deprecated-for-removal items.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user