8020586: Warning produced for an incorrect file
authorjlahoda
Wed, 17 Jul 2013 15:08:58 +0200
changeset 18919 7d1f1448a9db
parent 18918 4e8769f15a95
child 18920 5111c1aa3ecd
8020586: Warning produced for an incorrect file Summary: Always using DeferredLintHandler.immediateHandler when processing import classes Reviewed-by: mcimadamore
langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
langtools/test/tools/javac/warnings/6594914/Auxiliary.java
langtools/test/tools/javac/warnings/6594914/ExplicitCompilation.out
langtools/test/tools/javac/warnings/6594914/ImplicitCompilation.java
langtools/test/tools/javac/warnings/6594914/ImplicitCompilation.out
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Wed Jul 17 14:21:12 2013 +0100
+++ b/langtools/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/langtools/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/langtools/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/langtools/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/langtools/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