8020586: Warning produced for an incorrect file

Wed, 17 Jul 2013 15:08:58 +0200

author
jlahoda
date
Wed, 17 Jul 2013 15:08:58 +0200
changeset 1906
10711bd8bb2d
parent 1905
f65a807714ba
child 1907
e990e6bcecbe

8020586: Warning produced for an incorrect file
Summary: Always using DeferredLintHandler.immediateHandler when processing import classes
Reviewed-by: mcimadamore

src/share/classes/com/sun/tools/javac/comp/MemberEnter.java file | annotate | diff | comparison | revisions
test/tools/javac/warnings/6594914/Auxiliary.java file | annotate | diff | comparison | revisions
test/tools/javac/warnings/6594914/ExplicitCompilation.out file | annotate | diff | comparison | revisions
test/tools/javac/warnings/6594914/ImplicitCompilation.java file | annotate | diff | comparison | revisions
test/tools/javac/warnings/6594914/ImplicitCompilation.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Wed Jul 17 14:21:12 2013 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Wed Jul 17 15:08:58 2013 +0200
     1.3 @@ -508,11 +508,17 @@
     1.4          // process package annotations
     1.5          annotateLater(tree.packageAnnotations, env, tree.packge);
     1.6  
     1.7 -        // Import-on-demand java.lang.
     1.8 -        importAll(tree.pos, reader.enterPackage(names.java_lang), env);
     1.9 +        DeferredLintHandler prevLintHandler = chk.setDeferredLintHandler(DeferredLintHandler.immediateHandler);
    1.10  
    1.11 -        // Process all import clauses.
    1.12 -        memberEnter(tree.defs, env);
    1.13 +        try {
    1.14 +            // Import-on-demand java.lang.
    1.15 +            importAll(tree.pos, reader.enterPackage(names.java_lang), env);
    1.16 +
    1.17 +            // Process all import clauses.
    1.18 +            memberEnter(tree.defs, env);
    1.19 +        } finally {
    1.20 +            chk.setDeferredLintHandler(prevLintHandler);
    1.21 +        }
    1.22      }
    1.23  
    1.24      // process the non-static imports and the static imports of types.
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/warnings/6594914/Auxiliary.java	Wed Jul 17 15:08:58 2013 +0200
     2.3 @@ -0,0 +1,5 @@
     2.4 +import java.io.StringBufferInputStream;
     2.5 +
     2.6 +public class Auxiliary {
     2.7 +
     2.8 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/warnings/6594914/ExplicitCompilation.out	Wed Jul 17 15:08:58 2013 +0200
     3.3 @@ -0,0 +1,2 @@
     3.4 +Auxiliary.java:1:15: compiler.warn.has.been.deprecated: java.io.StringBufferInputStream, java.io
     3.5 +1 warning
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/tools/javac/warnings/6594914/ImplicitCompilation.java	Wed Jul 17 15:08:58 2013 +0200
     4.3 @@ -0,0 +1,13 @@
     4.4 +/**
     4.5 + * @test /nodynamiccopyright/
     4.6 + * @bug 8020586
     4.7 + * @summary Warnings in the imports section should be attributed to the correct source file
     4.8 + * @clean Auxiliary ImplicitCompilation
     4.9 + * @compile/ref=ImplicitCompilation.out -XDrawDiagnostics -Xlint:deprecation -sourcepath . ImplicitCompilation.java
    4.10 + * @clean Auxiliary ImplicitCompilation
    4.11 + * @compile/ref=ExplicitCompilation.out -XDrawDiagnostics -Xlint:deprecation ImplicitCompilation.java Auxiliary.java
    4.12 + */
    4.13 +
    4.14 +public class ImplicitCompilation {
    4.15 +    private Auxiliary a;
    4.16 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/tools/javac/warnings/6594914/ImplicitCompilation.out	Wed Jul 17 15:08:58 2013 +0200
     5.3 @@ -0,0 +1,2 @@
     5.4 +Auxiliary.java:1:15: compiler.warn.has.been.deprecated: java.io.StringBufferInputStream, java.io
     5.5 +1 warning

mercurial