8370800: Downgrade cant.attach.type.annotations diagnostics to warnings

This commit is contained in:
Liam Miller-Cushon 2025-10-28 12:38:26 +01:00
parent c867971340
commit 8a5aba5800
3 changed files with 11 additions and 8 deletions

View File

@ -2330,7 +2330,7 @@ public class ClassReader {
} catch (CompletionFailure ex) {
JavaFileObject prev = log.useSource(currentClassFile);
try {
log.error(Errors.CantAttachTypeAnnotations(attributes, s.owner, s.name, ex.getDetailValue()));
log.warning(Warnings.CantAttachTypeAnnotations(attributes, s.owner, s.name, ex.getDetailValue()));
} finally {
log.useSource(prev);
}

View File

@ -2465,7 +2465,7 @@ compiler.warn.annotation.method.not.found.reason=\
Cannot find annotation method ''{1}()'' in type ''{0}'': {2}
# 0: list of annotation, 1: symbol, 2: name, 3: message segment
compiler.err.cant.attach.type.annotations=\
compiler.warn.cant.attach.type.annotations=\
Cannot attach type annotations {0} to {1}.{2}:\n\
{3}

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 8337998
* @bug 8337998 8370800
* @summary CompletionFailure in getEnclosingType attaching type annotations
* @library /tools/javac/lib /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
@ -74,13 +74,14 @@ public class CompletionErrorOnEnclosingType {
tb.createDirectories(out);
new JavacTask(tb).outdir(out).files(tb.findJavaFiles(src)).run();
// now if we remove A.class there will be an error but javac should not crash
// now if we remove A.class javac should not crash
tb.deleteFiles(out.resolve("A.class"));
List<String> log =
new JavacTask(tb)
.outdir(out)
.classpath(out)
.options("-XDrawDiagnostics")
.options("-Werror", "-XDrawDiagnostics")
.files(src.resolve("C.java"))
.run(Expect.FAIL)
.writeAll()
@ -88,9 +89,11 @@ public class CompletionErrorOnEnclosingType {
var expectedOutput =
List.of(
"B.class:-:-: compiler.err.cant.attach.type.annotations: @Anno, B, a,"
+ " (compiler.misc.class.file.not.found: A)",
"1 error");
"B.class:-:-: compiler.warn.cant.attach.type.annotations: @Anno, B, a,"
+ " (compiler.misc.class.file.not.found: A)",
"- compiler.err.warnings.and.werror",
"1 error",
"1 warning");
if (!expectedOutput.equals(log)) {
throw new Exception("expected output not found: " + log);
}