changeset 1905:10711bd8bb2d

8020586: Warning produced for an incorrect file Summary: Always using DeferredLintHandler.immediateHandler when processing import classes Reviewed-by: mcimadamore
author jlahoda
date Wed, 17 Jul 2013 15:08:58 +0200
parents f65a807714ba
children e990e6bcecbe
files src/share/classes/com/sun/tools/javac/comp/MemberEnter.java test/tools/javac/warnings/6594914/Auxiliary.java test/tools/javac/warnings/6594914/ExplicitCompilation.out test/tools/javac/warnings/6594914/ImplicitCompilation.java test/tools/javac/warnings/6594914/ImplicitCompilation.out
diffstat 5 files changed, 32 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Wed Jul 17 14:21:12 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Wed Jul 17 15:08:58 2013 +0200
@@ -508,11 +508,17 @@
         // process package annotations
         annotateLater(tree.packageAnnotations, env, tree.packge);
 
-        // Import-on-demand java.lang.
-        importAll(tree.pos, reader.enterPackage(names.java_lang), env);
+        DeferredLintHandler prevLintHandler = chk.setDeferredLintHandler(DeferredLintHandler.immediateHandler);
+
+        try {
+            // Import-on-demand java.lang.
+            importAll(tree.pos, reader.enterPackage(names.java_lang), env);
 
-        // Process all import clauses.
-        memberEnter(tree.defs, env);
+            // Process all import clauses.
+            memberEnter(tree.defs, env);
+        } finally {
+            chk.setDeferredLintHandler(prevLintHandler);
+        }
     }
 
     // process the non-static imports and the static imports of types.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/warnings/6594914/Auxiliary.java	Wed Jul 17 15:08:58 2013 +0200
@@ -0,0 +1,5 @@
+import java.io.StringBufferInputStream;
+
+public class Auxiliary {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/warnings/6594914/ExplicitCompilation.out	Wed Jul 17 15:08:58 2013 +0200
@@ -0,0 +1,2 @@
+Auxiliary.java:1:15: compiler.warn.has.been.deprecated: java.io.StringBufferInputStream, java.io
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/warnings/6594914/ImplicitCompilation.java	Wed Jul 17 15:08:58 2013 +0200
@@ -0,0 +1,13 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 8020586
+ * @summary Warnings in the imports section should be attributed to the correct source file
+ * @clean Auxiliary ImplicitCompilation
+ * @compile/ref=ImplicitCompilation.out -XDrawDiagnostics -Xlint:deprecation -sourcepath . ImplicitCompilation.java
+ * @clean Auxiliary ImplicitCompilation
+ * @compile/ref=ExplicitCompilation.out -XDrawDiagnostics -Xlint:deprecation ImplicitCompilation.java Auxiliary.java
+ */
+
+public class ImplicitCompilation {
+    private Auxiliary a;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/warnings/6594914/ImplicitCompilation.out	Wed Jul 17 15:08:58 2013 +0200
@@ -0,0 +1,2 @@
+Auxiliary.java:1:15: compiler.warn.has.been.deprecated: java.io.StringBufferInputStream, java.io
+1 warning