-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8344148: Add an explicit compiler phase for warning generation
Reviewed-by: vromero
- Loading branch information
1 parent
8d388cc
commit 27646e5
Showing
19 changed files
with
219 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/WarningAnalyzer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) 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 | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Oracle designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
package com.sun.tools.javac.comp; | ||
|
||
import com.sun.tools.javac.util.Context; | ||
import com.sun.tools.javac.util.Log; | ||
|
||
/** This pass checks for various things to warn about. | ||
* It runs after attribution and flow analysis. | ||
* | ||
* <p><b>This is NOT part of any supported API. | ||
* If you write code that depends on this, you do so at your own risk. | ||
* This code and its internal interfaces are subject to change or | ||
* deletion without notice.</b> | ||
*/ | ||
public class WarningAnalyzer { | ||
|
||
protected static final Context.Key<WarningAnalyzer> contextKey = new Context.Key<>(); | ||
|
||
private final Log log; | ||
private final ThisEscapeAnalyzer thisEscapeAnalyzer; | ||
|
||
public static WarningAnalyzer instance(Context context) { | ||
WarningAnalyzer instance = context.get(contextKey); | ||
if (instance == null) | ||
instance = new WarningAnalyzer(context); | ||
return instance; | ||
} | ||
|
||
@SuppressWarnings("this-escape") | ||
protected WarningAnalyzer(Context context) { | ||
context.put(contextKey, this); | ||
log = Log.instance(context); | ||
thisEscapeAnalyzer = ThisEscapeAnalyzer.instance(context); | ||
} | ||
|
||
public void analyzeTree(Env<AttrContext> env) { | ||
thisEscapeAnalyzer.analyzeTree(env); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
[attribute A] | ||
[flow A] | ||
[warn A] | ||
[attribute B] | ||
[flow B] | ||
[warn B] | ||
[desugar B] | ||
[desugar A] | ||
[generate code A] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test/langtools/tools/javac/implicitCompile/SkipAttrFlowGenForImplicits.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[attribute Explicit] | ||
[flow Explicit] | ||
[warn Explicit] | ||
[desugar Explicit] | ||
[generate code Explicit] |
Oops, something went wrong.