8346294: Invalid lint category specified in compiler.properties

Reviewed-by: mcimadamore
This commit is contained in:
Archie Cobbs
2024-12-17 03:18:25 +00:00
parent 18d1d61116
commit 87804f24b2
3 changed files with 14 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 2024, 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
@@ -82,5 +82,5 @@ suppress.warnings=\
@SuppressWarnings("rawtypes")\n
lint.category=\
LintCategory.get({0})
LintCategory.get({0}).get()

View File

@@ -28,6 +28,7 @@ package com.sun.tools.javac.code;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import com.sun.tools.javac.code.Symbol.*;
@@ -362,8 +363,14 @@ public class Lint
map.put(option, this);
}
public static LintCategory get(String option) {
return map.get(option);
/**
* Get the {@link LintCategory} having the given command line option.
*
* @param option lint category option string
* @return corresponding {@link LintCategory}, or empty if none exists
*/
public static Optional<LintCategory> get(String option) {
return Optional.ofNullable(map.get(option));
}
public final String option;
@@ -441,9 +448,8 @@ public class Lint
public void visitConstant(Attribute.Constant value) {
if (value.type.tsym == syms.stringType.tsym) {
LintCategory lc = LintCategory.get((String) (value.value));
if (lc != null)
suppress(lc);
LintCategory.get((String)value.value)
.ifPresent(this::suppress);
}
}

View File

@@ -1880,7 +1880,7 @@ compiler.warn.lintOption=\
compiler.warn.constant.SVUID=\
serialVersionUID must be constant in class {0}
# lint: dangling
# lint: dangling-doc-comments
compiler.warn.dangling.doc.comment=\
documentation comment is not attached to any declaration