Skip to content

8348611: Eliminate DeferredLintHandler and emit warnings after attribution #24584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 73 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
4fcc612
Track source end positions of declarations that support @SuppressWarn…
archiecobbs Feb 18, 2025
e235228
Add end position for variables coming from variableDeclaratorId().
archiecobbs Feb 18, 2025
daacc44
Fix bug where some warnings didn't have a source file position.
archiecobbs Feb 18, 2025
f5be4ca
Remove no-longer-needed workaround.
archiecobbs Mar 24, 2025
99b3c35
Remove unused code.
archiecobbs Mar 29, 2025
8027224
Merge branch 'JDK-8353221' into JDK-8352731
archiecobbs Mar 29, 2025
0f85a24
Add missing variable decl end position.
archiecobbs Apr 4, 2025
e9931f6
Add new method Log.clear().
archiecobbs Apr 4, 2025
a1108ac
Invoke Log.useSource() before recursing into attribution.
archiecobbs Apr 4, 2025
2344716
Revert accidentally included unrelated changes.
archiecobbs Apr 7, 2025
a9d5845
Reset the DiagnosticHandler stack in clear().
archiecobbs Apr 7, 2025
0127028
Refactoring/cleanup for handling of ending positions.
archiecobbs Apr 8, 2025
f831a10
Add field LintCategory.annotationSuppression.
archiecobbs Apr 8, 2025
0791ff7
Refactor handling of DEPRECATION_ON_IMPORT via new flag Check.importS…
archiecobbs Apr 9, 2025
c491643
Bump copyright.
archiecobbs Apr 9, 2025
5bb0b11
Add "not yet" comment to TEXT_BLOCKS.
archiecobbs Apr 9, 2025
2e68d7a
Small cleanups relating to Log.DiagnosticHandler.
archiecobbs Apr 9, 2025
dc3b98c
Add comment per review suggestion.
archiecobbs Apr 10, 2025
0a9f5e0
Merge branch 'JDK-8354090' into JDK-8348611
archiecobbs Apr 10, 2025
6852ed1
Merge branch 'JDK-8329951' into JDK-8348611
archiecobbs Apr 10, 2025
004cc5f
Merge branch 'JDK-8352731' into JDK-8348611
archiecobbs Apr 10, 2025
20257a5
Merge branch 'JDK-8354071' into JDK-8348611
archiecobbs Apr 10, 2025
0c98da7
Merge branch 'JDK-8350212' into JDK-8348611
archiecobbs Apr 10, 2025
6ff5e73
Merge branch 'JDK-8354216' into JDK-8348611
archiecobbs Apr 10, 2025
de2d3ab
Initial prototype for JDK-8348611.
archiecobbs Apr 10, 2025
7771061
Merge remote-tracking branch 'upstream/master' into JDK-8348611
archiecobbs Apr 11, 2025
e67b47b
Add test for retroactive @SuppressWarnings("dangling-doc-comments") b…
archiecobbs Apr 11, 2025
d0954d4
Remove another unnecessary call to Check.setLint().
archiecobbs Apr 11, 2025
f2bab52
Merge branch 'JDK-8354447' into JDK-8348611
archiecobbs Apr 11, 2025
4d870e0
Revert unintentional change in the behavior of the "dangling-doc-comm…
archiecobbs Apr 11, 2025
fbca756
Update regression test expected output after previous commit.
archiecobbs Apr 11, 2025
d855d51
Remove some obsolete invocations of Check.setLint() and unused imports.
archiecobbs Apr 12, 2025
3f4b5f1
Update ThisEscapeAnalyzer to use LintMapper for Lint calculation.
archiecobbs Apr 12, 2025
f2d2755
Some refactoring & cleanups for ThisEscapeAnalyzer.
archiecobbs Apr 16, 2025
3a6dd76
Some refactoring to make code clearer.
archiecobbs Apr 17, 2025
7c298b4
More cleanups & refactoring.
archiecobbs Apr 22, 2025
d19ad6f
Move LintMapper from "util" to "code" sub-package.
archiecobbs Apr 23, 2025
5f003d1
Update copyrights.
archiecobbs Apr 23, 2025
67ce889
Merge branch 'JDK-8350212' into JDK-8348611
archiecobbs Apr 23, 2025
9394f7e
Merge branch 'master' into JDK-8348611
archiecobbs Apr 24, 2025
3cd938a
Cleanups.
archiecobbs Apr 24, 2025
5ef9606
Refactor ThisEscapeAnalyzer to correct bug in suppression logic.
archiecobbs Apr 28, 2025
b8c3dcd
Merge branch 'JDK-8355753' into JDK-8348611
archiecobbs Apr 28, 2025
ddb0d4e
Update copyrights.
archiecobbs Apr 28, 2025
a356d88
Merge branch 'master' into JDK-8348611 to fix conflict.
archiecobbs May 1, 2025
81a25ca
Merge branch 'master' into JDK-8348611 to fix conflicts.
archiecobbs May 5, 2025
102beb5
Merge branch 'master' into JDK-8348611
archiecobbs May 7, 2025
348cf0e
Merge branch 'master' into JDK-8350212 to fix conflict.
archiecobbs May 9, 2025
563a143
Merge branch 'master' into JDK-8348611
archiecobbs May 10, 2025
a63e3d6
Merge branch 'master' into JDK-8348611 to fix conflicts.
archiecobbs May 20, 2025
b10fb8b
Merge branch 'master' into JDK-8355753
archiecobbs May 29, 2025
65e2679
Add additional tests for warnings generated from fields.
archiecobbs May 29, 2025
0122a0e
Merge branch 'master' into JDK-8350212
archiecobbs May 29, 2025
0898c55
Revert TreeInfo.endPos() refactoring except for "bracePos" renaming.
archiecobbs May 30, 2025
f79e35f
Remove extraneous semicolons.
archiecobbs May 30, 2025
67f8cd1
Merge branch 'master' into JDK-8348611 to fix conflict.
archiecobbs May 30, 2025
9a15a63
Merge branch 'JDK-8355753' into JDK-8348611
archiecobbs May 30, 2025
205f77e
Update EndPosTable.replaceTree() to handle a new node equal to null.
archiecobbs May 30, 2025
a62ebc6
Merge branch 'JDK-8350212' into JDK-8348611
archiecobbs May 31, 2025
6ab327b
Merge branch 'master' into JDK-8348611
archiecobbs May 31, 2025
7f062a6
Merge branch 'master' into JDK-8348611 to fix conflicts.
archiecobbs Jun 5, 2025
2c4d228
Merge branch 'master' into JDK-8348611
archiecobbs Jun 5, 2025
16debaa
Small refactoring to utilize new method Options.isExplicitlyDisabled().
archiecobbs Jun 10, 2025
75d9edf
Refactor MandatoryWarningHandler to just be an aggregator.
archiecobbs Jun 13, 2025
cde1f5e
Revert PR #24600 (for JDK-8354447) from this branch so it's not a dep…
archiecobbs Jun 13, 2025
24df3a2
Add comment to regression test.
archiecobbs Jun 13, 2025
b7adf7c
Revert regression test change that is no longer necessary.
archiecobbs Jun 13, 2025
5069bf2
Restore behavior when both -Xlint:options and -Xlint:-options are given.
archiecobbs Jun 17, 2025
8dcea70
No need for /nodynamiccopyright/ with this test.
archiecobbs Jun 17, 2025
38febc6
Merge branch 'JDK-8359596' into JDK-8348611
archiecobbs Jun 18, 2025
9e78831
Ensure that "-Xlint:none" still works for the affected warnings.
archiecobbs Jun 18, 2025
34ab5ed
Merge branch 'JDK-8359596' into JDK-8348611
archiecobbs Jun 18, 2025
982d2b8
Merge branch 'MandatoryWarningCleanup' into JDK-8348611 to fix confli…
archiecobbs Jun 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, 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
Expand Down Expand Up @@ -412,6 +412,7 @@ public void process(Env<AttrContext> env) {
f.run(compiler.todo, classes);
}
} finally {
compiler.log.reportOutstandingWarnings();
compiler.log.flush();
}
return results;
Expand Down Expand Up @@ -483,8 +484,10 @@ public void process(Env<AttrContext> env) {
}
}
finally {
if (compiler != null)
if (compiler != null) {
compiler.log.reportOutstandingWarnings();
compiler.log.flush();
}
}
return results;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import com.sun.source.util.TaskListener;
import com.sun.source.util.TreeScanner;
import com.sun.tools.javac.code.Kinds;
import com.sun.tools.javac.code.LintMapper;
import com.sun.tools.javac.code.Preview;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symtab;
Expand Down Expand Up @@ -268,12 +269,11 @@ void clear() {
if (ht.get(Log.logKey) instanceof ReusableLog) {
//log already inited - not first round
Log.instance(this).clear();
LintMapper.instance(this).clear();
Enter.instance(this).newRound();
((ReusableJavaCompiler)ReusableJavaCompiler.instance(this)).clear();
Types.instance(this).newRound();
Check.instance(this).newRound();
Check.instance(this).clear(); //clear mandatory warning handlers
Preview.instance(this).clear(); //clear mandatory warning handlers
Modules.instance(this).newRound();
Annotate.instance(this).newRound();
CompileStates.instance(this).clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,14 @@ public TypeMirror getType(DocTreePath path) {
Log.DeferredDiagnosticHandler deferredDiagnosticHandler = log.new DeferredDiagnosticHandler();
try {
Env<AttrContext> env = getAttrContext(path.getTreePath());
Type t = attr.attribType(dcReference.qualifierExpression, env);
if (t != null && !t.isErroneous()) {
return t;
JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile);
try {
Type t = attr.attribType(dcReference.qualifierExpression, env);
if (t != null && !t.isErroneous()) {
return t;
}
} finally {
log.useSource(prevSource);
}
} catch (Abort e) { // may be thrown by Check.completionError in case of bad class file
return null;
Expand All @@ -388,6 +393,7 @@ private Symbol attributeDocReference(TreePath path, DCReference ref) {
return null;
}
Log.DeferredDiagnosticHandler deferredDiagnosticHandler = log.new DeferredDiagnosticHandler();
JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile);
try {
final TypeSymbol tsym;
final Name memberName;
Expand Down Expand Up @@ -509,6 +515,7 @@ private Symbol attributeDocReference(TreePath path, DCReference ref) {
} catch (Abort e) { // may be thrown by Check.completionError in case of bad class file
return null;
} finally {
log.useSource(prevSource);
log.popDiagnosticHandler(deferredDiagnosticHandler);
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,8 @@ public enum LintCategory {

/**
* Warn about issues relating to use of text blocks
*
* <p>
* This category is not supported by {@code @SuppressWarnings} (yet - see JDK-8224228).
*/
TEXT_BLOCKS("text-blocks", false),
TEXT_BLOCKS("text-blocks"),

/**
* Warn about possible 'this' escapes before subclass instance is fully initialized.
Expand Down Expand Up @@ -476,27 +473,6 @@ public boolean isSuppressed(LintCategory lc) {
return suppressedValues.contains(lc);
}

/**
* Helper method. Log a lint warning if its lint category is enabled.
*
* @param warning key for the localized warning message
*/
public void logIfEnabled(LintWarning warning) {
logIfEnabled(null, warning);
}

/**
* Helper method. Log a lint warning if its lint category is enabled.
*
* @param pos source position at which to report the warning
* @param warning key for the localized warning message
*/
public void logIfEnabled(DiagnosticPosition pos, LintWarning warning) {
if (isEnabled(warning.getLintCategory())) {
log.warning(pos, warning);
}
}

/**
* Obtain the set of recognized lint warning categories suppressed at the given symbol's declaration.
*
Expand Down
Loading