changeset 53215:e84983c2735e

8215368: Make Check.checkOverride call diagnosticPositionFor lazily Reviewed-by: mcimadamore, vromero
author cushon
date Thu, 13 Dec 2018 11:05:40 -0800
parents d5a2a29ca589
children 9dd0a2fdec24
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Dec 13 10:08:22 2018 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Dec 13 11:05:40 2018 -0800
@@ -26,6 +26,7 @@
 package com.sun.tools.javac.comp;
 
 import java.util.*;
+import java.util.function.Supplier;
 
 import javax.tools.JavaFileManager;
 
@@ -1797,7 +1798,7 @@
         if (!isDeprecatedOverrideIgnorable(other, origin)) {
             Lint prevLint = setLint(lint.augment(m));
             try {
-                checkDeprecated(TreeInfo.diagnosticPositionFor(m, tree), m, other);
+                checkDeprecated(() -> TreeInfo.diagnosticPositionFor(m, tree), m, other);
             } finally {
                 setLint(prevLint);
             }
@@ -3259,10 +3260,14 @@
     }
 
     void checkDeprecated(final DiagnosticPosition pos, final Symbol other, final Symbol s) {
+        checkDeprecated(() -> pos, other, s);
+    }
+
+    void checkDeprecated(Supplier<DiagnosticPosition> pos, final Symbol other, final Symbol s) {
         if ( (s.isDeprecatedForRemoval()
                 || s.isDeprecated() && !other.isDeprecated())
                 && (s.outermostClass() != other.outermostClass() || s.outermostClass() == null)) {
-            deferredLintHandler.report(() -> warnDeprecated(pos, s));
+            deferredLintHandler.report(() -> warnDeprecated(pos.get(), s));
         }
     }