Skip to content

Commit

Permalink
fix all removal warnings; add 3 different groups of tools options
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrushforth committed Mar 4, 2024
1 parent c44747e commit e596a73
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 18 deletions.
81 changes: 63 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,30 @@ ext.IS_RELEASE = !ext.IS_DEBUG_JAVA
defineProperty("MAVEN_PUBLISH", "false")
ext.IS_MAVEN_PUBLISH = Boolean.parseBoolean(MAVEN_PUBLISH)

// Defines the compiler lint warnings to enable. This can be overriden on
// Define the compiler lint warnings to enable. They can be overriden on
// the command line. If set to the empty string, then no lint warnings are
// enabled; even module-specific lint options are disabled. If not empty,
// then it is parsed as a space or comma separated list of names. See the
// javac documentation for a list of valid lint options.

// We define a separate set of options for normal classes, test classes
// (including shims), and tool classes (including JSLC)

def defaultLintOptions =
"removal" + "," +
"missing-explicit-ctor"
defineProperty("LINT", defaultLintOptions)
ext.IS_LINT = LINT != ""

def defaultToolLintOptions = ""
defineProperty("TOOL_LINT", defaultToolLintOptions)
ext.IS_TOOL_LINT = TOOL_LINT != ""

def defaultTestLintOptions = ""
defineProperty("TEST_LINT", defaultTestLintOptions)
ext.IS_TEST_LINT = TEST_LINT != ""

// Doclint options (all enabled by default)
defineProperty("DOC_LINT", "all")
ext.IS_DOC_LINT = DOC_LINT != ""

Expand Down Expand Up @@ -2164,7 +2176,7 @@ project(":base") {
// FIXME KCR: the following is just an example
project.ext.extraLintOptions =
"strictfp" + "," +
"lossy-conversions"
"path"

sourceSets {
main
Expand Down Expand Up @@ -4050,6 +4062,20 @@ project(":systemTests") {
addValidateSourceSets(project, nonModSrcSets, modSrcSets)
}

void setupLintOptions(Task compile, String lintOpts, String extraLintOpts) {
lintOpts.split("[, ]").each { s ->
compile.options.compilerArgs += "-Xlint:$s"
}

if (extraLintOpts != "") {
extraLintOpts.split("[, ]").each { s ->
compile.options.compilerArgs += "-Xlint:$s"
}
}

compile.options.compilerArgs += [ "-Xmaxwarns", "1000" ]
}

allprojects {
// The following block is a workaround for the fact that presently Gradle
// can't set the -XDignore.symbol.file flag, because it appears that the
Expand Down Expand Up @@ -4078,30 +4104,49 @@ allprojects {

compile.options.forkOptions.executable = JAVAC

compile.options.warnings = IS_LINT

compile.options.compilerArgs += ["-XDignore.symbol.file", "-encoding", "UTF-8"]
compile.options.compilerArgs += [ "-Xmaxerrs", "1000" ]

// we use a custom javadoc command
project.javadoc.enabled = false

// Add in the -Xlint options
if (IS_LINT) {
LINT.split("[, ]").each { s ->
compile.options.compilerArgs += "-Xlint:$s"
}
compile.options.compilerArgs += [ "-Xmaxwarns", "1000" ]
if (compile.name == "compileJava" ||
compile.name == "compileFullJava" ||
compile.name.startsWith("compileJavaDOMBinding")) {

if (project.hasProperty("extraLintOptions")) {
//def extraLintOptions = project.ext.extraLintOptions;
extraLintOptions.split("[, ]").each { s ->
compile.options.compilerArgs += "-Xlint:$s"
}
}
// Add in the -Xlint options
compile.options.warnings = IS_LINT
if (IS_LINT) {
def extraLintOpts = project.hasProperty("extraLintOptions") ?
project.ext.extraLintOptions : ""
setupLintOptions(compile, LINT, extraLintOpts);

// TODO: enable the following once we are lint clean
//compile.options.compilerArgs += "-Werror"
// TODO: enable the following once we are lint clean
//compile.options.compilerArgs += "-Werror"
}
} else if (compile.name == "compileJslcJava" ||
compile.name == "compileToolJava") {

// Add in the -Xlint options
compile.options.warnings = IS_TOOL_LINT
if (IS_TOOL_LINT) {
def extraLintOpts = project.hasProperty("extraToolLintOptions") ?
project.ext.extraToolLintOptions : ""
setupLintOptions(compile, TOOL_LINT, extraLintOpts);
}
} else if (compile.name == "compileShimsJava" ||
compile.name.startsWith("compileTest")) {

// Add in the -Xlint options
compile.options.warnings = IS_TEST_LINT
if (IS_TEST_LINT) {
def extraLintOpts = project.hasProperty("extraTestLintOptions") ?
project.ext.extraTestLintOptions : ""
setupLintOptions(compile, TEST_LINT, extraLintOpts);
}
} else {
logger.warn("Unknown compilation task: ${compile.name}")
compile.options.warnings = false
}
} // tasks with javaCompile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public CurrencyStringConverter(NumberFormat numberFormat) {
* @deprecated This method was exposed erroneously and will be removed in a future version.
*/
@Deprecated(forRemoval = true, since = "22")
@SuppressWarnings("removal")
@Override
protected NumberFormat getNumberFormat() {
Locale _locale = locale == null ? Locale.getDefault() : locale;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public PercentageStringConverter(NumberFormat numberFormat) {
* @deprecated This method was exposed erroneously and will be removed in a future version.
*/
@Deprecated(forRemoval = true, since = "22")
@SuppressWarnings("removal")
@Override
public NumberFormat getNumberFormat() {
Locale _locale = locale == null ? Locale.getDefault() : locale;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ private static Partition getPartition(PartitionKey id, Map<PartitionKey,Partitio
private static final PartitionKey WILDCARD = new PartitionKey<>("*");

/* Place this selector into the partitioning map. Package accessible */
@SuppressWarnings("removal")
public void partition(Selector selector) {

SimpleSelector simpleSelector = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
* @deprecated This class was exposed erroneously and will be removed in a future version
*/
@Deprecated(since = "23", forRemoval = true)
@SuppressWarnings("removal")
final public class CompoundSelector extends Selector {

private final List<SimpleSelector> selectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4249,6 +4249,7 @@ private List<Selector> selectors(CssLexer lexer) {
return selectors;
}

@SuppressWarnings("removal")
private Selector selector(CssLexer lexer) {

List<Combinator> combinators = null;
Expand Down Expand Up @@ -4292,6 +4293,7 @@ private Selector selector(CssLexer lexer) {

}

@SuppressWarnings("removal")
private SimpleSelector simpleSelector(CssLexer lexer) {

String esel = "*"; // element selector. default to universal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public final class Match implements Comparable<Match> {
// then pseudoclass count, and finally matching types (i.e., java name count)
final int specificity;

@SuppressWarnings("removal")
Match(final Selector selector, Set<PseudoClass> pseudoClasses, int idCount, int styleClassCount) {
Objects.requireNonNull(selector);
Objects.requireNonNull(pseudoClasses);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ abstract public class Selector {
}

private static class UniversalSelector {
@SuppressWarnings("removal")
private static final Selector INSTANCE =
new SimpleSelector("*", null, null, null);
}
Expand Down Expand Up @@ -145,6 +146,7 @@ public int getOrdinal() {
* @param stringStore unused
* @throws IOException if writing to {@code DataOutputStream} fails
*/
@SuppressWarnings("removal")
protected void writeBinary(DataOutputStream os, StyleConverter.StringStore stringStore)
throws IOException {
if (this instanceof SimpleSelector) {
Expand All @@ -161,6 +163,7 @@ protected void writeBinary(DataOutputStream os, StyleConverter.StringStore strin
* @param strings string array containing selector details
* @throws IOException if reading from {@code DataInputStream} fails
*/
@SuppressWarnings("removal")
static Selector readBinary(int bssVersion, DataInputStream is, String[] strings)
throws IOException {
final int type = is.readByte();
Expand All @@ -175,6 +178,7 @@ static Selector readBinary(int bssVersion, DataInputStream is, String[] strings)
* @param cssSelector CSS selector string
* @return a {@code Selector}
*/
@SuppressWarnings("removal")
public static Selector createSelector(final String cssSelector) {
if (cssSelector == null || cssSelector.length() == 0) {
return null; // actually return a default no-match selector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
* @deprecated This class was exposed erroneously and will be removed in a future version
*/
@Deprecated(since = "23", forRemoval = true)
@SuppressWarnings("removal")
final public class SimpleSelector extends Selector {

/**
Expand Down

0 comments on commit e596a73

Please sign in to comment.